Article View: linux.kernel.netdev
Article #24667Re: [PATCH net-next 1/4] net/sched: sch_cake: give the shaper timer slack
From: netdev-bot+sashiko
Date: Mon, 30 Nov 2026 15:46
Date: Mon, 30 Nov 2026 15:46
147 lines
13984 bytes
13984 bytes
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
Technical Details
Message-ID:
<179605360257.3146.12392342891161576726@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374281-linux-kernel-netdev=dewy.ruReferences:
<20261129151144.2194312-2-julius@bairaktaris.de>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374281-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev 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 Organization: Usenet Network Message-ID: <179605360257.3146.12392342891161576726@kernel.org> References: <20261129151144.2194312-2-julius@bairaktaris.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1459655"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:dHv9U5N9hFw5CwXryuZ39691hWQ= sha256:or2LihFBg8ibzqyEO80tD4Orrj9K7qaAvkt7G5u1mzQ= sha1:joA4vecH7bHgbTMM8ymVgOyvHDU= sha256:TBLXdynjAqekWCxNZmpTqcVDstCzbTLJW/9c3/tMSgc= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 61BF4125FF2; Mon, 30 Nov 2026 18:47:20 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KJ8MhfOCkIHW; Mon, 30 Nov 2026 18:47:16 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374281-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 6F4C5125FED; Mon, 30 Nov 2026 18:47:07 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id BEB29325F2; Mon, 30 Nov 2026 15:46:47 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796053605; b=Ex37GFbV4AkQwkQBuoOtdrru759+qzOhrKZ22hDjyXOjCiKukpgjEb3c6velyrtObSm3 lnOpfr52QBQczqW/zNN02y0vJzbcVlpTICeVDTG1SCvmn8CwnYUzxKlehaODu6R/PFUnR SciQsjM55LD6Ww1M8L7tSQz6EL7F0H5UqgN/ZPLIcaenFDC7/RHtRHXSDXB0i+LiK/FAB +fmkDFj1Y8TSOLhopzUmnb0LQr5SGRq8xYYIYTV88IpV0wRMDYE31Asg9yUN1JjJbhTpF xggkxG46VyxwKgM7mVqFZhHhqrnGYklK5Jack9rMIdrnJ5sTmC7xvISlQDLHH7mBeHA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796053605; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=U1hi9inEDLVL3oqA7PjXiauCr/2OUfdglKqn4JwT6KQ=; b=Q3gOnkAe5fVhSA1JBVmBSSmKqE6kjxzlF1VVRZruifeMX+6CLxie9modXpgtTXf1B8VW b735x0+bfZIvxMuJavb3PKtGZeYnJPPRv4qHLNuumHAfpljEnw6x1SI3KVahml0jIiE91 r9Dfb5IJCEcXb2miHuQo8FtBpw8hq7cZPGvV7xhxhWi/sQZMYHoI4IdUD7agc2ZvFzcVh olWIMiGaPsaOdIf68Bmu/GtrQTU9OU9Oe5+tDM83s3LzYnlYGdVvND+LpqDojfQci7doE y384Bq83dLpitGAScEx3gdK9+oOHC8qD+DuiiAp9Pqzk7AfSM6JUDtgT9PwbXmd9LGA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=IJMjkTt0; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EA096606A69B; Mon, 30 Nov 2026 15:46:44 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=IJMjkTt0 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796053604; b=qu6JYhOhz/2XjPAcSI1FbotAKSfV5LYwMPmEhazUU2jK++VKJHUSGpSP8rANBU+rjTPk LGvKwB36OfpxFZ09dW68DMNTIaEt2MkTjkFPoi6P5IVXdVmDU42bs/CZFxFX4gxfQ72lo yysr0D1rT1Nn3LXNegizpKyftUFW2GkPkmKQ1IPG3MaSB+vrNQxPvRpVXuNImGwLoE/pl LDOc10Fla60Iw5tsVgRlPk+RGxH+xSh4U5n+VzArt3/wey3ZB4hsYa2pI6SobW2a+SSmj P+smFWTjTI03p6WT+g0bBMFlDMdqb9f5ks0eegVXotErcA6p4DWaH7CkgO4YUXc2lrg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796053604; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=U1hi9inEDLVL3oqA7PjXiauCr/2OUfdglKqn4JwT6KQ=; b=Hx+4iD3PPuOx90sW3l5a+8jztaikPdcYPjzINhlCTBFqzJ88yNLL/yKh3zst58W4RUSu 6v7hw2HvtrfulbMPRgHzxfW/qbU5p+tjThoInITvGHGVHNL2oTqxSzDKMRxVin8ZtbtPn t3e/YWYA5Hm4zqusqrV+8cTb8TlR8k6xkqVLe2BCiiptpDDGiBRTK6QWuCDmV9oPsu7n3 FmstlwAF+UDR47NJfBuFc7PgC0dKUgPv/YvpgFhKfu8M8w1kmiQiIjg8cVphm4AjLD8gS AT52gZSLf8UzPd67Wsc8dvtJq1g4uTtDZOp2bERiWjambhCNMZiEitwR6u4nq+qWAwQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=IJMjkTt0; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 18CDC606A692 for <netdev@vger.kernel.org>; Mon, 30 Nov 2026 15:46:44 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FA951F000C1; Mon, 30 Nov 2026 15:46:43 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796053603; bh=U1hi9inEDLVL3oqA7PjXiauCr/2OUfdglKqn4JwT6KQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=IJMjkTt0py6Mr59J67oVdmVl7UbJAnHVvtYMgfTpSLCuHsSIkeJRVakeOGbLqJ7uT CZe+2rEXf42quRkT6ex3HJXes/0qf+TW6m/P+CVaY/gqdQG468y3svHfNJ11y1Jm15 KBgNUk+3y1WQ0e/vegslfbgSMbxQbvFKE490xiHuNf8jHPPppc/xsf2OpduunYLoZ1 QgQ9XjtsCuGv1pAxEAH9vLc2uJV369SLLNhhkVsQx8uuh2KlEaK4uYWFs7NOqr3NU3 AwvEPIIW38APvc9mctoizEZqT0DTLQlZ4+oqr5c5vdL7m+cZHCB3JMEZ5OBXIaDsZQ 3CyIyqW2xET7g== X-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 X-In-Reply-To: <20261129151144.2194312-2-julius@bairaktaris.de> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list