From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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 ; Mon, 30 Nov 2026 15:46:44 +0000 (UTC) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FA951F000C1; Mon, 30 Nov 2026 15:46:43 +0000 (UTC) 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== Subject: Re: [PATCH net-next 1/4] net/sched: sch_cake: give the shaper timer slack 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 Date: Mon, 30 Nov 2026 15:46:42 +0000 Message-ID: <179605360257.3146.12392342891161576726@kernel.org> In-Reply-To: <20261129151144.2194312-2-julius@bairaktaris.de> References: <20261129151144.2194312-2-julius@bairaktaris.de> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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