Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Michal Hocko <mhocko@suse.com>
Cc: Zhan Xusheng <zhanxusheng1024@gmail.com>,
	akpm@linux-foundation.org, hannes@cmpxchg.org,
	roman.gushchin@linux.dev, shakeel.butt@linux.dev,
	muchun.song@linux.dev, penguin-kernel@i-love.sakura.ne.jp,
	mkoutny@suse.com, chris@chrisdown.name, cui.tao@linux.dev,
	cgroups@vger.kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	zhanxusheng@xiaomi.com
Subject: Re: [PATCH v3] mm: memcontrol: don't miss processes whose leader has exited in OOM scans
Date: Mon, 23 Nov 2026 01:13:25 -1000	[thread overview]
Message-ID: <305c5803b904a57c188b505d6ed9e1e4@kernel.org> (raw)
In-Reply-To: <awQRT7InNqEF-K8-@tiehlicka>

Hello, Michal.

On Mon, Nov 23, 2026 at 11:11:27AM +0100, Michal Hocko wrote:
> Tejun, is there any strong reason to keep the exiting thread group
> leader in the original cgroup? This makes CSS_TASK_ITER_PROCS iteration
> really tricky and error prone as above examples show.

No, and I agree that the leader should follow the rest of the process on
cgroup.procs migrations. It's this way because controllers primarily care
about resources and exiting and zombie tasks don't matter much in that
regard, so migration skips them and controllers don't have to deal with
them. I don't want to change that. It doesn't make much sense to teach
all controllers about them.

That rules out the full migration path for the leader, and moving it
without one looks fragile. If cgroup core switches its css_set without
involving the controllers, ->release() sees a different css from the one
the task exited in, which breaks e.g. pids uncharging, and that still
doesn't work for a leader which is exiting but not dead yet as it's still
running.

Maybe the leader can pretend to be in the new cgroup instead. On
cgroup.procs migrations, record the destination css_set in an exiting or
dead leader without touching the css_set it's actually on. When a
CSS_TASK_ITER_PROCS iteration finds the first live thread of a process
whose leader is exiting or dead, it looks at the leader and visits it
there if the recorded css_set agrees.

That leaves the leader's actual css_set and everything that the
controllers see as they are now. Only the iteration changes, and exiting
and dead leaders are handled the same way.

Thanks.

--
tejun


  reply	other threads:[~2026-11-23 11:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21  7:32 [PATCH v3] mm: memcontrol: don't miss processes whose leader has exited in OOM scans Zhan Xusheng
2026-11-22  7:32 ` sashiko-bot
2026-11-23  9:33   ` Zhan Xusheng
2026-11-23 10:11 ` Michal Hocko
2026-11-23 11:13   ` Tejun Heo [this message]
2026-11-23 11:39     ` Zhan Xusheng

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=305c5803b904a57c188b505d6ed9e1e4@kernel.org \
    --to=tj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=chris@chrisdown.name \
    --cc=cui.tao@linux.dev \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=mkoutny@suse.com \
    --cc=muchun.song@linux.dev \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=roman.gushchin@linux.dev \
    --cc=shakeel.butt@linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=zhanxusheng1024@gmail.com \
    --cc=zhanxusheng@xiaomi.com \
    /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