* [PATCH net-next v11 0/4] net/sched: sch_fq_pie: add per-flow class statistics
@ 2026-12-04 19:01 Hemendra M. Naik
2026-12-04 19:01 ` [PATCH net-next v11 1/4] net/sched: sch_fq_pie: add per-flow statistics via class ops Hemendra M. Naik
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Hemendra M. Naik @ 2026-12-04 19:01 UTC (permalink / raw)
To: netdev
Cc: davem, edumazet, kuba, pabeni, horms, jiri, jhs, shuah,
donald.hunter, ast, toke, liuhangbin, j.koeppeler, linux-kernel,
linux-kselftest, vishy0777, tahiliani, Hemendra M. Naik
FQ-PIE runs an independent PIE controller per flow but exposes no
per-flow statistics. This series wires up fq_pie_class_ops to expose
per-flow AQM state (prob, delay, deficit, avg_dq_rate) via
'tc -s class show', following a similar pattern as FQ-CoDel.
This patch series is accompanied by a companion iproute2 patch series that
will be posted on net-next as well.
Both the kernel and iproute2 patches can also be found in GitHub:
- https://github.com/H-N41K/linux-net-next/tree/fq_pie_class_stats/
- https://github.com/H-N41K/iproute2-next/tree/fq_pie_class_stats
---
Changelog:
v11:
- Addressed Sashiko review comments:
- Made use of WRITE_ONCE() macro on per-flow variables: deficit, qlen, backlog, vars.accu_prob
- Updated tc-pie-xstats doc strings in tc.yaml
- Updated the commit messages in patches 1/4 and 4/4
v10: https://lore.kernel.org/netdev/20261109071017.438478-1-hemendranaik@gmail.com/
- Update Documentation/netlink/specs/tc.yaml for fq_pie
v9: https://lore.kernel.org/netdev/20260928043358.6866-1-hemendranaik@gmail.com/
- Add a blank line between structs in commit 1/3.
v8: https://lore.kernel.org/netdev/20260922205924.32173-1-hemendranaik@gmail.com/
- No code changes since v7.
- Reword commit message to reflect usage of div_u64().
v7: https://lore.kernel.org/netdev/20260919060125.38063-1-hemendranaik@gmail.com/
- No code changes since v6.
- Rebased over the latest net-next tree and re-submitted patch.
v6: https://lore.kernel.org/netdev/20260917204225.275251-1-hemendranaik@gmail.com/
- Address Sashiko review comments:
- Revert the fq_pie flows range to [1..65536].
- Also drop the accompanying selftest 83be change.
- Compute the per-flow delay with div_u64() on the full 64-bit
nanosecond value.
- Widen avg_dq_rate to u64 before scaling it by PSCHED_TICKS_PER_SEC.
- Document the 36 to 64 byte xstats growth in the patch 1 commit message.
- Fix selftest 83c0. The ping payload exceeded the TBF burst so no
packet ever reached fq_pie, and the missing -W left the run waiting
out ping's default timeout.
v5: https://lore.kernel.org/netdev/20260902035231.81866-1-hemendranaik@gmail.com/
- Addressed Sashiko review comments:
- Omitted .tcf_block / .bind_tcf / .unbind_tcf from cl_ops (statistics
only being exported; filter attach to fq_pie is now disabled).
- Dropped empty tc_fq_pie_xqd_stats placeholder; class_stats is a direct
struct member.
- Limited flows to [1..65535] so per-flow class handles fit in a 16-bit
TC minor.
- Rewrote selftest 83c0 with TBF + fq_pie, ping traffic, and
matchCount 1 on per-flow stats output.
- Updated selftest 83be for the new flows limit.
- Dropped the tools/include UAPI mirror changes from patch 3/3.
v4: https://lore.kernel.org/netdev/20260727164056.106203-1-hemendranaik@gmail.com/
- Fixed unaligned commit message; moved typo fixes to another patch.
v3: https://lore.kernel.org/netdev/20260630183702.170798-1-hemendranaik@gmail.com/
- No changes since v2.
- Resent after the previous submission was deferred due to the
net-next tree closing during review.
- Updated corresponding iproute2 patch in response to review comments;
kernel patches unchanged.
v2: https://lore.kernel.org/netdev/20260614125000.6058-1-hemendranaik@gmail.com/
- Addressed ABI backward compatibility issue for tc_fq_pie_xstats.
v1: https://lore.kernel.org/netdev/20260531125314.22492-1-hemendranaik@gmail.com/
- Initial submission
Hemendra M. Naik (4):
net/sched: sch_fq_pie: add per-flow statistics via class ops
selftests: tc-testing: add fq_pie per-flow class stats test
net/sched: pie: correct tc_pie_xstats field documentation
Documentation/netlink/specs: tc: describe fq_pie per-flow class stats
Documentation/netlink/specs/tc.yaml | 32 +++++++
include/uapi/linux/pkt_sched.h | 21 ++++-
net/sched/sch_fq_pie.c | 88 ++++++++++++++++++-
.../tc-testing/tc-tests/qdiscs/fq_pie.json | 27 ++++++
4 files changed, 165 insertions(+), 3 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net-next v11 1/4] net/sched: sch_fq_pie: add per-flow statistics via class ops
2026-12-04 19:01 [PATCH net-next v11 0/4] net/sched: sch_fq_pie: add per-flow class statistics Hemendra M. Naik
@ 2026-12-04 19:01 ` Hemendra M. Naik
2026-12-05 19:17 ` netdev-bot+sashiko
2026-12-04 19:01 ` [PATCH net-next v11 2/4] selftests: tc-testing: add fq_pie per-flow class stats test Hemendra M. Naik
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Hemendra M. Naik @ 2026-12-04 19:01 UTC (permalink / raw)
To: netdev
Cc: davem, edumazet, kuba, pabeni, horms, jiri, jhs, shuah,
donald.hunter, ast, toke, liuhangbin, j.koeppeler, linux-kernel,
linux-kselftest, vishy0777, tahiliani, Hemendra M. Naik
FQ-PIE schedules independent PIE controllers per flow but exposes no
per-flow AQM state. Without class-level statistics there is no way to
observe the per-flow drop probability, queue delay, deficit or dequeue
rate from userspace.
Extend tc_fq_pie_xstats with a type discriminator and tc_fq_pie_cl_stats
for per-flow metrics. The nine existing __u32 counters keep their
offsets, type is appended at offset 36 and class_stats follows it,
growing the structure from 36 to 64 bytes.
Wire up fq_pie_class_ops with walk, dump, and dump_stats only so that
'tc -s class show' reports per-flow state (prob, delay, deficit,
avg_dq_rate - the last if dq_rate_estimating is enabled). leaf and find
are also added, but as required stubs. Filter attachment callbacks
(.tcf_block, .bind_tcf, .unbind_tcf) are omitted.
Used WRITE_ONCE() macro to guard following variables:
- deficit
- qlen
- backlog
- vars.accu_prob
The changes here have a companion iproute2 change,
"tc: fq_pie: add support for printing per-flow PIE statistics".
Signed-off-by: Hemendra M. Naik <hemendranaik@gmail.com>
Signed-off-by: Vishal Kamath <vishy0777@gmail.com>
Signed-off-by: Mohit P. Tahiliani <tahiliani@nitk.edu.in>
---
include/uapi/linux/pkt_sched.h | 17 ++++++
net/sched/sch_fq_pie.c | 108 +++++++++++++++++++++++++++++----
2 files changed, 114 insertions(+), 11 deletions(-)
diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h
index 490efd288526..fef848eaaab2 100644
--- a/include/uapi/linux/pkt_sched.h
+++ b/include/uapi/linux/pkt_sched.h
@@ -953,6 +953,21 @@ enum {
};
#define TCA_FQ_PIE_MAX (__TCA_FQ_PIE_MAX - 1)
+enum {
+ TCA_FQ_PIE_XSTATS_QDISC,
+ TCA_FQ_PIE_XSTATS_CLASS,
+};
+
+struct tc_fq_pie_cl_stats {
+ __u64 prob; /* current probability */
+ __u32 delay; /* current delay in microseconds */
+ __s32 deficit; /* number of remaining byte credits */
+ __u32 avg_dq_rate; /* current average dq_rate in
+ * bytes/second
+ */
+ __u32 dq_rate_estimating; /* is avg_dq_rate being calculated? */
+};
+
struct tc_fq_pie_xstats {
__u32 packets_in; /* total number of packets enqueued */
__u32 dropped; /* packets dropped due to fq_pie_action */
@@ -963,6 +978,8 @@ struct tc_fq_pie_xstats {
__u32 new_flows_len; /* count of flows in new list */
__u32 old_flows_len; /* count of flows in old list */
__u32 memory_usage; /* total memory across all queues */
+ __u32 type;
+ struct tc_fq_pie_cl_stats class_stats;
};
/* CBS */
diff --git a/net/sched/sch_fq_pie.c b/net/sched/sch_fq_pie.c
index 5982847df8f8..d66fd56bfaed 100644
--- a/net/sched/sch_fq_pie.c
+++ b/net/sched/sch_fq_pie.c
@@ -190,17 +190,17 @@ static int fq_pie_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch,
if (list_empty(&sel_flow->flowchain)) {
list_add_tail(&sel_flow->flowchain, &q->new_flows);
q->new_flow_count++;
- sel_flow->deficit = q->quantum;
- sel_flow->qlen = 0;
- sel_flow->backlog = 0;
+ WRITE_ONCE(sel_flow->deficit, q->quantum);
+ WRITE_ONCE(sel_flow->qlen, 0);
+ WRITE_ONCE(sel_flow->backlog, 0);
}
- sel_flow->qlen++;
- sel_flow->backlog += pkt_len;
+ WRITE_ONCE(sel_flow->qlen, sel_flow->qlen + 1);
+ WRITE_ONCE(sel_flow->backlog, sel_flow->backlog + pkt_len);
return NET_XMIT_SUCCESS;
}
out:
q->stats.dropped++;
- sel_flow->vars.accu_prob = 0;
+ WRITE_ONCE(sel_flow->vars.accu_prob, 0);
qdisc_drop_reason(skb, sch, to_free, reason);
return NET_XMIT_CN;
}
@@ -254,7 +254,7 @@ static struct sk_buff *fq_pie_qdisc_dequeue(struct Qdisc *sch)
flow = list_first_entry(head, struct fq_pie_flow, flowchain);
/* Flow has exhausted all its credits */
if (flow->deficit <= 0) {
- flow->deficit += q->quantum;
+ WRITE_ONCE(flow->deficit, flow->deficit + q->quantum);
list_move_tail(&flow->flowchain, &q->old_flows);
goto begin;
}
@@ -276,9 +276,9 @@ static struct sk_buff *fq_pie_qdisc_dequeue(struct Qdisc *sch)
goto begin;
}
- flow->qlen--;
- flow->deficit -= pkt_len;
- flow->backlog -= pkt_len;
+ WRITE_ONCE(flow->qlen, flow->qlen - 1);
+ WRITE_ONCE(flow->deficit, flow->deficit - pkt_len);
+ WRITE_ONCE(flow->backlog, flow->backlog - pkt_len);
q->memory_usage -= get_pie_cb(skb)->mem_usage;
pie_process_dequeue(skb, &q->p_params, &flow->vars, flow->backlog);
return skb;
@@ -511,7 +511,11 @@ static int fq_pie_dump(struct Qdisc *sch, struct sk_buff *skb)
static int fq_pie_dump_stats(struct Qdisc *sch, struct gnet_dump *d)
{
struct fq_pie_sched_data *q = qdisc_priv(sch);
- struct tc_fq_pie_xstats st = { 0 };
+
+ struct tc_fq_pie_xstats st = {
+ .type = TCA_FQ_PIE_XSTATS_QDISC,
+ };
+
struct list_head *pos;
sch_tree_lock(sch);
@@ -563,7 +567,89 @@ static void fq_pie_destroy(struct Qdisc *sch)
kvfree(q->flows);
}
+static struct Qdisc *fq_pie_leaf(struct Qdisc *sch, unsigned long arg)
+{
+ return NULL;
+}
+
+static unsigned long fq_pie_find(struct Qdisc *sch, u32 classid)
+{
+ return 0;
+}
+
+static int fq_pie_dump_class(struct Qdisc *sch, unsigned long cl,
+ struct sk_buff *skb, struct tcmsg *tcm)
+{
+ tcm->tcm_handle |= TC_H_MIN(cl);
+ return 0;
+}
+
+static int fq_pie_dump_class_stats(struct Qdisc *sch, unsigned long cl,
+ struct gnet_dump *d)
+{
+ struct fq_pie_sched_data *q = qdisc_priv(sch);
+ struct gnet_stats_queue qs = { 0 };
+ struct tc_fq_pie_xstats xstats;
+ u32 idx = cl - 1;
+
+ if (idx < q->flows_cnt) {
+ const struct fq_pie_flow *flow = &q->flows[idx];
+
+ memset(&xstats, 0, sizeof(xstats));
+ xstats.type = TCA_FQ_PIE_XSTATS_CLASS;
+ xstats.class_stats.prob =
+ READ_ONCE(flow->vars.prob) << BITS_PER_BYTE;
+ xstats.class_stats.delay =
+ div_u64(PSCHED_TICKS2NS(READ_ONCE(flow->vars.qdelay)),
+ NSEC_PER_USEC);
+ xstats.class_stats.deficit = READ_ONCE(flow->deficit);
+ xstats.class_stats.dq_rate_estimating =
+ READ_ONCE(q->p_params.dq_rate_estimator);
+
+ if (xstats.class_stats.dq_rate_estimating) {
+ xstats.class_stats.avg_dq_rate =
+ ((u64)READ_ONCE(flow->vars.avg_dq_rate)
+ * PSCHED_TICKS_PER_SEC) >> PIE_SCALE;
+ }
+
+ qs.qlen = READ_ONCE(flow->qlen);
+ qs.backlog = READ_ONCE(flow->backlog);
+ }
+ if (gnet_stats_copy_queue(d, NULL, &qs, qs.qlen) < 0)
+ return -1;
+ if (idx < q->flows_cnt)
+ return gnet_stats_copy_app(d, &xstats, sizeof(xstats));
+ return 0;
+}
+
+static void fq_pie_walk(struct Qdisc *sch, struct qdisc_walker *arg)
+{
+ struct fq_pie_sched_data *q = qdisc_priv(sch);
+ unsigned int i;
+
+ if (arg->stop)
+ return;
+
+ for (i = 0; i < q->flows_cnt; i++) {
+ if (list_empty(&q->flows[i].flowchain)) {
+ arg->count++;
+ continue;
+ }
+ if (!tc_qdisc_stats_dump(sch, i + 1, arg))
+ break;
+ }
+}
+
+static const struct Qdisc_class_ops fq_pie_class_ops = {
+ .leaf = fq_pie_leaf,
+ .find = fq_pie_find,
+ .dump = fq_pie_dump_class,
+ .dump_stats = fq_pie_dump_class_stats,
+ .walk = fq_pie_walk,
+};
+
static struct Qdisc_ops fq_pie_qdisc_ops __read_mostly = {
+ .cl_ops = &fq_pie_class_ops,
.id = "fq_pie",
.priv_size = sizeof(struct fq_pie_sched_data),
.enqueue = fq_pie_qdisc_enqueue,
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next v11 2/4] selftests: tc-testing: add fq_pie per-flow class stats test
2026-12-04 19:01 [PATCH net-next v11 0/4] net/sched: sch_fq_pie: add per-flow class statistics Hemendra M. Naik
2026-12-04 19:01 ` [PATCH net-next v11 1/4] net/sched: sch_fq_pie: add per-flow statistics via class ops Hemendra M. Naik
@ 2026-12-04 19:01 ` Hemendra M. Naik
2026-12-05 19:17 ` netdev-bot+sashiko
2026-12-04 19:01 ` [PATCH net-next v11 3/4] net/sched: pie: correct tc_pie_xstats field documentation Hemendra M. Naik
2026-12-04 19:01 ` [PATCH net-next v11 4/4] Documentation/netlink/specs: tc: describe fq_pie per-flow class stats Hemendra M. Naik
3 siblings, 1 reply; 8+ messages in thread
From: Hemendra M. Naik @ 2026-12-04 19:01 UTC (permalink / raw)
To: netdev
Cc: davem, edumazet, kuba, pabeni, horms, jiri, jhs, shuah,
donald.hunter, ast, toke, liuhangbin, j.koeppeler, linux-kernel,
linux-kselftest, vishy0777, tahiliani, Hemendra M. Naik
Add tc-testing case 83c0: build a TBF + fq_pie hierarchy on $DUMMY, push
traffic through it with ping, and verify that 'tc -s class show' reports
an fq_pie class.
The per-flow counters themselves (prob, delay, deficit) are printed with
the companion iproute2 change, "tc: fq_pie: add support for printing
per-flow PIE statistics"
Signed-off-by: Hemendra M. Naik <hemendranaik@gmail.com>
Signed-off-by: Vishal Kamath <vishy0777@gmail.com>
Signed-off-by: Mohit P. Tahiliani <tahiliani@nitk.edu.in>
---
.../tc-testing/tc-tests/qdiscs/fq_pie.json | 27 +++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/fq_pie.json b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/fq_pie.json
index 229fe1bf4a90..15b2667285eb 100644
--- a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/fq_pie.json
+++ b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/fq_pie.json
@@ -40,5 +40,32 @@
"matchPattern": "qdisc fq_pie 1: root refcnt [0-9]+ limit 1p",
"matchCount": "1",
"teardown": ["$TC qdisc del dev $DEV1 handle 1: root"]
+ },
+ {
+ "id": "83c0",
+ "name": "FQ-PIE class stats accessible via tc class show",
+ "category": [
+ "qdisc",
+ "fq_pie"
+ ],
+ "plugins": {
+ "requires": "nsPlugin"
+ },
+ "setup": [
+ "$IP link set dev $DUMMY up || true",
+ "$IP addr add 10.10.11.10/24 dev $DUMMY || true",
+ "$TC qdisc add dev $DUMMY root handle 1: tbf rate 8bit burst 100b latency 100ms",
+ "$TC qdisc add dev $DUMMY parent 1:1 handle 2: fq_pie limit 100 flows 1",
+ "ping -c 50 -i 0.001 -W 0.01 -s 56 10.10.11.11 -I $DUMMY > /dev/null 2>&1 || true"
+ ],
+ "cmdUnderTest": "$TC -s class show dev $DUMMY",
+ "expExitCode": "0",
+ "verifyCmd": "$TC -s class show dev $DUMMY",
+ "matchPattern": "class fq_pie 2:[0-9]+ .*prob .*delay .*deficit",
+ "matchCount": "1",
+ "teardown": [
+ "$TC qdisc del dev $DUMMY handle 1: root",
+ "$IP addr del 10.10.11.10/24 dev $DUMMY || true"
+ ]
}
]
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next v11 3/4] net/sched: pie: correct tc_pie_xstats field documentation
2026-12-04 19:01 [PATCH net-next v11 0/4] net/sched: sch_fq_pie: add per-flow class statistics Hemendra M. Naik
2026-12-04 19:01 ` [PATCH net-next v11 1/4] net/sched: sch_fq_pie: add per-flow statistics via class ops Hemendra M. Naik
2026-12-04 19:01 ` [PATCH net-next v11 2/4] selftests: tc-testing: add fq_pie per-flow class stats test Hemendra M. Naik
@ 2026-12-04 19:01 ` Hemendra M. Naik
2026-12-04 19:01 ` [PATCH net-next v11 4/4] Documentation/netlink/specs: tc: describe fq_pie per-flow class stats Hemendra M. Naik
3 siblings, 0 replies; 8+ messages in thread
From: Hemendra M. Naik @ 2026-12-04 19:01 UTC (permalink / raw)
To: netdev
Cc: davem, edumazet, kuba, pabeni, horms, jiri, jhs, shuah,
donald.hunter, ast, toke, liuhangbin, j.koeppeler, linux-kernel,
linux-kselftest, vishy0777, tahiliani, Hemendra M. Naik
The comments describing struct tc_pie_xstats do not match the values
exported by the kernel.
Update the delay field comment to microseconds (PSCHED_TICKS2NS() /
NSEC_PER_USEC). Update avg_dq_rate to bytes/second (avg_dq_rate *
PSCHED_TICKS_PER_SEC >> PIE_SCALE).
Documentation-only; no UAPI layout or runtime change. Touch
include/uapi/linux/pkt_sched.h only
Signed-off-by: Hemendra M. Naik <hemendranaik@gmail.com>
Signed-off-by: Vishal Kamath <vishy0777@gmail.com>
Signed-off-by: Mohit P. Tahiliani <tahiliani@nitk.edu.in>
---
include/uapi/linux/pkt_sched.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h
index fef848eaaab2..445a041cd103 100644
--- a/include/uapi/linux/pkt_sched.h
+++ b/include/uapi/linux/pkt_sched.h
@@ -920,9 +920,9 @@ enum {
struct tc_pie_xstats {
__u64 prob; /* current probability */
- __u32 delay; /* current delay in ms */
+ __u32 delay; /* current delay in microseconds */
__u32 avg_dq_rate; /* current average dq_rate in
- * bits/pie_time
+ * bytes/second
*/
__u32 dq_rate_estimating; /* is avg_dq_rate being calculated? */
__u32 packets_in; /* total number of packets enqueued */
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH net-next v11 4/4] Documentation/netlink/specs: tc: describe fq_pie per-flow class stats
2026-12-04 19:01 [PATCH net-next v11 0/4] net/sched: sch_fq_pie: add per-flow class statistics Hemendra M. Naik
` (2 preceding siblings ...)
2026-12-04 19:01 ` [PATCH net-next v11 3/4] net/sched: pie: correct tc_pie_xstats field documentation Hemendra M. Naik
@ 2026-12-04 19:01 ` Hemendra M. Naik
2026-12-05 19:17 ` netdev-bot+sashiko
3 siblings, 1 reply; 8+ messages in thread
From: Hemendra M. Naik @ 2026-12-04 19:01 UTC (permalink / raw)
To: netdev
Cc: davem, edumazet, kuba, pabeni, horms, jiri, jhs, shuah,
donald.hunter, ast, toke, liuhangbin, j.koeppeler, linux-kernel,
linux-kselftest, vishy0777, tahiliani, Hemendra M. Naik
Add the tc-fq-pie-cl-stats header for fq_pie per flow (class) stats in
Documentation/netlink/specs/tc.yaml with its five fields:
- prob
- delay
- deficit
- avg-dq-rate
- dq-rate-estimating
Extend the tc-fq-pie-xstats fixed header with the type discriminator
and the per-flow class_stats fields that follow the nine legacy
__u32 qdisc counters in struct tc_fq_pie_xstats.
Update the tc-pie-xstats delay, avg_dq_rate member comments to show
units as microseconds, bytes/second respectively.
Signed-off-by: Hemendra M. Naik <hemendranaik@gmail.com>
Signed-off-by: Vishal Kamath <vishy0777@gmail.com>
Signed-off-by: Mohit P. Tahiliani <tahiliani@nitk.edu.in>
---
Documentation/netlink/specs/tc.yaml | 56 +++++++++++++++++++++++------
1 file changed, 45 insertions(+), 11 deletions(-)
diff --git a/Documentation/netlink/specs/tc.yaml b/Documentation/netlink/specs/tc.yaml
index b6ccc645b0e3..ff71042e31c1 100644
--- a/Documentation/netlink/specs/tc.yaml
+++ b/Documentation/netlink/specs/tc.yaml
@@ -894,6 +894,31 @@ definitions:
name: memory-limit
type: u32
doc: Memory limit in bytes
+ -
+ name: tc-fq-pie-cl-stats
+ type: struct
+ members:
+ -
+ name: prob
+ type: u64
+ doc: Current drop probability of the flow, scaled as an unsigned
+ 64-bit fixed-point fraction over [0, U64_MAX] (class dumps only)
+ -
+ name: delay
+ type: u32
+ doc: Current queue delay of the flow in microseconds (class dumps only)
+ -
+ name: deficit
+ type: s32
+ doc: Number of remaining byte credits (class dumps only)
+ -
+ name: avg-dq-rate
+ type: u32
+ doc: Current average dq_rate in bytes/second (class dumps only)
+ -
+ name: dq-rate-estimating
+ type: u32
+ doc: Is avg-dq-rate being calculated? (class dumps only)
-
name: tc-fq-pie-xstats
type: struct
@@ -901,39 +926,48 @@ definitions:
-
name: packets-in
type: u32
- doc: Total number of packets enqueued
+ doc: Total number of packets enqueued (qdisc dumps only)
-
name: dropped
type: u32
- doc: Packets dropped due to fq_pie_action
+ doc: Packets dropped due to fq_pie_action (qdisc dumps only)
-
name: overlimit
type: u32
- doc: Dropped due to lack of space in queue
+ doc: Dropped due to lack of space in queue (qdisc dumps only)
-
name: overmemory
type: u32
- doc: Dropped due to lack of memory in queue
+ doc: Dropped due to lack of memory in queue (qdisc dumps only)
-
name: ecn-mark
type: u32
- doc: Packets marked with ECN
+ doc: Packets marked with ECN (qdisc dumps only)
-
name: new-flow-count
type: u32
- doc: Count of new flows created by packets
+ doc: Count of new flows created by packets (qdisc dumps only)
-
name: new-flows-len
type: u32
- doc: Count of flows in new list
+ doc: Count of flows in new list (qdisc dumps only)
-
name: old-flows-len
type: u32
- doc: Count of flows in old list
+ doc: Count of flows in old list (qdisc dumps only)
-
name: memory-usage
type: u32
- doc: Total memory across all queues
+ doc: Total memory across all queues (qdisc dumps only)
+ -
+ name: type
+ type: u32
+ doc: TCA_FQ_PIE_XSTATS_QDISC (0) or TCA_FQ_PIE_XSTATS_CLASS (1)
+ -
+ name: class-stats
+ type: binary
+ struct: tc-fq-pie-cl-stats
+ doc: Class statistics of a particular flow (invoked via tc class show)
-
name: tc-fq-qd-stats
type: struct
@@ -1032,11 +1066,11 @@ definitions:
-
name: delay
type: u32
- doc: Current delay in ms
+ doc: Current delay in microseconds
-
name: avg-dq-rate
type: u32
- doc: Current average dq rate in bits/pie-time
+ doc: Current average dq rate in bytes/second
-
name: dq-rate-estimating
type: u32
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v11 1/4] net/sched: sch_fq_pie: add per-flow statistics via class ops
2026-12-04 19:01 ` [PATCH net-next v11 1/4] net/sched: sch_fq_pie: add per-flow statistics via class ops Hemendra M. Naik
@ 2026-12-05 19:17 ` netdev-bot+sashiko
0 siblings, 0 replies; 8+ messages in thread
From: netdev-bot+sashiko @ 2026-12-05 19:17 UTC (permalink / raw)
To: hemendranaik
Cc: netdev, davem, edumazet, kuba, pabeni, horms, jiri, jhs, shuah,
donald.hunter, ast, toke, liuhangbin, j.koeppeler, linux-kernel,
linux-kselftest, vishy0777, tahiliani
Thank you for your contribution! Sashiko AI review found 6 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 4
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] net/sched: sch_fq_pie: unclamped flow->vars.prob shift wraps
on congestion
- [Medium] net/sched: fq_pie: 32-bit avg_dq_rate truncation in
fq_pie_dump_class_stats()
- [Low] The WRITE_ONCE() annotations added for the new lockless class-
stats reader do not match what that reader reads, and the commit…
- [Low] The patch grows the UAPI `struct tc_fq_pie_xstats` from 36 to 64
bytes.
- [Low] Setting `.cl_ops = &fq_pie_class_ops` in `fq_pie_qdisc_ops` makes
fq_pie classful as far as the tc core is concerned.
- [Low] When `flows_cnt` is 65536, the last flow is reported as class
X:0, the same handle as the fq_pie qdisc itself.
--
net/sched: sch_fq_pie: add per-flow statistics via class ops
This patch adds class ops to fq_pie so that tc -s class show reports
per-flow PIE state (prob, delay, deficit, avg_dq_rate). It extends struct
tc_fq_pie_xstats with a type discriminator and a per-class stats struct,
which grows it from 36 to 64 bytes. It also converts several per-flow
field updates to WRITE_ONCE().
> diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h
> index 490efd2885267..fef848eaaab23 100644
> --- a/include/uapi/linux/pkt_sched.h
> +++ b/include/uapi/linux/pkt_sched.h
[ ... ]
> @@ -963,6 +978,8 @@ struct tc_fq_pie_xstats {
> __u32 new_flows_len; /* count of flows in new list */
> __u32 old_flows_len; /* count of flows in old list */
> __u32 memory_usage; /* total memory across all queues */
> + __u32 type;
> + struct tc_fq_pie_cl_stats class_stats;
> };
[Severity: Low]
Is this the uAPI layout we want to keep for good? Two mutually exclusive
payloads share one flat struct, and the type discriminator comes after
the nine legacy counters.
With this layout, fq_pie_dump_stats() always sends 28 bytes of zeroed
class_stats at qdisc level. fq_pie_dump_class_stats() sends 64 bytes, and
the first 36 of them (the qdisc counters) are always zero.
Userspace built against the 36-byte struct never reads type. Before this
patch fq_pie had no cl_ops, so tc -s class show printed nothing for it.
With this patch, an older iproute2 would probably decode each per-flow
TCA_STATS_APP with its qdisc print_xstats handler. It would then print
all-zero pkts_in, dropped, overlimit and similar counters that look like
real values. I inferred the iproute2 behaviour and did not check it here.
Could the commit message explain this compatibility trade-off? It would
also help to say how the companion iproute2 change handles 36-byte
payloads from older kernels.
Separately, the new type member has no doc comment, unlike the fields
around it.
> diff --git a/net/sched/sch_fq_pie.c b/net/sched/sch_fq_pie.c
> index a5e2a83efb679..b9ada9ded8213 100644
> --- a/net/sched/sch_fq_pie.c
> +++ b/net/sched/sch_fq_pie.c
> @@ -190,17 +190,17 @@ static int fq_pie_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch,
[ ... ]
> out:
> q->stats.dropped++;
> - sel_flow->vars.accu_prob = 0;
> + WRITE_ONCE(sel_flow->vars.accu_prob, 0);
> qdisc_drop_reason(skb, sch, to_free, reason);
> return NET_XMIT_CN;
> }
[Severity: Low]
Which lockless reader of accu_prob does this WRITE_ONCE() pair with?
tc_fill_tclass() passes a NULL lock, so fq_pie_dump_class_stats() runs
without the qdisc lock. It never reads accu_prob, though, and struct
tc_fq_pie_cl_stats does not export it.
The main writers of accu_prob still use plain stores:
net/sched/sch_pie.c:pie_drop_early() {
...
if (local_prob == 0)
vars->accu_prob = 0;
else
vars->accu_prob += local_prob;
...
}
pie_qdisc_enqueue() and pie_vars_init() also use plain stores.
The commit message says:
Used WRITE_ONCE() macro to guard following variables:
- deficit
- qlen
- backlog
- vars.accu_prob
Would it be more accurate to drop vars.accu_prob from that list, along
with this annotation?
The class dump does read vars.prob, vars.qdelay and vars.avg_dq_rate with
READ_ONCE() and without the qdisc lock. Those reads depend on WRITE_ONCE()
annotations that already exist in sch_pie.c and pie.h. Should the message
mention them instead?
Also, fq_pie_reset() still writes backlog with a plain store, although
the new dump reads it with READ_ONCE():
net/sched/sch_fq_pie.c:fq_pie_reset() {
...
flow->head = NULL;
flow->backlog = 0;
...
}
Both paths seem to run under RTNL, so this looks like an inconsistency
rather than a real race.
[ ... ]
> @@ -565,7 +569,89 @@ static void fq_pie_destroy(struct Qdisc *sch)
> kvfree(q->flows);
> }
>
[ ... ]
> +static int fq_pie_dump_class(struct Qdisc *sch, unsigned long cl,
> + struct sk_buff *skb, struct tcmsg *tcm)
> +{
> + tcm->tcm_handle |= TC_H_MIN(cl);
> + return 0;
> +}
[Severity: Low]
What happens here when flows_cnt is 65536? fq_pie_change() accepts that
value:
if (!q->flows_cnt || q->flows_cnt > 65536) {
fq_pie_walk() then passes cl = i + 1:
if (!tc_qdisc_stats_dump(sch, i + 1, arg))
For the last flow that gives cl = 65536. TC_H_MIN(65536) is 0, so
tcm_handle stays equal to the qdisc handle.
fq_pie_dump_class_stats() still treats cl = 65536 as valid, since idx
65535 < flows_cnt, and emits real per-flow stats. Userspace would see an
active flow class with classid X:0, the same handle as the fq_pie qdisc,
and could not map it to that flow.
fq_codel_walk() has the same pattern, but this behaviour is new for
fq_pie.
[ ... ]
> static struct Qdisc_ops fq_pie_qdisc_ops __read_mostly = {
> + .cl_ops = &fq_pie_class_ops,
> .id = "fq_pie",
[Severity: Low]
Setting cl_ops makes the tc core treat fq_pie as classful. Should the
commit message mention the user-visible error changes that follow? It
currently says only that the filter callbacks are omitted.
Before this patch, tc filter add ... parent <fq_pie handle>: failed in
__tcf_qdisc_find() with -EINVAL "Qdisc not classful". It now gets one
check further:
net/sched/cls_api.c:__tcf_qdisc_find() {
...
if (!cops->tcf_block) {
NL_SET_ERR_MSG(extack, "Class doesn't support blocks");
err = -EOPNOTSUPP;
goto errout_qdisc;
}
...
}
RTM_NEWTCLASS, RTM_DELTCLASS and RTM_GETTCLASS used to return -EINVAL in
__tc_ctl_tclass() when cops == NULL. They now reach fq_pie_find(), which
always returns 0, so they return -ENOENT.
Grafting a qdisc under an fq_pie class used to fail with -EOPNOTSUPP
"Parent qdisc is not classful". It now fails with -ENOENT "Specified
class not found".
So classes that tc class show lists (for example 2:5) cannot be looked
up with tc class get. fq_codel behaves the same way, but scripts that
match on these errors may see the difference.
[ ... ]
> @@ -563,7 +567,89 @@ static void fq_pie_destroy(struct Qdisc *sch)
> kvfree(q->flows);
> }
>
> +static struct Qdisc *fq_pie_leaf(struct Qdisc *sch, unsigned long arg)
> +{
> + return NULL;
> +}
> +
> +static unsigned long fq_pie_find(struct Qdisc *sch, u32 classid)
> +{
> + return 0;
> +}
> +
> +static int fq_pie_dump_class(struct Qdisc *sch, unsigned long cl,
> + struct sk_buff *skb, struct tcmsg *tcm)
> +{
> + tcm->tcm_handle |= TC_H_MIN(cl);
> + return 0;
> +}
> +
> +static int fq_pie_dump_class_stats(struct Qdisc *sch, unsigned long cl,
> + struct gnet_dump *d)
> +{
> + struct fq_pie_sched_data *q = qdisc_priv(sch);
> + struct gnet_stats_queue qs = { 0 };
> + struct tc_fq_pie_xstats xstats;
> + u32 idx = cl - 1;
> +
> + if (idx < q->flows_cnt) {
> + const struct fq_pie_flow *flow = &q->flows[idx];
> +
> + memset(&xstats, 0, sizeof(xstats));
> + xstats.type = TCA_FQ_PIE_XSTATS_CLASS;
> + xstats.class_stats.prob =
> + READ_ONCE(flow->vars.prob) << BITS_PER_BYTE;
> + xstats.class_stats.delay =
> + div_u64(PSCHED_TICKS2NS(READ_ONCE(flow->vars.qdelay)),
> + NSEC_PER_USEC);
> + xstats.class_stats.deficit = READ_ONCE(flow->deficit);
> + xstats.class_stats.dq_rate_estimating =
> + READ_ONCE(q->p_params.dq_rate_estimator);
> +
> + if (xstats.class_stats.dq_rate_estimating) {
> + xstats.class_stats.avg_dq_rate =
[Severity: Medium]
Can the converted rate exceed U32_MAX here? The product is computed
in u64, but it is stored into the __u32 avg_dq_rate field of struct
tc_fq_pie_cl_stats without any clamping, so the upper 32 bits are
silently dropped.
flow->vars.avg_dq_rate is in bytes per psched tick, scaled by
PIE_SCALE. With PSCHED_TICKS_PER_SEC at 15625000, an avg_dq_rate of
70369 or more converts to more than U32_MAX bytes/second. That is
about 4.3 GB/s, or roughly 34 Gbit/s, for a single flow.
pie_process_dequeue() reaches it whenever QUEUE_THRESHOLD (16384
bytes) drains in 59 ticks or fewer, about 3.8 us. For example, 71089
converts to 4338928222 bytes/second, which wraps to 43960926.
One flow at that rate is realistic on 40G and faster NICs, over veth
or on loopback, especially with GSO. With dq_rate_estimator enabled,
tc -s class show would then report a wrapped rate that is far too low.
struct tc_fq_pie_cl_stats is new uAPI and its layout cannot change
once released. Should avg_dq_rate be a __u64? Placing it next to prob,
with an explicit pad member at the end, would keep the struct free of
implicit holes. If __u32 is kept for consistency with tc_pie_xstats,
could the value at least saturate with min_t(u64, ..., U32_MAX), with
the limit documented next to the field? Either way, the tc.yaml spec
update later in this series would need to match.
> + ((u64)READ_ONCE(flow->vars.avg_dq_rate)
> + * PSCHED_TICKS_PER_SEC) >> PIE_SCALE;
> + }
> +
> + qs.qlen = READ_ONCE(flow->qlen);
> + qs.backlog = READ_ONCE(flow->backlog);
> + }
> + if (gnet_stats_copy_queue(d, NULL, &qs, qs.qlen) < 0)
> + return -1;
> + if (idx < q->flows_cnt)
> + return gnet_stats_copy_app(d, &xstats, sizeof(xstats));
> + return 0;
> +}
> +
> +static void fq_pie_walk(struct Qdisc *sch, struct qdisc_walker *arg)
> +{
> + struct fq_pie_sched_data *q = qdisc_priv(sch);
> + unsigned int i;
> +
> + if (arg->stop)
> + return;
> +
> + for (i = 0; i < q->flows_cnt; i++) {
> + if (list_empty(&q->flows[i].flowchain)) {
> + arg->count++;
> + continue;
> + }
> + if (!tc_qdisc_stats_dump(sch, i + 1, arg))
> + break;
> + }
> +}
> +
> +static const struct Qdisc_class_ops fq_pie_class_ops = {
> + .leaf = fq_pie_leaf,
> + .find = fq_pie_find,
> + .dump = fq_pie_dump_class,
> + .dump_stats = fq_pie_dump_class_stats,
> + .walk = fq_pie_walk,
> +};
> +
> static struct Qdisc_ops fq_pie_qdisc_ops __read_mostly = {
> + .cl_ops = &fq_pie_class_ops,
> .id = "fq_pie",
> .priv_size = sizeof(struct fq_pie_sched_data),
> .enqueue = fq_pie_qdisc_enqueue,
[Severity: Medium]
Can flow->vars.prob be larger than MAX_PROB at this point? MAX_PROB
is U64_MAX >> 8, and the shift by BITS_PER_BYTE assumes the top byte
of prob is always zero.
pie_calculate_probability() only clamps when the u64 addition wraps
around completely:
net/sched/sch_pie.c:pie_calculate_probability() {
...
WRITE_ONCE(vars->prob, vars->prob + delta);
if (delta > 0) {
/* prevent overflow */
if (vars->prob < oldprob) {
WRITE_ONCE(vars->prob, MAX_PROB);
...
}
Under sustained congestion, with qdelay well above target, the
positive delta steps can carry prob past MAX_PROB into the range
(MAX_PROB, U64_MAX] without wrapping, so the check above never fires.
Nothing in sch_pie.c or sch_fq_pie.c caps it there, and
pie_drop_early() then drops essentially every packet of the flow.
fq_pie_dump_class_stats() shifts that non-zero top byte out. A
prob of 0x0100000000000000, for example, is reported as 0. A flow that
is losing nearly all of its packets could therefore appear in tc -s
class show with a drop probability close to 0%, or with some other
arbitrary value.
Would clamping with min_t(u64, READ_ONCE(flow->vars.prob), MAX_PROB)
before the shift be enough here? Or should pie_calculate_probability()
cap prob at MAX_PROB itself? That would also cover pie_dump_stats() in
sch_pie.c, which appears to use the same shift. However, it changes how
quickly prob decays once congestion ends, so it may be better as a
separate fix.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204190143.633361-1-hemendranaik%40gmail.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v11 2/4] selftests: tc-testing: add fq_pie per-flow class stats test
2026-12-04 19:01 ` [PATCH net-next v11 2/4] selftests: tc-testing: add fq_pie per-flow class stats test Hemendra M. Naik
@ 2026-12-05 19:17 ` netdev-bot+sashiko
0 siblings, 0 replies; 8+ messages in thread
From: netdev-bot+sashiko @ 2026-12-05 19:17 UTC (permalink / raw)
To: hemendranaik
Cc: netdev, davem, edumazet, kuba, pabeni, horms, jiri, jhs, shuah,
donald.hunter, ast, toke, liuhangbin, j.koeppeler, linux-kernel,
linux-kselftest, vishy0777, tahiliani
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The new test 83c0 in tools/testing/selftests/tc-testing/tc-
tests/qdiscs/fq_pie.json fails on any system with a released iproute2.
--
selftests: tc-testing: add fq_pie per-flow class stats test
This adds tc-testing case 83c0 to fq_pie.json. The test builds a TBF +
fq_pie hierarchy on $DUMMY and sends ping traffic through it. It then
checks the tc -s class show output for an fq_pie class.
> diff --git a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/fq_pie.json b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/fq_pie.json
> index 229fe1bf4a906..15b2667285eb4 100644
> --- a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/fq_pie.json
> +++ b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/fq_pie.json
> @@ -40,5 +40,32 @@
[ ... ]
> + {
> + "id": "83c0",
> + "name": "FQ-PIE class stats accessible via tc class show",
[ ... ]
> + "cmdUnderTest": "$TC -s class show dev $DUMMY",
> + "expExitCode": "0",
> + "verifyCmd": "$TC -s class show dev $DUMMY",
> + "matchPattern": "class fq_pie 2:[0-9]+ .*prob .*delay .*deficit",
> + "matchCount": "1",
[Severity: Medium]
On a system with a released iproute2, will this test fail instead of
skipping?
The matchPattern needs the labels prob, delay and deficit in the tc -s
class show output. On the kernel side, fq_pie_dump_class_stats() in
net/sched/sch_fq_pie.c only sends a binary tc_fq_pie_xstats blob. That
blob uses the new type/class_stats layout:
xstats.type = TCA_FQ_PIE_XSTATS_CLASS;
xstats.class_stats.prob = READ_ONCE(flow->vars.prob) << BITS_PER_BYTE;
Released tc only knows the qdisc xstats layout (pkts_in, overlimit,
dropped, ecn_mark, new_flow_count and so on). Those words do not appear
in the tbf class line or in the generic stats lines either.
So the regex finds 0 matches, and run_one_test() in tdc.py marks the test
as failed:
if len(match_index) != int(tidx["matchCount"]):
res.set_result(ResultState.fail)
Later patches in the series don't touch tools/testing/selftests/tc-testing/.
The test will keep failing until the iproute2 change ships and is
installed.
tdc already supports a dependsOn probe: if the probe exits non-zero, the
test is marked SKIP. mirred.json, tunnel_key.json and taprio.json already
use it. Could 83c0 add a dependsOn probe that checks for the new iproute2
support?
The commit message also describes a weaker check than the one the test
does:
... and verify that 'tc -s class show' reports
an fq_pie class.
The per-flow counters themselves (prob, delay, deficit) are printed with
the companion iproute2 change, ...
The regex requires those counters. That gives the test a hard dependency
on the unmerged iproute2 change "tc: fq_pie: add support for printing
per-flow PIE statistics".
Should the pattern match only the class line, for example
"class fq_pie 2:[0-9]+ parent 2:"? If the counter check stays, should the
commit message state the dependency on the iproute2 change?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204190143.633361-1-hemendranaik%40gmail.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next v11 4/4] Documentation/netlink/specs: tc: describe fq_pie per-flow class stats
2026-12-04 19:01 ` [PATCH net-next v11 4/4] Documentation/netlink/specs: tc: describe fq_pie per-flow class stats Hemendra M. Naik
@ 2026-12-05 19:17 ` netdev-bot+sashiko
0 siblings, 0 replies; 8+ messages in thread
From: netdev-bot+sashiko @ 2026-12-05 19:17 UTC (permalink / raw)
To: hemendranaik
Cc: netdev, davem, edumazet, kuba, pabeni, horms, jiri, jhs, shuah,
donald.hunter, ast, toke, liuhangbin, j.koeppeler, linux-kernel,
linux-kselftest, vishy0777, tahiliani
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The spec now describes the fq_pie xstats fixed header as 64
bytes.
--
Documentation/netlink/specs: tc: describe fq_pie per-flow class stats
This commit adds a tc-fq-pie-cl-stats struct to the tc netlink spec. It
also extends the tc-fq-pie-xstats fixed header with a type discriminator
and a class-stats member, and corrects the units in the tc-pie-xstats
member docs.
> diff --git a/Documentation/netlink/specs/tc.yaml b/Documentation/netlink/specs/tc.yaml
> index b6ccc645b0e33..ff71042e31c15 100644
> --- a/Documentation/netlink/specs/tc.yaml
> +++ b/Documentation/netlink/specs/tc.yaml
[ ... ]
> @@ -901,39 +926,48 @@ definitions:
[ ... ]
> -
> name: memory-usage
> type: u32
> - doc: Total memory across all queues
> + doc: Total memory across all queues (qdisc dumps only)
> + -
> + name: type
> + type: u32
> + doc: TCA_FQ_PIE_XSTATS_QDISC (0) or TCA_FQ_PIE_XSTATS_CLASS (1)
> + -
> + name: class-stats
> + type: binary
> + struct: tc-fq-pie-cl-stats
> + doc: Class statistics of a particular flow (invoked via tc class show)
[Severity: Medium]
With these two members appended, the fq_pie fixed header described by the
spec grows from 36 bytes to 64 bytes. Kernels without the earlier change
in this series, "net/sched: sch_fq_pie: add per-flow statistics via class
ops", still send the 36-byte struct tc_fq_pie_xstats (nine __u32
counters) from fq_pie_dump_stats():
gnet_stats_copy_app(d, &st, sizeof(st));
Can the in-tree YNL decoder handle that shorter payload?
The fq_pie entry in tca-stats-app-msg maps to fixed-header
tc-fq-pie-xstats. YnlFamily._decode_sub_msg() therefore calls
_decode_struct() on the TCA_XSTATS and TCA_STATS_APP payloads, and
_decode_struct() in tools/net/ynl/pyynl/lib/ynl.py walks every member
without checking len(data):
format_ = NlAttr.get_format(m.type, m.byte_order)
[ value ] = format_.unpack_from(data, offset)
offset += format_.size
For the new type member this becomes unpack_from(data, 36) on a 36-byte
buffer, which raises struct.error. Nothing in the decode path catches it.
As a result, something like:
cli.py --spec Documentation/netlink/specs/tc.yaml --dump getqdisc
run against an older kernel with an fq_pie qdisc configured would fail to
decode the whole message. Before this patch it decoded the nine legacy
counters correctly.
tc-fq-qd-stats seems to have the same limitation, since it lists members
that older kernels lack. This patch adds a new instance of it for fq_pie,
though.
Could _decode_struct() stop at the end of the available data, or could
the spec stay decodable for the legacy 36-byte layout in some other way?
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204190143.633361-1-hemendranaik%40gmail.com
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-12-05 19:17 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 19:01 [PATCH net-next v11 0/4] net/sched: sch_fq_pie: add per-flow class statistics Hemendra M. Naik
2026-12-04 19:01 ` [PATCH net-next v11 1/4] net/sched: sch_fq_pie: add per-flow statistics via class ops Hemendra M. Naik
2026-12-05 19:17 ` netdev-bot+sashiko
2026-12-04 19:01 ` [PATCH net-next v11 2/4] selftests: tc-testing: add fq_pie per-flow class stats test Hemendra M. Naik
2026-12-05 19:17 ` netdev-bot+sashiko
2026-12-04 19:01 ` [PATCH net-next v11 3/4] net/sched: pie: correct tc_pie_xstats field documentation Hemendra M. Naik
2026-12-04 19:01 ` [PATCH net-next v11 4/4] Documentation/netlink/specs: tc: describe fq_pie per-flow class stats Hemendra M. Naik
2026-12-05 19:17 ` netdev-bot+sashiko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox