net/sched: sch_fq_pie: add per-flow class statistics
Subsystems (4)
v3 cover net/sched: sch_fq_pie: add per-flow class statistics
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.
---
Changelog:
v3:
- No changes since v2.
- Resending as the previous submission was deferred when the net-next tree closed during review.
- Corresponding iproute2 patch updated in response to review comments; no changes required for this patch.
v2:
- Addressed ABI backward compatibility issue for tc_fq_pie_xstats. (https://lore.kernel.org/netdev/[email protected]/)
v1:
- https://lore.kernel.org/netdev/[email protected]/
Hemendra M. Naik (2):
net/sched: sch_fq_pie: add per-flow statistics via class ops
selftests: tc-testing: add fq_pie per-flow class stats test
include/uapi/linux/pkt_sched.h | 29 ++++- net/sched/sch_fq_pie.c | 118 +++++++++++++++++- tools/include/uapi/linux/pkt_sched.h | 4 +- .../tc-testing/tc-tests/qdiscs/fq_pie.json | 22 ++++ 4 files changed, 163 insertions(+), 10 deletions(-)
Signature · 1 line
2.34.1
PATCH v3 1/2 net/sched: sch_fq_pie: add per-flow statistics via class ops
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 to support both qdisc and class-level extended statistics.
- Add enum with QDISC and CLASS type discriminators.
- Add struct tc_fq_pie_cl_stats for per-flow metrics (prob, delay, deficit, avg_dq_rate, dq_rate_estimating).
- Add empty struct tc_fq_pie_xqd_stats placeholder.
Wire up fq_pie_class_ops (.walk, .dump, .dump_stats) so that 'tc -s class show' against an fq_pie qdisc reports per-flow state:
prob per-flow PIE drop probability
delay per-flow queue sojourn time (microseconds)
deficit remaining DRR byte credits (signed integer)
avg_dq_rate dequeue rate estimate in bytes/second
(dq_rate_estimator mode only)
dq_rate_estimating flag indicating active delay estimation mode
Fix the 'delay' field comment in struct tc_pie_xstats from "in ms" to "in microseconds" to match the kernel's
PSCHED_TICKS2NS / NSEC_PER_USEC conversion.
Also correct the avg_dq_rate comment in tc_pie_xstats from "bits/pie_time" to "bytes/second" to match the actual kernel conversion (avg_dq_rate * PSCHED_TICKS_PER_SEC >> PIE_SCALE).
---
Changelog:
v3:
- No changes since v2.
- Resending as the previous submission was deferred when the net-next tree closed during review.
- Corresponding iproute2 patch updated in response to review comments; no changes required for this patch.
v2:
- Addressed ABI backward compatibility issue for tc_fq_pie_xstats. (https://lore.kernel.org/netdev/[email protected]/)
v1:
- https://lore.kernel.org/netdev/[email protected]
--- include/uapi/linux/pkt_sched.h | 29 ++++++- net/sched/sch_fq_pie.c | 118 +++++++++++++++++++++++++-- tools/include/uapi/linux/pkt_sched.h | 4 +- 3 files changed, 141 insertions(+), 10 deletions(-)
include/uapi/linux/pkt_sched.h +27 -2
@@ -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 */
@@ -953,6 +953,25 @@ 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_xqd_stats { +/* placeholder for new qdisc-level stats */ +}; +struct tc_fq_pie_xstats {__u32 packets_in;/* total number of packets enqueued */ __u32 dropped;/* packets dropped due to fq_pie_action */
@@ -963,6 +982,12 @@ 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; +union { +struct tc_fq_pie_cl_stats class_stats; +struct tc_fq_pie_xqd_stats xqdisc_stats; + }; + };/* CBS */
net/sched/sch_fq_pie.c +112 -6
143 lines not on this page · raw message
tools/include/uapi/linux/pkt_sched.h +2 -2
@@ -847,8 +847,8 @@ enum {struct tc_pie_xstats {__u32 prob;/* current probability */ -__u32 delay;/* current delay in ms */ -__u32 avg_dq_rate;/* current average dq_rate in bits/pie_time */ +__u32 delay;/* current delay in micoseconds */ +__u32 avg_dq_rate;/* current average dq_rate in bytes/second */ __u32 packets_in;/* total number of packets enqueued */ __u32 dropped;/* packets dropped due to pie_action */ __u32 overlimit;/* dropped due to lack of space in queue */
Signature · 1 line
2.34.1
Paolo Abeni
maintainerRe: [PATCH net-next v3 1/2] net/sched: sch_fq_pie: add per-flow statistics via class ops
net/sched/sch_fq_pie.c static int fq_pie_change(struct Qdisc *sch, struct nlattr *opt, · line 333
Quoted 10 lines · Hemendra M. Naik
net/sched/sch_fq_pie.c +1
-1@@ -330,7 +330,7 @@ static int fq_pie_change(struct Qdisc *sch, struct nlattr *opt,/* tupdate is in jiffies */ if (tb[TCA_FQ_PIE_TUPDATE ])WRITE_ONCE (q->p_params.tupdate, -usecs_to_jiffies (nla_get_u32 (tb[TCA_FQ_PIE_TUPDATE ]))); +usecs_to_jiffies (nla_get_u32 (tb[TCA_FQ_PIE_TUPDATE ])));
Minor nit, only if a repost is needed for other reasons: unrelated formatting changes should go in a separate patch.
net/sched/sch_fq_pie.c static int fq_pie_dump_stats(struct Qdisc *sch, struct gnet_dump *d) · line 525
Quoted 12 lines
net/sched/sch_fq_pie.c +4
-4@@ -517,10 +519,10 @@ static int fq_pie_dump_stats(struct Qdisc *sch, struct gnet_dump *d) st.packets_in = q->stats.packets_in; st.overlimit = q->stats.overlimit; st.overmemory = q->overmemory; - st.dropped = q->stats.dropped; - st.ecn_mark = q->stats.ecn_mark; - st.new_flow_count = q->new_flow_count; - st.memory_usage = q->memory_usage; + st.dropped = q->stats.dropped; + st.ecn_mark = q->stats.ecn_mark; + st.new_flow_count = q->new_flow_count; + st.memory_usage = q->memory_usage;
Same here.
@Jamal: the patch LGTM, and I think that the alignment concern raised by sashiko is not relevant:
https://sashiko.dev/#/patchset/20260630183702.170798-1-hemendranaik%40gmail.com
as user-space already has to deal with 64-bit aligned fields in tc stats.
WDYT?
Thanks,
Paolo
Jakub Kicinski
maintainerRe: [PATCH net-next v3 1/2] net/sched: sch_fq_pie: add per-flow statistics via class ops
In reply to Hemendra M. NaikQuoted 4 lines · On Wed, 1 Jul 2026 00:07:01 +0530 Hemendra M. Naik wrote:
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.
Please un-indent the commit msg.
Re: [PATCH net-next v3 1/2] net/sched: sch_fq_pie: add per-flow statistics via class ops
Hi Paolo, Jakub,
Thank you for reviewing the series and for your feedback.
We double-checked the formatting tweaks and confirmed they are not required, so we'll drop them. Any unrelated corrections will be moved to a separate commit. We'll also fix the commit message indentation.
We'll incorporate the suggested changes and submit a v4 of the kernel series, along with the corresponding iproute2 changes, shortly.
Thanks,
Hemendra
PATCH v3 2/2 selftests: tc-testing: add fq_pie per-flow class stats test
In reply to Hemendra M. NaikAdd a tc-testing entry (id: 83c0) to verify the fq_pie class ops wired up in the previous patch do not crash and integrate cleanly with the tc class show path.
The test creates an fq_pie root qdisc on a dummy interface and runs 'tc -s class show'.
---
Changelog:
v3:
- No changes since v2.
- Resending as the previous submission was deferred when the net-next tree closed during review.
- Corresponding iproute2 patch updated in response to review comments; no changes required for this patch.
v2:
- No changes since v1. (https://lore.kernel.org/netdev/[email protected]/)
v1:
- https://lore.kernel.org/netdev/[email protected]/
--- .../tc-testing/tc-tests/qdiscs/fq_pie.json | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+)
tools/testing/selftests/tc-testing/tc-tests/qdiscs/fq_pie.json +22 -0
@@ -40,5 +40,27 @@ "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": [ + "$TC qdisc add dev $DUMMY handle 1: root fq_pie" + ], + "cmdUnderTest": "$TC -s class show dev $DUMMY", + "expExitCode": "0", + "verifyCmd": "$TC -s class show dev $DUMMY", + "matchPattern": "class fq_pie", + "matchCount": "0", + "teardown": [ + "$TC qdisc del dev $DUMMY handle 1: root" + ] } ]
Signature · 1 line
2.34.1