Re: [PATCH net] net: gen_estimator: protect seqcount updates from hardirq readers
From: Sebastian Andrzej Siewior
Date: Wed Sep 23 2026 - 02:25:09 EST
On 2026-09-23 11:29:36 [+0800], Runyu Xiao wrote:
> est_timer updates the estimator seqcount with preemption disabled, which
> does not exclude hardirq readers on non-PREEMPT_RT kernels. A reader can
> observe an odd sequence and spin while the timer is interrupted.
How do you inject a reader from hardirq? Isn't this meant for softirq
context only?
> Disable interrupts around the seqcount write section.
>
> The failure mode was reproduced with an x86_64 kernel under QEMU. A
> test-only hardirq injection invokes gen_estimator_read() on the same CPU
> while est_timer() is updating the sequence counter.
>
> On the unfixed kernel, the hardirq reader reports the seqcount lockdep
> warning and spins until QEMU times out. With this change, the reader is
> deferred until the writer restores local IRQs, then returns and the guest
> shuts down normally. The hardirq context is deliberately injected to
> exercise this interleaving; ordinary userspace traffic does not guarantee
> it.
>
> Fixes: 1c0d32fde5bd ("net_sched: gen_estimator: complete rewrite of rate estimators")
> Cc: stable@xxxxxxxxxxxxxxx
> Assisted-by: LLM
> Signed-off-by: Runyu Xiao <runyu.xiao@xxxxxxxxxx>
Sebastian