From: Michal Hocko <mhocko@suse.com>
To: Zhan Xusheng <zhanxusheng1024@gmail.com>
Cc: 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,
tj@kernel.org, mkoutny@suse.com, cgroups@vger.kernel.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
zhanxusheng@xiaomi.com, stable@vger.kernel.org
Subject: Re: [PATCH] mm: memcontrol: don't miss processes whose leader has exited in OOM scans
Date: Mon, 2 Nov 2026 11:12:42 +0100 [thread overview]
Message-ID: <auhiGqKJeukk7t3P@tiehlicka> (raw)
In-Reply-To: <20261026120248.2188024-1-zhanxusheng1024@gmail.com>
On Mon 26-10-26 20:02:48, Zhan Xusheng wrote:
> From: Zhan Xusheng <zhanxusheng@xiaomi.com>
>
> mem_cgroup_scan_tasks() walks with CSS_TASK_ITER_PROCS, so it sees only
> thread group leaders, plus a dying leader that still has live threads.
> Moving a process whose leader has exited, by writing its PID to
> cgroup.procs, moves the live threads but leaves the leader behind, as
> cgroup_migrate_add_task() skips exiting tasks.
Is this a desirable/intended behavior? Shouldn't we move the dead leader
along with the rest?
> The destination's OOM killer then cannot see the process. If it is
> alone there, every attempt ends with "Out of memory and no killable
> processes..." and the charge is retried indefinitely, and
> memory.oom.group kills nothing; otherwise another process is killed in
> its place. The source's OOM killer still finds the leader, reaches the
> moved threads' mm through find_lock_task_mm(), and kills a process that
> has left the memcg.
While you patch works around this seems like something to address in the
cgroup core. Should CSS_TASK_ITER_PROCS iteration see all processes
regardless leader being alive after or prior the migration? AFAIU the
thread group belongs to the new cgroup in both cases.
>
> @@ -1452,9 +1482,10 @@ void mem_cgroup_scan_tasks(struct mem_cgroup *memcg,
> struct css_task_iter it;
> struct task_struct *task;
>
> - css_task_iter_start(&iter->css, CSS_TASK_ITER_PROCS, &it);
> + css_task_iter_start(&iter->css, 0, &it);
Shouldn't this be CSS_TASK_ITER_THREADED instead of 0?
> while (!ret && (task = css_task_iter_next(&it))) {
> - ret = fn(task, arg);
> + if (!mem_cgroup_scan_skip(task))
> + ret = fn(task, arg);
> /* Avoid potential softlockup warning */
> cond_resched();
> }
>
> base-commit: 6b4b543fa18757297ac756a6fe6e64f506b7844a
> --
> 2.43.0
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2026-11-02 10:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-26 12:02 [PATCH] mm: memcontrol: don't miss processes whose leader has exited in OOM scans Zhan Xusheng
2026-10-27 8:39 ` [PATCH] selftests: cgroup: test memcg OOM on a process whose leader has exited Zhan Xusheng
2026-10-27 12:03 ` [PATCH] mm: memcontrol: don't miss processes whose leader has exited in OOM scans sashiko-bot
2026-10-27 13:26 ` Tao Cui
2026-11-02 10:12 ` Michal Hocko [this message]
2026-11-02 11:40 ` Zhan Xusheng
2026-11-13 8:19 ` Michal Hocko
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=auhiGqKJeukk7t3P@tiehlicka \
--to=mhocko@suse.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--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=tj@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 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.