Re: [PATCH] mm: memcontrol: don't miss processes whose leader has exited in OOM scans
From: Zhan Xusheng
Date: Mon Nov 02 2026 - 06:42:51 EST
Hi Michal,
This is v1. v2 [1] reworked the check, but your questions apply to
both.
On Mon, Nov 02, 2026 at 11:12:42AM +0100, Michal Hocko wrote:
> Is this a desirable/intended behavior? Shouldn't we move the dead leader
> along with the rest?
Userspace sees it too. After writing the PID of such a process to
dst/cgroup.procs:
src: cgroup.procs = 85 cgroup.threads = (empty)
dst: cgroup.procs = (empty) cgroup.threads = 86 87
Moving the leader would fix that, and memcg would then need no change,
as the PROCS walk already returns a dying leader with live threads.
The catch is that the leader has already gone through
cgroup_task_dead() and is still accounted by controllers: pids, for
one, uncharges it through task_css() when it is reaped, so the move
would also have to transfer its pids charge. Tejun, would that be
acceptable in the core?
> Should CSS_TASK_ITER_PROCS iteration see all processes
> regardless leader being alive after or prior the migration?
With the leader moved, it would. Otherwise PROCS would have to pick a
stand-in thread, which is what this patch does inside memcg.
> Shouldn't this be CSS_TASK_ITER_THREADED instead of 0?
No. Walking a memcg css goes over e_csets[memory], which already
includes the csets of threaded descendants, as memory is not a
threaded controller. THREADED also walks each cset's threaded_csets,
so those would be visited twice. It is meant for walks over
cgrp->self, like cgroup.procs. 0 is also what this function used
before f168a9a54ec3.
[1] https://lore.kernel.org/all/20261027144016.2582880-1-zhanxusheng1024@xxxxxxxxx/
Thanks,
Zhan Xusheng