net/sched: act_gate: bound the cycle time and refuse schedule entries shorter than 10 us
Get series with b4
b4 am [email protected]Versions newest first
- v4 Latest3 patches 3 repliesIn review
Changes in v4 from the cover letter
- Reworked as a three-patch series on the current net tree.
- Bound base_time and cycle_time at KTIME_MAX, keeping NLA_U64.
- Saturating start-time arithmetic, shared with the catch-up path.
- Minimum entry interval, with its measured cost and its tdc coverage.
Patches in v4 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | net/sched: act_gate: bound the cycle time and start time arithmeticnet/ | +19 | 0 replies | |
| 2/3 | net/sched: act_gate: refuse schedule entries shorter than 10 usnet/ | +9 | 3 replies | |
| 3/3 | selftests: tc-testing: act_gate: cover the new cycle time and interval limitstools/ | +189 | 0 replies |
Reviews trailers per patch
1 of 3 patches has a Reviewed-by or Acked-by.
| Patch | Sebastian Andrzej Siewior |
|---|---|
| 1/3 | |
| 2/3 | R-b |
| 3/3 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH net v4 0/3] net/sched: act_gate: bound the cycle time and refuse schedule entries shorter than 10 us
An act_gate schedule is armed from TCA_GATE_BASE_TIME and TCA_GATE_CYCLE_TIME, both unchecked u64 attributes that are read into a signed ktime_t. A cycle time above S64_MAX turns negative on that read and the cycle arithmetic that follows wraps.
That arms the timer in the past. Every expiry then recomputes the same past time, so the timer softirq never finishes and the task that installed the action spins until the watchdog reports a soft lockup.
A schedule entry of a few nanoseconds reaches the same state from the other direction: the entry interval is the period the hrtimer runs at, so the handler is always behind its own next expiry and the action holds a core for as long as it exists.
1/3 cap base_time and cycle_time at KTIME_MAX, and make every
start-time computation saturate instead of wrapping.
2/3 require at least 10 us per schedule entry.
3/3 cover the refusals, the largest accepted base time and cycle time,
and both sides of the interval boundary in the tdc action tests.
Edward Adam Davis posted a v3 that capped cycle_time at S64_MAX and moved the attribute to NLA_S64. That refuses the reported value but leaves the invariant to the wrap: base_time is read the same way into the same arithmetic and stays unbounded, so an accepted pair can still compute a start the timer was never meant to take. The type change is also unnecessary; S64_MAX is a fine range for NLA_U64.
Alexei Starovoitov traced the stall to this action on the syzbot thread and sketched the saturating arithmetic used here:
https://lore.kernel.org/netdev/[email protected]/
This series keeps NLA_U64 for both attributes and bounds the computed start time rather than one input's value. cycle_time = 0 stays accepted:
it means "derive the cycle from the entry intervals".
The 10 us entry floor comes from the measured cost of one expiry rather than a device's frame time, and 2/3 states the margin it leaves. The 100 us floor proposed for taprio was withdrawn for narrowing working uAPI and for a margin it never explained; this floor answers both.
Changes in v4:
- Reworked as a three-patch series on the current net tree.
- Bound base_time and cycle_time at KTIME_MAX, keeping NLA_U64.
- Saturating start-time arithmetic, shared with the catch-up path.
- Minimum entry interval, with its measured cost and its tdc coverage.
v1 -> v2: reject an out-of-range cycletime instead of clamping it. v2 -> v3: move the range check into the netlink policy.
Jamal Hadi Salim (3):
net/sched: act_gate: bound the cycle time and start time arithmetic net/sched: act_gate: refuse schedule entries shorter than 10 us
selftests: tc-testing: act_gate: cover the new cycle time and interval
limits
net/sched/act_gate.c | 45 +++-- .../tc-testing/tc-tests/actions/gate.json | 189 ++++++++++++++++++ 2 files changed, 217 insertions(+), 17 deletions(-)
Signature · 1 line
2.43.0