Re: [PATCH 0/2] cgroup: list processes whose leader has exited where their threads are
From: Tejun Heo
Date: Tue Nov 24 2026 - 13:47:47 EST
Hello, Zhan.
On Tue, Nov 24, 2026 at 11:35:45AM +0800, Zhan Xusheng wrote:
> This implements Tejun's suggestion in [1]. Patch 1 makes PROCS walks
> visit an exited leader left behind by a cgroup.procs migration at the
> first live thread of its process. Patch 2 makes the memcg OOM group
> lookup do the same.
The main problem I see is that it's difficult to keep the walks intact
this way. The thread that a leader is visited at is picked by testing
PF_EXITING, which isn't synchronized with css_set_lock, so, as the comment
in patch 1 notes, a walk can skip a process or visit it more than once. A
walk shouldn't miss processes.
It also looks fragile in general. AFAICS, only cgroup_migrate() sets
cg_leader_left, so when a cgroup.subtree_control write moves the threads
to a new css_set, a walk of that controller's css, e.g. the memcg OOM
scan, still misses the process. And as a walk can now return a leader
whose css_set isn't the process's, every user has to know to use
task_procs_css().
I'm trying out a different approach.
Thanks.
--
tejun