Re: [PATCH 1/2] sched/psi: Create the psimon kthread outside of cgroup_mutex
Suren Baghdasaryan <[email protected]> Mon, 13 Jul 2026 08:19:12 -0700
| Newsgroups | dev.linux.lists.sched-ext,org.kernel.vger.cgroups,org.kernel.vger.linux-kernel,org.kernel.vger.stable |
|---|---|
| Message-ID | <CAJuCfpGAx3t_ur3gkpvr8uxooM5=1pbA+ap_qtUvu=CjNzaYzQ@mail.gmail.com> |
On Mon, Jul 13, 2026 at 6:48 AM Matt Fleming <[email protected]> wrote: > > On Sun, Jul 12, 2026 at 07:46:18AM -1000, Tejun Heo wrote: > > a5b98009f16d ("sched/psi: fix race between file release and pressure write") > > made pressure_write() hold cgroup_mutex across psi_trigger_create(), which > > forks the psimon kthread for the first rtpoll trigger. As kthread creation > > depends on the whole fork path, the commit inadvertently created a lot of > > unwanted locking dependencies from cgroup_mutex. > > > > sched_ext got hit by one: its enable path blocks forks and then grabs > > cgroup_mutex, so a pressure write racing a scheduler enable deadlocks, with > > every other fork piling up behind. > > > > Fix it by splitting trigger creation so that the worker is forked with > > cgroup_mutex dropped and the kernfs active reference left broken. The latter > > matters because rmdir and cgroup.pressure writes drain active references > > under cgroup_mutex. Publishing the trigger last keeps error reporting > > synchronous and preserves the of->priv lifetime rules. > > > > The trigger registered in the first stage pins the group's rtpoll machinery > > across the unlocked window, leaving only creation races to resolve. The > > catch-up poll on installation covers scheduling attempts dropped while there > > was no worker. > > > > v2: Retagged sched/psi (was cgroup). > > > > Fixes: a5b98009f16d ("sched/psi: fix race between file release and pressure write") > > Cc: [email protected] > > Cc: Johannes Weiner <[email protected]> > > Cc: Edward Adam Davis <[email protected]> > > Cc: Chen Ridong <[email protected]> > > Reported-by: Matt Fleming <[email protected]> > > Closes: https://lore.kernel.org/all/[email protected]/ > > Signed-off-by: Tejun Heo <[email protected]> > > --- > > include/linux/psi.h | 4 ++- > > kernel/cgroup/cgroup.c | 23 +++++++++++++- > > kernel/sched/psi.c | 69 ++++++++++++++++++++++++++++++++---------- > > 3 files changed, 78 insertions(+), 18 deletions(-) > > Tested-by: Matt Fleming <[email protected]> Acked-by: Suren Baghdasaryan <[email protected]>