* [PATCH net 0/2] net/sched: sch_cake: two shaper accounting fixes
@ 2026-12-05 15:11 Julius Bairaktaris
2026-12-05 15:12 ` [PATCH net 1/2] net/sched: sch_cake: count the arriving packet in the autorate window Julius Bairaktaris
2026-12-05 15:12 ` [PATCH net 2/2] net/sched: sch_cake: charge an SCTP GSO packet by its own segments Julius Bairaktaris
0 siblings, 2 replies; 4+ messages in thread
From: Julius Bairaktaris @ 2026-12-05 15:11 UTC (permalink / raw)
To: Toke Høiland-Jørgensen
Cc: netdev, cake, Jamal Hadi Salim, Jiri Pirko, David S . Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Willem de Bruijn,
Simon Horman
Two fixes to how CAKE counts the length of a packet.
1/2: with autorate-ingress and the ACK filter, dropping a queued ACK
that is longer than the new one wraps the window's byte count, and the
shaper is set to tens of Gbit/s.
2/2: an SCTP GSO packet (gso_size GSO_BY_FRAGS) is charged as about
65 kB per segment when CAKE does not split it at enqueue, so the other
flows lose link time to a local SCTP sender.
Sashiko's review of my net-next CAKE series pointed at the first; the
second came up while testing that series with SCTP.
Tested in QEMU (KVM, x86_64) on net e9d78fc6741a, one module per run:
- 1/2: a scapy sender on a veth, CAKE besteffort 20kbit autorate-ingress
ack-filter-aggressive. Without the fix the shaper rate ends at 61976
to 69100 Mbit/s in 5 of 6 runs; with it at 275 to 276 kbit in 6 of 6.
- 2/2: CAKE besteffort 1gbit no-split-gso on a veth, a local SCTP sender
beside iperf3 TCP, one run per SCTP message size (2000, 60000 bytes).
Without the fix TCP gets 478/459 Mbit/s and SCTP 15.7/20.7 Mbit/s; with
it TCP 621/479 and SCTP 351/536 Mbit/s, the link full.
I used Claude (Anthropic) to help write these patches.
Julius Bairaktaris (2):
net/sched: sch_cake: count the arriving packet in the autorate window
net/sched: sch_cake: charge an SCTP GSO packet by its own segments
net/sched/sch_cake.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
base-commit: e9d78fc6741ac06d438cf64e314c28e57014432a
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net 1/2] net/sched: sch_cake: count the arriving packet in the autorate window
2026-12-05 15:11 [PATCH net 0/2] net/sched: sch_cake: two shaper accounting fixes Julius Bairaktaris
@ 2026-12-05 15:12 ` Julius Bairaktaris
2026-12-05 15:12 ` [PATCH net 2/2] net/sched: sch_cake: charge an SCTP GSO packet by its own segments Julius Bairaktaris
1 sibling, 0 replies; 4+ messages in thread
From: Julius Bairaktaris @ 2026-12-05 15:12 UTC (permalink / raw)
To: Toke Høiland-Jørgensen
Cc: netdev, cake, Jamal Hadi Salim, Jiri Pirko, David S . Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Willem de Bruijn,
Simon Horman
With autorate-ingress, cake_enqueue() adds the length of each arriving
packet to avg_window_bytes, the byte count of the current estimation
window, which it resets to 0 when it closes a window. When the ACK
filter drops a queued ACK for the new packet, it adds the new length
minus that of the dropped ACK. The filter can drop an ACK that is
longer than the new one: an older ACK whose SACK blocks the new one
covers, for example two blocks merged into one, which is 8 bytes
shorter. Right after a window close the u64 count then wraps to nearly
2^64, and when this packet closes the window as well, the sample taken
from it sets avg_peak_bandwidth and, through cake_reconfigure(), the
shaper rate to tens of Gbit/s.
The dropped ACK was counted in the window it arrived in. Count what
arrives: the window measures the arrival rate, not the queue.
Fixes: 8b7138814f29 ("sch_cake: Add optional ACK filter")
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
net/sched/sch_cake.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c
index c1652c0506e1..8448559e8fa8 100644
--- a/net/sched/sch_cake.c
+++ b/net/sched/sch_cake.c
@@ -1868,7 +1868,7 @@ static s32 cake_enqueue(struct sk_buff *skb, struct Qdisc *sch,
/* stats */
WRITE_ONCE(b->packets, b->packets + 1);
qstats_backlog_add(sch, len - ack_pkt_len);
- q->avg_window_bytes += len - ack_pkt_len;
+ q->avg_window_bytes += len;
WRITE_ONCE(b->bytes, b->bytes + len - ack_pkt_len);
WRITE_ONCE(b->tin_backlog, b->tin_backlog + len - ack_pkt_len);
WRITE_ONCE(b->backlogs[idx], b->backlogs[idx] + len - ack_pkt_len);
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH net 2/2] net/sched: sch_cake: charge an SCTP GSO packet by its own segments
2026-12-05 15:11 [PATCH net 0/2] net/sched: sch_cake: two shaper accounting fixes Julius Bairaktaris
2026-12-05 15:12 ` [PATCH net 1/2] net/sched: sch_cake: count the arriving packet in the autorate window Julius Bairaktaris
@ 2026-12-05 15:12 ` Julius Bairaktaris
2026-12-06 16:06 ` netdev-bot+sashiko
1 sibling, 1 reply; 4+ messages in thread
From: Julius Bairaktaris @ 2026-12-05 15:12 UTC (permalink / raw)
To: Toke Høiland-Jørgensen
Cc: netdev, cake, Jamal Hadi Salim, Jiri Pirko, David S . Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Willem de Bruijn,
Simon Horman
cake_overhead() charges a GSO skb the overhead of each segment it will
be sent as, taking every segment but the last as gso_size plus the
headers. SCTP builds its GSO skbs with gso_size set to GSO_BY_FRAGS
(0xFFFF), and each skb on the frag list is one packet. For those,
every segment but the last is charged as 65535 bytes plus headers, and
the length of the last one wraps and is charged the mpu, so a
two-packet SCTP skb of 3 kB costs the shaper and the flow's deficit
about 65 kB. Every flow on the qdisc then loses link time to a local
SCTP sender, and the adjusted-size statistics are wrong. CAKE computes
this for every GSO skb it does not split at enqueue, as with
no-split-gso.
Charge a GSO_BY_FRAGS skb per skb on its frag list, each as the head's
headers plus its own length, which is the packet skb_segment() makes of
it.
Fixes: a729b7f0bd5b ("sch_cake: Add overhead compensation support to the rate shaper")
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
net/sched/sch_cake.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c
index 8448559e8fa8..9722d1ce170e 100644
--- a/net/sched/sch_cake.c
+++ b/net/sched/sch_cake.c
@@ -1426,6 +1426,20 @@ static u32 cake_overhead(struct cake_sched_data *q, const struct sk_buff *skb)
if (segs == 1)
return cake_calc_overhead(q, len, off);
+ /* SCTP: each skb on the frag list is one packet, sent behind the
+ * headers of the head
+ */
+ if (shinfo->gso_size == GSO_BY_FRAGS) {
+ const struct sk_buff *frag;
+ u32 hdr = skb->len, adjlen = 0;
+
+ skb_walk_frags(skb, frag)
+ hdr -= frag->len;
+ skb_walk_frags(skb, frag)
+ adjlen += cake_calc_overhead(q, hdr + frag->len, off);
+ return adjlen;
+ }
+
/* borrowed from qdisc_pkt_len_segs_init() */
if (!skb->encapsulation)
hdr_len = skb_transport_offset(skb);
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net 2/2] net/sched: sch_cake: charge an SCTP GSO packet by its own segments
2026-12-05 15:12 ` [PATCH net 2/2] net/sched: sch_cake: charge an SCTP GSO packet by its own segments Julius Bairaktaris
@ 2026-12-06 16:06 ` netdev-bot+sashiko
0 siblings, 0 replies; 4+ messages in thread
From: netdev-bot+sashiko @ 2026-12-06 16:06 UTC (permalink / raw)
To: julius
Cc: toke, netdev, jhs, jiri, davem, edumazet, kuba, pabeni, willemb,
horms
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] net/sched: cake_overhead() returns 0 for GSO_BY_FRAGS with
NULL frag_list
--
> diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c
> --- a/net/sched/sch_cake.c
> +++ b/net/sched/sch_cake.c
> @@ -1426,6 +1426,20 @@ static u32 cake_overhead(struct cake_sched_data *q, const struct sk_buff *skb)
> if (segs == 1)
> return cake_calc_overhead(q, len, off);
>
> + /* SCTP: each skb on the frag list is one packet, sent behind the
> + * headers of the head
> + */
> + if (shinfo->gso_size == GSO_BY_FRAGS) {
> + const struct sk_buff *frag;
> + u32 hdr = skb->len, adjlen = 0;
> +
> + skb_walk_frags(skb, frag)
> + hdr -= frag->len;
> + skb_walk_frags(skb, frag)
> + adjlen += cake_calc_overhead(q, hdr + frag->len, off);
> + return adjlen;
> + }
> +
> /* borrowed from qdisc_pkt_len_segs_init() */
> if (!skb->encapsulation)
> hdr_len = skb_transport_offset(skb);
[Severity: Medium]
If this branch is entered with skb_shinfo(skb)->frag_list == NULL,
both skb_walk_frags() loops run zero times and cake_overhead()
returns 0. Before this patch the function always went through
cake_calc_overhead(), so it could never return 0.
gso_size == GSO_BY_FRAGS together with qdisc_pkt_segs() != 1 does
not guarantee a frag list, though.
A cls_bpf program calling bpf_skb_pull_data(skb, skb->len), or
act_pedit through skb_ensure_writable(), ends up in
__pskb_pull_tail(). That pulls the frag_list skbs into the head and
clears frag_list, but leaves gso_size and the pkt_segs value cached
by qdisc_pkt_len_segs_init() alone. With no-split-gso on a device
that advertises NETIF_F_GSO_SCTP (veth, lo, ifb, ...), that skb
reaches cake_overhead() unsegmented.
xen-netback also accepts a guest-supplied gso.size of 0xffff on TCP
frames, which never have a frag list there. For header-only frames
gso_segs comes out as 0, so even the default split-gso path does not
catch it.
With adjusted_len == 0:
- cake_advance_shaper() charges nothing to the tin, global and
failsafe shapers.
- cake_dequeue() takes nothing out of flow->deficit or
b->tin_deficit.
- The mpu, overhead and ATM/PTM handling in cake_calc_overhead(),
and the netlen and adjlen statistics, are skipped entirely.
Such packets are sent for free and their flow is never made to
yield.
Could this path be limited to skb_has_frag_list(skb), with anything
else charged as a single packet via cake_calc_overhead(q, len, off)?
Or do you see a better way to account for how such an skb will
actually go out? Either way, cake_overhead() should not be able to
return 0 here.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261205151201.2705110-1-julius%40bairaktaris.de
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-06 16:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-05 15:11 [PATCH net 0/2] net/sched: sch_cake: two shaper accounting fixes Julius Bairaktaris
2026-12-05 15:12 ` [PATCH net 1/2] net/sched: sch_cake: count the arriving packet in the autorate window Julius Bairaktaris
2026-12-05 15:12 ` [PATCH net 2/2] net/sched: sch_cake: charge an SCTP GSO packet by its own segments Julius Bairaktaris
2026-12-06 16:06 ` 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