Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: julius@bairaktaris.de
Cc: toke@toke.dk, netdev@vger.kernel.org, jhs@mojatatu.com,
	jiri@resnulli.us, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, willemb@google.com,
	horms@kernel.org, victor@mojatatu.com
Subject: Re: [PATCH net-next 1/4] net/sched: sch_cake: give the shaper timer slack
Date: Mon, 30 Nov 2026 15:46:42 +0000	[thread overview]
Message-ID: <179605360257.3146.12392342891161576726@kernel.org> (raw)
In-Reply-To: <20261129151144.2194312-2-julius@bairaktaris.de>

Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · Low: 2

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] In net/sched/sch_cake.c, cake_configure_rates() sets the slack
  to qd->timer_slack = min(100 us, 4 * psched_mtu * rate_ns >>…
- [Medium] The commit message presents the new slack as matching sch_fq
  ('as sch_fq does with its timer_slack').
- [Low] This is a pure performance change to a latency-focused qdisc.
- [Low] The comment added above the slack calculation in
  cake_configure_rates() (net/sched/sch_cake.c:2646-2651) says the cap…

--

net/sched: sch_cake: give the shaper timer slack

This patch changes how CAKE arms its shaper watchdog. Instead of an exact
expiry, it now uses qdisc_watchdog_schedule_range_ns() with a slack
computed in cake_configure_rates(). The slack is four MTU packet times at
the configured rate, capped at 100 us, and the goal is fewer timer
interrupts and softirqs at a few hundred Mbit/s.

> Let the timer fire up to four packet times late, capped at 100 us, as
> sch_fq does with its timer_slack. The shaper keeps its rate, since it
> sends what it owes once the timer runs.

[Severity: Low]
This isn't a bug, but this change trades up to 100 us of extra timer
lateness for fewer timer interrupts and softirqs, in a qdisc that is
focused on latency. Could the commit message include some measurements?

Before and after figures for CPU use, interrupt or softirq counts,
throughput, and latency or jitter would help.

Going by the slack formula, the batching benefit looks limited to a middle
band of rates. Below about 121 Mbit/s the slack is less than one packet
time, and at 10 Gbit/s it is only about 5 us.

> diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c
> index f97134522727e..89f3c5cbb3dee 100644
> --- a/net/sched/sch_cake.c
> +++ b/net/sched/sch_cake.c

[ ... ]

> @@ -1618,6 +1619,11 @@ static unsigned int cake_drop(struct Qdisc *sch, struct sk_buff **to_free)
>  	return idx + (tin << 16);
>  }
>  
> +static void cake_watchdog_schedule(struct cake_sched_data *q, u64 next)
> +{
> +	qdisc_watchdog_schedule_range_ns(&q->watchdog, next, q->timer_slack);
> +}

[Severity: Medium]
Below about 121 Mbit/s, is this slack shorter than one packet time? The
slack is min(100 us, four MTU times). A 1514 byte frame takes about 121 us
at 100 Mbit/s and about 1.2 ms at 10 Mbit/s, so the 100 us cap applies
while each wait on the shaper is longer than the slack.

qdisc_watchdog_schedule_range_ns() ends up in hrtimer_start_range_ns().
There, hrtimer_set_expires_range_ns() sets the hard expiry to
next + slack. Unless some other interrupt lands inside that window, the
watchdog fires at next + 100 us.

cake_advance_shaper() moves the departure time on from its previous
scheduled value, not from now:

		q->time_next_packet = ktime_add_ns(q->time_next_packet,
						   global_dur);

So a wakeup at T + S, where S is smaller than the packet time P, still
releases only one packet. The watchdog is then re-armed for T + P plus the
slack, from the global hard shaper branch in cake_dequeue() or the re-arm
at its end.

In that rate range, isn't the number of watchdog firings and qdisc runs
unchanged? Meanwhile, each packet that waits on the shaper would leave up
to about 100 us after its scheduled time. Many CAKE setups (home, CPE and
ingress shaping) run below that rate.

The commit message only says "below about 480 Mbit/s the cap applies".
It doesn't mention this effect below about 121 Mbit/s. As far as I can
tell, this behaviour is also unchanged later in the series.

[ ... ]

> @@ -2636,6 +2642,16 @@ static void cake_configure_rates(struct Qdisc *sch, u64 rate, bool rate_adjust)
>  
>  	qd->rate_ns   = qd->tins[ft].tin_rate_ns;
>  	qd->rate_shft = qd->tins[ft].tin_rate_shft;
> +
> +	/* Waking the shaper for every packet costs a timer interrupt and a
> +	 * softirq each. Letting the timer fire up to four packet times late
> +	 * lets it send a few at once, as sch_fq's timer_slack does; the shaper
> +	 * still meets its rate, since it catches up on what it owes. Capped so
> +	 * that a slow link waits no longer than a fast one would.

[Severity: Low]
This isn't a bug, but does this comment match the min_t() below it?

rate_ns >> rate_shft is nanoseconds per byte, so the second argument is
the time to send four MTU sized frames. On slow links that term is large
and the 100 us cap wins: 4.8 ms becomes 100 us at 10 Mbit/s. On fast links
the term is smaller, about 48 us at 1 Gbit/s and 5 us at 10 Gbit/s.

So a slow link waits longer than a fast one (100 us against 5 to 48 us),
not "no longer than" one. Was the intent that the extra wait on a slow
link is bounded?

> +	 */
> +	qd->timer_slack = min_t(u64, 100 * NSEC_PER_USEC,
> +				(4ULL * psched_mtu(qdisc_dev(sch)) *
> +				 qd->rate_ns) >> qd->rate_shft);

[Severity: Medium]
The commit message says this is done "as sch_fq does with its
timer_slack". In sch_fq the slack is a tunable with a 10 us default, set
in fq_init():

	q->timer_slack = 10 * NSEC_PER_USEC; /* 10 usec of hrtimer slack */

Userspace can change it through TCA_FQ_TIMER_SLACK in fq_change(), and
fq_dump() reports it.

Here the slack is hard-coded in cake_configure_rates(), and it reaches
100 us on any link below about 480 Mbit/s. There is no TCA_CAKE_*
attribute for it, no handling in cake_change(), and nothing in
cake_dump().

If a user sees added latency or jitter from this, is there a way to turn
it off or to see the value in use? The same slack also applies when
cake_enqueue() arms the watchdog while the shaper is still paying off
earlier traffic.

>  }

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

  reply	other threads:[~2026-11-30 15:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 15:11 [PATCH net-next 0/4] net/sched: sch_cake: per-packet cost of a shaping CAKE Julius Bairaktaris
2026-11-29 15:11 ` [PATCH net-next 1/4] net/sched: sch_cake: give the shaper timer slack Julius Bairaktaris
2026-11-30 15:46   ` netdev-bot+sashiko [this message]
2026-11-29 15:11 ` [PATCH net-next 2/4] net/sched: sch_cake: dither the flow quantum from a per-tin generator Julius Bairaktaris
2026-11-30 15:46   ` netdev-bot+sashiko
2026-11-29 15:11 ` [PATCH net-next 3/4] net/sched: sch_cake: keep short GSO aggregates whole Julius Bairaktaris
2026-11-30 15:46   ` netdev-bot+sashiko
2026-11-29 15:11 ` [PATCH net-next 4/4] net/sched: sch_cake: skip the dissection for a packet of an active flow Julius Bairaktaris
2026-11-30 15:46   ` netdev-bot+sashiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179605360257.3146.12392342891161576726@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=julius@bairaktaris.de \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=toke@toke.dk \
    --cc=victor@mojatatu.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox