All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shakeel Butt <shakeel.butt@linux.dev>
To: Tejun Heo <tj@kernel.org>
Cc: 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>,
	cgroups@vger.kernel.org, linux-mm@kvack.org,
	 linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/9] cgroup: don't hold cgroup_mutex for cgroup.kill and cgroup.freeze
Date: Mon, 30 Nov 2026 09:04:01 -0800	[thread overview]
Message-ID: <aw2hPgwq5Dl-JBMQ@linux.dev> (raw)
In-Reply-To: <a6553d7921f3f47b7b890bfd232de644@kernel.org>

On Sun, Nov 29, 2026 at 06:25:21PM -1000, Tejun Heo wrote:
> Hello, Shakeel.
> 
> The following is a Claude-generated review.
> 
> Two problems were found, in 8/9 and 9/9. Both were reproduced in a VM
> with delays added to widen the windows. The debug patch and the
> reproducer are attached.

Thanks a lot for taking a look.

> 
> 1. A migration that fails before it commits makes the task walk skip a
>    task (8/9 and 9/9).
> 
>    cgroup_migrate_add_task() calls css_set_skip_task_iters() and moves
>    the task to cset->mg_tasks. When ->can_attach() then fails,
>    out_release_tset in cgroup_migrate_execute() splices mg_tasks back
>    onto cset->tasks. An iterator whose next task was that one has
>    already moved past the end of cset->tasks and never returns it. The
>    task didn't change css_set, so neither the kill in
>    cgroup_migrate_execute() nor cgroup_freezer_migrate_task() runs for
>    it. cgroup_mutex used to keep migrations out of the walks.
> 
>    The task has to be the last one on its css_set that the iterator
>    hasn't returned, so a cgroup with one task is enough. With the failed
>    attach between css_task_iter_start() and the first
>    css_task_iter_next():
> 
>    - cgroup.kill returns success and the task survives.
>    - A freeze leaves cgroup.freeze at 1 with the task running, and the
>      cgroup never reports frozen.
>    - A thaw leaves cgroup.freeze at 0 and "frozen 0" in cgroup.events
>      with the task still frozen.

I think this failed migration issue is in css_task_iter and has been present
since the commit 5ee01f1a7343. Will fix as a separate patch in v2.

> 
> 2. The SIGKILL sent from cgroup_migrate_execute() isn't forced (8/9).
> 
>    send_sig(SIGKILL, task, 0) sends SEND_SIG_NOINFO, which
>    send_signal_locked() forces only when current is outside the target's
>    pid namespace. current is the migrator there, not the cgroup.kill
>    writer. A pid namespace init which writes its own pid to cgroup.procs
>    of a cgroup that the walk has already passed ignores the signal and
>    survives a kill written from the host. The same move made from the
>    host kills it.
> 
>    The other direction follows from the code and wasn't run: a host
>    migration during a kill written inside the container kills an init
>    which that kill would have left alone.

Here I think we need to remember the writer and for the migration path, if the
writer is outside the target's pid namespace, only then force the kill.

I will address the remaining points as well in v2.

      reply	other threads:[~2026-11-30 17:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 18:35 [PATCH 0/9] cgroup: don't hold cgroup_mutex for cgroup.kill and cgroup.freeze Shakeel Butt
2026-11-29 18:35 ` [PATCH 1/9] cgroup: kill a child forked while cgroup.kill runs Shakeel Butt
2026-11-29 18:35 ` [PATCH 2/9] cgroup/freezer: check own tasks and descendants for the frozen state Shakeel Butt
2026-11-29 18:35 ` [PATCH 3/9] cgroup/freezer: don't update the frozen state of removed cgroups Shakeel Butt
2026-11-29 18:35 ` [PATCH 4/9] cgroup/freezer: test the freeze trap bit under siglock Shakeel Butt
2026-11-29 18:35 ` [PATCH 5/9] selftests/cgroup: test the frozen state of a cgroup with tasks and children Shakeel Butt
2026-11-30 18:36   ` sashiko-bot
2026-11-29 18:35 ` [PATCH 6/9] selftests/cgroup: test cgroup.kill in a threaded cgroup Shakeel Butt
2026-11-29 18:35 ` [PATCH 7/9] cgroup: factor out cgroup_kn_break_active() and cgroup_kn_unbreak_active() Shakeel Butt
2026-11-29 18:35 ` [PATCH 8/9] cgroup: don't hold cgroup_mutex for cgroup.kill Shakeel Butt
2026-11-30 18:36   ` sashiko-bot
2026-11-30 21:21     ` Shakeel Butt
2026-11-29 18:35 ` [PATCH 9/9] cgroup/freezer: don't hold cgroup_mutex for cgroup.freeze Shakeel Butt
2026-11-30  4:25 ` [PATCH 0/9] cgroup: don't hold cgroup_mutex for cgroup.kill and cgroup.freeze Tejun Heo
2026-11-30 17:04   ` Shakeel Butt [this message]

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=aw2hPgwq5Dl-JBMQ@linux.dev \
    --to=shakeel.butt@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=bigeasy@linutronix.de \
    --cc=brauner@kernel.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=mkoutny@suse.com \
    --cc=oleg@redhat.com \
    --cc=roman.gushchin@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.