Re: [PATCH net v4 2/3] net/sched: act_gate: refuse schedule entries shorter than 10 us

From
Jamal Hadi Salim <jhs@mojatatu.com>
Date
2026-11-24 17:11:18
Also in
linux-rt-devel, stable
Reply to
Jamal Hadi Salim, 2026-11-24
On Tue, Nov 24, 2026 at 11:58 AM Jamal Hadi Salim [off-list ref] wrote:
On Tue, Nov 24, 2026 at 11:13 AM Sebastian Andrzej Siewior
[off-list ref] wrote:
quoted
On 2026-11-24 09:12:09 [-0500], Jamal Hadi Salim wrote:
quoted
This is a followup of commit a51c328df310 ("net: qos: introduce a gate
control flow action") as reported by Sashiko.

The issue:
fill_gate_entry() only rejects an interval of zero, but that interval is
the period gate_timer_func() re-arms the hrtimer at, and a few
nanoseconds is below the cost of servicing one expiry: the next is due
before the current one finishes, so the action holds a CPU in the timer
softirq for as long as it exists.
The timer is programmed in the past, fires immediately and hogs the
CPU.
quoted
On a 2-vCPU guest, entries of 1 us and below hold 86% to 90% of a core,
2 us holds 61%, and 3 us holds 22%; from 3.5 us on the cost falls to a
few percent and it reaches zero by 100 us.

The Fix:
Require at least 10 us per entry.  An act_gate schedule is not tied to a
device, so unlike taprio there is no frame time to derive a bound from;
the bound has to come from the cost of servicing one expiry, with room
for a kernel that services it slower.
The 10us sound sane. With enough debug (say kasan, lockdep, …) this
might become tight again.
Agreed. Unfortunately, there is no way to derive a "good value" here
(it depends on workload, machine, utilization, etc, etc).
poor choice of wording on my part - should probably have said all of
what i said above for precisiness...
And now that you bring this up - this should really have been
targetting net-next not net.
I dont want to resend (unless sashikos find something sinister) - but
Jakub/Paolo consider applying this to net-next instead when the time
comes.


cheers,
jamal
Cant wait to see the pedantic nitpicks the sashikos will get about
this. Regardless if this is all they came up with I am not resending.
quoted
…
quoted
Fixes: a51c328df310 ("net: qos: introduce a gate control flow action")
Reported-by: Sashiko (gemini) <sashiko-bot@kernel.org>
There is no syzbot report for this?
It's in 1/3
quoted
quoted
Closes: https://sashiko.dev/#/patchset/tencent_4ED9536B0375C96183B2244CF7709768C605@qq.com
Cc: <redacted>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
quoted
--- a/net/sched/act_gate.c
+++ b/net/sched/act_gate.c
@@ -25,6 +25,11 @@ static struct tc_action_ops act_gate_ops;
  */
 #define GATE_ENTRIES_MAX     1024U

+/* An entry shorter than this lets the next expiry land before the softirq
+ * servicing the current one can finish, so the timer stays permanently behind.
+ */
No strong opinion. I leave this here.

| With a too small interval the next timer will be programmed in the past
| and will fire immediately.
see above.

cheers,
jamal
quoted
quoted
+#define GATE_MIN_INTERVAL_NSEC       10000U
+
 static ktime_t gate_get_time(struct tcf_gate *gact)
 {
      ktime_t mono = ktime_get();
Sebastian
Thread (13 messages) 13 messages, 4 authors, last reply 1d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help