Re: [PATCH cgroup/for-6.19] cgroup: Fix sleeping from invalid context warning on PREEMPT_RT
From: Calvin Owens
Date: Wed Nov 05 2025 - 20:15:54 EST
On Wednesday 11/05 at 09:03 -1000, Tejun Heo wrote:
> cgroup_task_dead() is called from finish_task_switch() which runs with
> preemption disabled and doesn't allow scheduling even on PREEMPT_RT. The
> function needs to acquire css_set_lock which is a regular spinlock that can
> sleep on RT kernels, leading to "sleeping function called from invalid
> context" warnings.
>
> css_set_lock is too large in scope to convert to a raw_spinlock. However,
> the unlinking operations don't need to run synchronously - they just need
> to complete after the task is done running.
>
> On PREEMPT_RT, defer the work through irq_work.
>
> Fixes: d245698d727a ("cgroup: Defer task cgroup unlink until after the task is done switching out")
> Reported-by: Calvin Owens <calvin@xxxxxxxxxx>
> Link: https://lore.kernel.org/r/20251104181114.489391-1-calvin@xxxxxxxxxx
> Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>
> ---
> Hello,
>
> Calvin, this seems to work fine here but can you please try it out?
Works for me, no splats with that on top of next-20251104.