Re: [PATCH v3 12/12] cgroup/freezer: don't hold cgroup_mutex for cgroup.freeze

From: Espen Tveit

Date: Fri Dec 04 2026 - 21:10:40 EST


Hi Shakeel,

I ran TLA+ models of patch 11 ("cgroup: don't hold cgroup_mutex for
cgroup.kill") exhaustively with warpspec. No violations were found on
the patch as posted, and disabling each added safeguard individually
reproduces the bug it is meant to prevent.

What was checked (LLM-drafted):

Two models:
- domain: root/A/B with sibling root/C, modeling processes and rmdir
- threaded: root/A/B/C with sibling root/D, modeling individual threads
and switches to threaded

Each run explores all interleavings of kills, forks (including
CLONE_THREAD and CLONE_INTO_CGROUP), and migrations, bounded to 1-3
forks and 1-2 migrations. Below, "host" means a writer in the initial
pid ns, and "in-ns" means a writer inside the child pid ns (same ns as
the pid ns init).

Properties checked in every run:
- every process in the tree at kill start, and every child it forks,
gets SIGKILL
- a pid ns init is killed only by a writer outside its pid ns
- no process with threads outside the tree is killed
- nr_killing / nr_subtree_kills return to 0 after all writers finish

Patch as posted:

scenario states fork/mig
------------------------------------------------- ------ --------
domain: 1 host kill on A 24M 2/2
domain: 1 in-ns kill on A 13M 2/2
domain: host kills on A & B, pid ns init in B 3.14G 2/2
domain: in-ns kills on A & B 1.20G 2/2
domain: host kill on B + in-ns kill on A 2.67G 2/2
domain: 2 overlapping host kills on A 9.18G 2/2
domain: host kills on A & C, tasks moving 9.22G 3/2
threaded: switches to threaded vs kill below 33M 1/2
threaded: kill on thread root B vs switch of A 49M 1/2
threaded: host kill on A, init threads in B 927M 2/2
threaded: in-ns kill on A, init threads in B 998M 2/2
threaded: host kill on A + in-ns kill on B 464M 1/1

All pass.

Each mechanism was disabled on the same scenario as a passing run
above (the migration kill and the CLONE_INTO_CGROUP check on "1 host
kill on A", the EBUSY checks on "kill on thread root B vs switch of
A", and the post_fork force on "host kill on A, init threads in B");
in each case the model finds the bug it prevents.

Limitations / not modeled:
- Locked sections are atomic steps, and unlocked reads such as
cgroup_is_populated() are treated as consistent snapshots.
- The task walk is assumed to return every task that stays in its
cgroup (checked separately for patch 01).
- Not modeled: CLONE_NEWPID children, controller-driven css_set
changes, the extra threaded css_sets visited by
CSS_TASK_ITER_THREADED, lock ordering, refcount lifetimes, and
memory ordering (covered by lockdep / KCSAN rather than the model).

Overall, patch 11's concurrency logic looks solid; the two races
between pass 1 and pass 2 of patch 12 (cgroup_update_frozen() skipped
for populated cgroups in pass 1) were the only issues found in the
series.

Thanks,
Espen
________________________________________
From: Shakeel Butt <shakeel.butt@xxxxxxxxx>
Sent: Saturday, December 5, 2026 12:35 AM
To: Espen Tveit
Cc: Tejun Heo; Andrew Morton; Johannes Weiner; Michal Koutny; Michal Hocko; Roman Gushchin; Christian Brauner; Oleg Nesterov; Sebastian Andrzej Siewior; Suren Baghdasaryan; T.J. Mercier; Usama Arif; Meta kernel team; cgroups@xxxxxxxxxxxxxxx; linux-mm@xxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
Subject: Re: [PATCH v3 12/12] cgroup/freezer: don't hold cgroup_mutex for cgroup.freeze

Hi Espen,

On Fri, Dec 04, 2026 at 11:16:50PM +0000, Espen Tveit wrote:
> Hi Shakeel,
>
> While experimenting with a TLA+ solver (warpspec) against patch 12, I
> found two races between pass 1 and pass 2. Details follow (LLM-drafted,
> cross-checked against the patch code):

Thanks for the report, I will take a look. Can you also run your TLA+ solver
against patch 11 ("cgroup/freezer: don't hold cgroup_mutex for cgroup.freeze")?