๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by netdev-bot+sashiko Mon, 30 Nov 2026 15:46
Re: [PATCH net-next 2/4] net/sched: sch_cake: dither the flow quantum from a per-tin generator
#24669
Author: netdev-bot+sashiko
Date: Mon, 30 Nov 2026 15:46
67 lines
10370 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The commit message for "net/sched: sch_cake: dither the flow
  quantum from a per-tin generator" gives a performance motive but noโ€ฆ

--

net/sched: sch_cake: dither the flow quantum from a per-tin generator

This patch replaces the get_random_u16() dithering addend in
cake_get_flow_quantum() with a value taken from a per-tin struct rnd_state.
cake_init() seeds that state from get_random_u64() for each tin.

> CAKE adds a random 16-bit value to every flow quantum it hands out, so
> that the scaled quantum does not accumulate a rounding error. That is a
> get_random_u16() for nearly every packet dequeued, while the dithering
> needs no more than a uniform value.

[Severity: Low]
This isn't a bug, but are there any measurements behind the performance
motivation here? The commit message has no cycle counts, pps figures or
perf profile showing that get_random_u16() costs anything noticeable in
cake_get_flow_quantum().

get_random_u16() already draws from a batched per-CPU buffer. The patch also
adds a struct rnd_state to each struct cake_tin_data and moves this call
from the system CSPRNG to prandom. Without numbers it is hard to tell what
the change gains.

Is "nearly every packet dequeued" accurate? In net/sched/sch_cake.c,
cake_get_flow_quantum() has only two callers. In cake_dequeue() it runs
only when the deficit is refilled:

cake_dequeue() {
    ...
	if (flow->deficit <= 0) {
		...
		WRITE_ONCE(flow->deficit,
			   flow->deficit + cake_get_flow_quantum(b, flow, q->config->flow_mode));
    ...
}

The second caller is cake_enqueue(), when a flow is activated as sparse. The
commit message does not mention this one:

cake_enqueue() {
    ...
		WRITE_ONCE(flow->deficit, cake_get_flow_quantum(b, flow, q->config->flow_mode));
    ...
}

So the number of calls per dequeued packet is roughly pkt_len divided by
the scaled quantum. cake_set_rate() clamps flow_quantum to 300..1514 bytes,
and the quantum is then divided by host_load. Bulk MTU-sized or GSO traffic
gets one or more calls per packet. Small packets such as ACKs get far fewer
than one.

Could the commit message describe the call frequency more precisely and
include numbers that show the benefit?

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261129151144.2194312-1-julius%40bairaktaris.de
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads