From: Shakeel Butt <shakeel.butt@linux.dev>
To: sashiko-reviews@lists.linux.dev
Cc: Tejun Heo <tj@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Koutny <mkoutny@suse.com>,
Michal Hocko <mhocko@kernel.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Christian Brauner <brauner@kernel.org>,
Oleg Nesterov <oleg@redhat.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Suren Baghdasaryan <surenb@google.com>,
"T . J . Mercier" <tjmercier@google.com>,
Usama Arif <usama.arif@linux.dev>,
Meta kernel team <kernel-team@meta.com>,
linux-mm@kvack.org, Espen Tveit <espen.tveit@outlook.com>
Subject: Re: [PATCH v3 12/12] cgroup/freezer: don't hold cgroup_mutex for cgroup.freeze
Date: Sat, 5 Dec 2026 13:04:01 -0800 [thread overview]
Message-ID: <axR6pslefJKZYSE7@linux.dev> (raw)
In-Reply-To: <sashiko-outbox-251809@kernel.org>
On Sat, Dec 05, 2026 at 06:42:26PM +0000, sashiko-bot@kernel.org wrote:
[...]
> [Severity: High]
> Can skipping !cgroup_is_populated() here leave CGRP_FROZEN permanently
> stale if a cgroup becomes unpopulated between pass 1 and pass 2?
[...]
Espen reported this race as well and also found a thaw race: the first
pass clears CGRP_FREEZE, but CGRP_FROZEN is only cleared when the second
pass gets to the cgroup, so a task that moves in between runs in a
cgroup that still reports frozen.
> [Severity: High]
> Can an exiting task finishing in a dying child also depopulate a parent
> between pass 1 and pass 2 and leave its CGRP_FROZEN permanently stale?
This one is new and the fix I am working on will handle all three cases.
More specifically the first pass updates the frozen state of every cgroup
it changes, in the css_set_lock section that changes CGRP_FREEZE. The
first pass also emits the trace event, so the duplicate event is gone
too. Marking only the populated cgroups would fix the two races above,
but not the thaw race.
> Does holding global css_set_lock across cgroup_freeze_task() create heavy
> lock contention when freezing or thawing a populated cgroup?
It costs some speed, but the lock keeps the task's cgroup from changing
while its state is set. I plan to read the cgroup under siglock instead,
in a follow-up: a migration sets the task's state under siglock after it
changes the task's css_set.
> Can 32-bit cgroup_freeze_seq wrap around to 0 and collide with walk_seq?
Yes, after 2^32 writes. With the change above, a stray visit only sets
each task to the state of its own cgroup again, but I plan to make both
64-bit anyway.
> Should pass 1 check cgroup_is_dead(dsct) before acquiring css_set_lock?
Yes.
> Can this unbroken rcu_read_lock() stall RCU grace periods or trigger
> softlockups on large or deep hierarchies?
On kernels without preemptible RCU, yes. We can pin the current cgroup and
calls cond_resched() when needed.
> Does pass 2 still perform an O(N) walk of all immediate children when the
> entire subtree is empty?
Yes, we can skip the second pass when the cgroup has no tasks.
next prev parent reply other threads:[~2026-12-05 21:04 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 18:40 [PATCH v3 00/12] cgroup: don't hold cgroup_mutex for cgroup.kill and cgroup.freeze Shakeel Butt
2026-12-04 18:40 ` [PATCH v3 01/12] cgroup: don't lose a task in css_task_iter when a migration fails Shakeel Butt
2026-12-05 7:54 ` Tejun Heo
2026-12-04 18:40 ` [PATCH v3 02/12] cgroup: kill a child forked while cgroup.kill runs Shakeel Butt
2026-12-04 18:40 ` [PATCH v3 03/12] cgroup: refuse cgroup.kill below a threaded cgroup Shakeel Butt
2026-12-04 18:40 ` [PATCH v3 04/12] cgroup/freezer: check own tasks and descendants for the frozen state Shakeel Butt
2026-12-04 18:40 ` [PATCH v3 05/12] cgroup/freezer: don't update the frozen state of removed cgroups Shakeel Butt
2026-12-05 18:42 ` sashiko-bot
2026-12-04 18:40 ` [PATCH v3 06/12] cgroup/freezer: test the freeze trap bit under siglock Shakeel Butt
2026-12-04 18:40 ` [PATCH v3 07/12] selftests/cgroup: test cgroup.procs reads across a failed migration Shakeel Butt
2026-12-05 18:42 ` sashiko-bot
2026-12-04 18:40 ` [PATCH v3 08/12] selftests/cgroup: test the frozen state of a cgroup with tasks and children Shakeel Butt
2026-12-05 18:42 ` sashiko-bot
2026-12-04 18:40 ` [PATCH v3 09/12] selftests/cgroup: test cgroup.kill in and below a threaded cgroup Shakeel Butt
2026-12-05 18:42 ` sashiko-bot
2026-12-04 18:40 ` [PATCH v3 10/12] cgroup: factor out cgroup_kn_break_active() and cgroup_kn_unbreak_active() Shakeel Butt
2026-12-04 18:40 ` [PATCH v3 11/12] cgroup: don't hold cgroup_mutex for cgroup.kill Shakeel Butt
2026-12-05 18:42 ` sashiko-bot
2026-12-04 18:40 ` [PATCH v3 12/12] cgroup/freezer: don't hold cgroup_mutex for cgroup.freeze Shakeel Butt
2026-12-05 18:42 ` sashiko-bot
2026-12-05 21:04 ` Shakeel Butt [this message]
2026-12-04 18:54 ` [PATCH v3 00/12] cgroup: don't hold cgroup_mutex for cgroup.kill and cgroup.freeze Shakeel Butt
-- strict thread matches above, loose matches on Subject: below --
2026-12-04 23:16 [PATCH v3 12/12] cgroup/freezer: don't hold cgroup_mutex for cgroup.freeze Espen Tveit
2026-12-04 23:35 ` Shakeel Butt
2026-12-05 2:10 ` Espen Tveit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=axR6pslefJKZYSE7@linux.dev \
--to=shakeel.butt@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=bigeasy@linutronix.de \
--cc=brauner@kernel.org \
--cc=espen.tveit@outlook.com \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@meta.com \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=mkoutny@suse.com \
--cc=oleg@redhat.com \
--cc=roman.gushchin@linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=surenb@google.com \
--cc=tj@kernel.org \
--cc=tjmercier@google.com \
--cc=usama.arif@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox