net/sched: sch_fq_pie: add per-flow class statistics
Subsystems (4)
v7 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.
This patch series is accompanied by a companion iproute2 patch series that will be posted on net-dev mailing list as well.
Both the kernel and iproute2 patches can also be found in GitHub:
- https://github.com/H-N41K/linux-net-next/commits/fq_pie_class_stats/
- https://github.com/H-N41K/iproute2-next/tree/fq_pie_class_stats
---
Changelog:
v7:
- No code changes since v6.
- Rebased over the latest net-next tree and re-submitted patch.
v6: https://lore.kernel.org/netdev/[email protected]/
- 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/[email protected]/
- 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/[email protected]/
- Fixed unaligned commit message; moved typo fixes to another patch.
v3: https://lore.kernel.org/netdev/[email protected]/
- 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/[email protected]/
- Addressed ABI backward compatibility issue for tc_fq_pie_xstats.
v1: https://lore.kernel.org/netdev/[email protected]/
- Initial submission
Hemendra M. Naik (3):
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
include/uapi/linux/pkt_sched.h | 20 ++++- net/sched/sch_fq_pie.c | 86 ++++++++++++++++++- .../tc-testing/tc-tests/qdiscs/fq_pie.json | 27 ++++++ 3 files changed, 130 insertions(+), 3 deletions(-)
Signature · 1 line
2.34.1
PATCH v7 1/3 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 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, dq_rate_estimating). Filter attachment callbacks (.tcf_block, .bind_tcf, .unbind_tcf) are omitted on purpose.
Derive delay with div_u64() from the full 64-bit nanosecond value rather than truncating to u32 before dividing, which wrapped for sojourn times above ~4.295 s, and widen avg_dq_rate to u64 before scaling it by PSCHED_TICKS_PER_SEC.
--- include/uapi/linux/pkt_sched.h | 16 +++++++ net/sched/sch_fq_pie.c | 86 +++++++++++++++++++++++++++++++++- 2 files changed, 101 insertions(+), 1 deletion(-)
include/uapi/linux/pkt_sched.h +16 -0
@@ -953,6 +953,20 @@ 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 +977,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 */
net/sched/sch_fq_pie.c +85 -1
99 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v7 2/3 selftests: tc-testing: add fq_pie per-flow class stats test
In reply to Hemendra M. NaikAdd 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 only after the companion iproute2 change, "tc: fq_pie: add support for printing per-flow PIE statistics"
--- .../tc-testing/tc-tests/qdiscs/fq_pie.json | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+)
tools/testing/selftests/tc-testing/tc-tests/qdiscs/fq_pie.json +27 -0
@@ -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" + ] } ]
Signature · 1 line
2.34.1
PATCH v7 3/3 net/sched: pie: correct tc_pie_xstats field documentation
In reply to Hemendra M. NaikThe 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
--- include/uapi/linux/pkt_sched.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/uapi/linux/pkt_sched.h +2 -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 */
Signature · 1 line
2.34.1