Re: [PATCH v2 00/11] cgroup: don't hold cgroup_mutex for cgroup.kill and cgroup.freeze

From: Shakeel Butt

Date: Tue Dec 01 2026 - 13:15:52 EST


On Tue, Dec 01, 2026 at 09:55:32AM -0800, Andrew Morton wrote:
> On Mon, 30 Nov 2026 09:34:14 -0800 Shakeel Butt <shakeel.butt@xxxxxxxxx> wrote:
>
> > cgroup.kill and cgroup.freeze take cgroup_mutex and hold it while they
> > walk every task of the subtree. cgroup.kill is how userspace OOM
> > killers, service managers and container runtimes stop a workload, often
> > when the system is already under pressure. Waiting for cgroup_mutex
> > makes the kill as slow as the slowest cgroup operation on the machine.
>
> I gave this series a fairly thorough workout on my LLM-driven live
> kernel test setup.
>
> I told it "if you hit a bug, fix it and keep going". It seems to have
> found four issues, fixed them and then everything worked OK. Its fixes
> sped a few things up nicely. I'll send those 4 patches in reply to the
> patches which they patch.
>

Thanks a lot for the testing and the fixes.

Three of the four fixes match changes I already have for v3, after the
sashiko review of v1:

- the NULL check in the nonleaf freezer selftest (7/11);
- EBUSY for a switch to threaded while a kill of the cgroup, or of a
cgroup below it, is running (10/11);
- refusing cgroup.kill below a threaded cgroup (10/11). Mainline has
this bug too, so v3 also adds it as a separate fix for stable.

Skipping empty branches in the task pass of the freeze walk (11/11) is
new to me, and the numbers look good. I'll fold it into the freeze patch
with your Co-developed-by and Signed-off-by, if that's OK with you.

v3 will also fix two more issues that sashiko found in v2. The fork path
decides whether its SIGKILL is forced from the parent instead of the
cgroup.kill writer, and the task pass of the freeze walk can visit a
cgroup that was created below a subtree it skipped.

The populated freeze rows are a bit slower. The freeze walk now takes
css_set_lock for each task to check which cgroup it is in, and I'll look
at whether that can be avoided.

With v3, the four fix patches won't be needed on top.

Thanks,
Shakeel