Re: [PATCH v2] net/sched: sch_cake: skip redundant cake_mq rate updates

From: Toke Høiland-Jørgensen

Date: Tue Oct 27 2026 - 05:57:03 EST


"Shubhang Kaushik (Ampere)" <sh@xxxxxxxxxx> writes:

> cake_mq periodically counts active child qdiscs in cake_dequeue() and
> derives an effective per-child shaper rate. cake_dequeue() currently
> reconfigures every tin after each scan, even when that effective rate
> is unchanged.
>
> The dequeue-time call chain is:
>
> cake_dequeue()
> -> cake_configure_rates(..., true)
> -> cake_config_*()
> -> cake_set_rate()
>
> With rate_adjust=true, cake_set_rate() only refreshes rate-derived
> state. Tin 0 records the unscaled rate argument in every supported
> CAKE tin mode, so its installed rate identifies whether this call chain
> would change any state.
>
> Skip the reconfiguration when the effective rate is already installed,
> while continuing to update the activity-sampling timestamp and
> active-queue statistic.
>
> Fixes: 1bddd758bac2 ("net/sched: sch_cake: share shaper state across sub-instances of cake_mq")
> Signed-off-by: Shubhang Kaushik (Ampere) <sh@xxxxxxxxxx>
> ---
> Tested on an 80-core SMP, non-SMT Ampere Altra system (aarch64)
> The test used a 32-TX-queue veth pair, with cake_mq
> bandwidth 2gbit on the transmit side and the peer in a network
> namespace. The workload was:
>
> iperf3 -c 198.18.0.2 -P 32 -t 30
>
> Validation against mainline commit a32e63a613aa80, the patched kernel
> reduced cake_configure_rates() calls by 99.99% (2,477,627 to 206) and
> aggregate helper time by 99.986% (3.477 s to 0.498 ms), while retaining
> approximately 1.91 Gbit/s aggregate throughput (baseline:
> 1.91-1.92 Gbit/s). A separate per-child trace observed no
> same-effective-rate calls on the patched kernel (@unchanged: 0).
> Changing cake_mq bandwidth from 2Gbit to 1Gbit and back invoked
> cake_configure_rates() 64 times, matching all 32 child CAKE qdiscs
> updated for each of the two control-plane changes.
>
> Changes in v2:
> - Drop READ_ONCE() as suggested by Jonas Köppeler.
>
> Link to v1: https://lore.kernel.org/r/20261025-net_sched_sch_cake-v1-1-5165c924a590@xxxxxxxxxx

Acked-by: Toke Høiland-Jørgensen <toke@xxxxxxx>