Re: [PATCH cgroup/for-6.19] cgroup: Fix sleeping from invalid context warning on PREEMPT_RT

From: Tejun Heo

Date: Thu Nov 06 2025 - 12:37:17 EST


Hello,

On Thu, Nov 06, 2025 at 04:07:17PM +0100, Sebastian Andrzej Siewior wrote:
> How important is it, that it happens right away? Written as-is, this

Not important at all.

> leads to an interrupt then wakes irq_work/$cpu thread which then runs
> this callback. That thread runs as SCHED_FIFO-1. This means the
> termination of a SCHED_OTHER tasks on a single CPU will run as follows:
> - TASK_DEAD
> schedule()
> - queue IRQ_WORK
> -> INTERRUPT
> -> WAKE irq_work
> -> preempt to irq_work/
> -> handle one callback
> schedule()
> back to next TASK_DEAD
>
> So cgrp_dead_tasks_iwork_fn() will never have to opportunity to batch.
> Unless the exiting task's priority is > 1. Then it will be delayed
> until all RT tasks are done.
>
> My proposal would be to init the irq_work item with
> *per_cpu_ptr(&cgrp_dead_tasks_iwork, cpu) = IRQ_WORK_INIT_LAZY(cgrp_dead_tasks_iwork_fn);
>
> instead which won't raise an IRQ immediately and delay the callback
> until the next timer tick. So it could batch multiple tasks.
>
> [ queue_work() should work, too but the overhead to schedule is greater
> imho so this makes sense ]

Will switch to IRQ_WORK_LAZY_INIT.

Thanks for the review.

--
tejun