Re: [PATCH bpf-next v2] cgroup/rstat: disable preemption in css_rstat_updated()

From: Shakeel Butt

Date: Tue Nov 24 2026 - 00:20:55 EST


On Tue, Nov 24, 2026 at 04:16:42AM +0100, Karl Mehltretter wrote:
> BPF programs can call css_rstat_updated() with preemption enabled.
> The kfunc calls __css_rstat_updated(), which requires preemption to
> be disabled while it queues an rstat update. A cgroup iterator can
> hit the lockdep assertion on both RT and non-RT kernels. The
> cgroup_hierarchical_stats selftest can also hit it on PREEMPT_RT:
> spin_lock_irqsave() on trace_cgroup_path_lock leaves preemption and
> interrupts enabled there.
>
> Disable preemption in the BPF wrapper after validating the CPU and
> before calling __css_rstat_updated().
>
> Fixes: 36df6e3dbd7e ("cgroup: make css_rstat_updated nmi safe")
> Reported-by: Jiayuan Chen <jiayuan.chen@xxxxxxxxx>
> Closes: https://lore.kernel.org/r/20251119111402.153727-1-jiayuan.chen@xxxxxxxxx/
> Signed-off-by: Karl Mehltretter <kmehltretter@xxxxxxxxx>

Acked-by: Shakeel Butt <shakeel.butt@xxxxxxxxx>