Skip to content

net/sched: sch_cake: fixes for accounting and reconfiguration

Jamal Hadi Salim netdev 3 versions – Applied

Status from this message: This series was applied to netdev/net-next.git (main)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest4 patches 2 repliesApplied 4/4
  2. v24 patches 6 repliesSuperseded
  3. v14 patches 6 repliesSuperseded

Changes in v3 from the cover letter

- Patch 1/4: reuse the rate snapshot in cake_dequeue() and cake_reconfigure() instead of a second READ_ONCE() per use, order the declarations longest-first (Björn Töpel), and scope the annotation
claim: READ_ONCE()/WRITE_ONCE() do not make a 64-bit access single-copy atomic on 32-bit, so the lockless cake_config_dump() and cake_mq readers remain best-effort (Sashiko nipa).
- Patch 2/4: no change; carries Toke's v1 Acked-by.
- Patch 3/4: publish buffer_max_used as u64_stats_t under the qdisc lock and snapshot it with u64_stats_fetch_begin()/retry(), so the lockless stat read is coherent on 32-bit (Sashiko gemini + nipa).
- Patch 4/4: no change; carries its Reviewed-by and Acked-by tags.

Patches in v3 All 4 applied

#Subject and filesSizeRepliesApplied
1/4net/sched/sch_cake: serialize reconfiguration with the datapathnet/sched/sch_cake.c+21 -111 replyApplied
2/4net/sched/sch_cake: reduce parent backlog when clearing a tinnet/sched/sch_cake.c+7 -00 repliesApplied
3/4net/sched/sch_cake: widen buffer_used to u64net/sched/sch_cake.c+21 -61 replyApplied
4/4net/sched/sch_cake: drop dead nla_nest_end() error checknet/sched/sch_cake.c+1 -20 repliesApplied

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by.

PatchVictor NogueiraToke Høiland-Jørgensen
1/4R-b A-b
2/4R-b A-b
3/4R-b A-b
4/4R-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH net-next v3 0/4] net/sched: sch_cake: fixes for accounting and reconfiguration

Four independent fixes in the CAKE qdisc. Three are follow-ups to the autorate reconfiguration work around commit 7cbfb180945c ("net/sched:
sch_cake: fix autorate reconfiguration throttling") and the 32-bit admission-counter wraps fixed in gred/bfifo/plug by commit 4c660ee8c809 ("net: sched: fix 32-bit backlog wrap in gred, bfifo and plug enqueue"); the fourth is a dead-code cleanup found while auditing the dump path.

Patch 1 serializes a 'tc qdisc change' with the datapath's autorate update under the qdisc lock, so the netlink writer and the autorate writer can no longer lose the configured rate. rate_bps needs no atomic (it is only loaded and stored), so it stays a plain u64 with READ_ONCE()/WRITE_ONCE() annotations.

Patch 2 propagates the backlog reduction of the reconfigure-time tin purge to classful parents, so a CAKE leaf under HTB no longer leaves the purged packets in the parent's qlen/backlog forever.

Patch 3 widens buffer_used and buffer_max_used to u64. The u32 accumulator wraps once the resident truesize passes 2^32, bypassing the over-limit drop loop while the configured limit is a u32 attribute; the u32 MEMORY_USED export is clamped so widening the counter does not truncate the reported value.

Patch 4 drops an unreachable 'nla_nest_end() < 0' error check: the helper never returns a negative value.

All four are hardening for net-next (no Fixes:, no Cc: stable): the counter wrap, the missing parent-backlog propagation and the reconfiguration race all predate any contract we could anchor a regression on. Patches 1-2 were reported by Sashiko (gemini) and patch 3 comes from the gred 32-bit-wrap family; patch 4 is a static cleanup.

v2 -> v3:
- Patch 1/4: reuse the rate snapshot in cake_dequeue() and cake_reconfigure() instead of a second READ_ONCE() per use, order the declarations longest-first (Björn Töpel), and scope the annotation
claim: READ_ONCE()/WRITE_ONCE() do not make a 64-bit access single-copy atomic on 32-bit, so the lockless cake_config_dump() and cake_mq readers remain best-effort (Sashiko nipa).
- Patch 2/4: no change; carries Toke's v1 Acked-by.
- Patch 3/4: publish buffer_max_used as u64_stats_t under the qdisc lock and snapshot it with u64_stats_fetch_begin()/retry(), so the lockless stat read is coherent on 32-bit (Sashiko gemini + nipa).
- Patch 4/4: no change; carries its Reviewed-by and Acked-by tags.

v1 -> v2:
- Patch 1/4: drop atomic64_t; rate_bps stays a plain u64 with READ_ONCE()/WRITE_ONCE() annotations (per Toke's review: the accesses are plain loads/stores, so no atomic is needed).
- Patch 2/4: no change; carries Toke's v1 Acked-by.
- Patch 3/4: clamp the MEMORY_USED export to U32_MAX, so widening the counter does not truncate the u32 stat (Sashiko nipa Medium).
- Patch 4/4: no change; carries Toke's v1 Acked-by.

Jamal Hadi Salim (4):
net/sched: sch_cake: serialize reconfiguration with the datapath net/sched: sch_cake: reduce parent backlog when clearing a tin net/sched: sch_cake: widen buffer_used to u64 net/sched: sch_cake: drop dead nla_nest_end() error check

 net/sched/sch_cake.c | 69 ++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 50 insertions(+), 19 deletions(-)
Signature · 1 line
2.43.0