Root Cause Analysis
1. Mechanism and Trigger
The bug report shows an expedited RCU CPU stall warning where CPU 0 failed to report a quiescent state (0-...D), while running in a hardirq context triggered during the execution of batadv_bla_periodic_work:
Workqueue: bat_events batadv_bla_periodic_work
batadv_bla_purge_claims+0x160/0x780 net/batman-adv/bridge_loop_avoidance.c:1289
At line 1289 of net/batman-adv/bridge_loop_avoidance.c, batadv_bla_purge_claims() acquired rcu_read_lock() and was interrupted by hrtimer_interrupt(). The batman-adv work item is not the root cause, but rather an innocent victim that was preempted by hardirq processing while holding an RCU read lock.
The root cause resides in the Time-Aware Priority (taprio) scheduler (net/sched/sch_taprio.c):
- Low interval validation threshold: When
taprio_change() parses a schedule entry via fill_sched_entry(), it enforces a minimum interval based on length_to_duration(q, ETH_ZLEN). On virtual network interfaces (such as team0, configured in the reproducer), this minimum duration can be extremely small or zero because link speed queries fail or default to high speeds, allowing userspace to configure schedule intervals as small as 3250 ns (0xcb2 in the reproducer).
- Sub-execution-time advance in
advance_sched():
- Infinite/tight loop in
__hrtimer_run_queues():
- In
kernel/time/hrtimer.c:1733, __hrtimer_run_queues() runs active timers in a loop:
while ((node = timerqueue_getnext(&base->active))) {
timer = container_of(node, struct hrtimer, node);
if (basenow < hrtimer_get_softexpires_tv64(timer))
break;
__run_hrtimer(cpu_base, base, timer, &basenow, flags);
}
- Whenever the timer callback execution overhead plus interrupt overhead ($E$) exceeds or is comparable to the scheduled interval ($I = 3250\text{ ns}$), any slight latency $\Delta t$ causes the timer to fall behind.
- Because
basenow is fixed across the while loop iterations and the timer advances its expiration by only $I$ on each iteration, catching up a lag of $\Delta t$ requires $\Delta t / I$ iterations, taking $(\Delta t / I) \cdot E > \Delta t$ of wall-clock time.
- When
__hrtimer_run_queues() returns to hrtimer_interrupt(), hrtimer_update_base() observes that time has moved forward even further, repeatedly retrying or firing immediately.
- Hardirq saturation and RCU stall:
- The CPU becomes trapped handling
hrtimer_interrupt / advance_sched() almost continuously in hardirq context.
- As a result, the interrupted task (
batadv_bla_purge_claims) running on CPU 0 under rcu_read_lock() cannot make forward progress to rcu_read_unlock() or report a quiescent state.
- Another CPU (CPU 1) waiting for an expedited grace period (
synchronize_rcu_expedited()) times out after 2684 jiffies, triggering the expedited RCU stall warning and sending an NMI to CPU 0.
Affected Files and Entities
- Source File:
net/sched/sch_taprio.c
- Functions:
advance_sched(), fill_sched_entry(), taprio_change()
- Structs/Fields:
struct taprio_sched::advance_timer, struct sched_entry::interval