Linux cgroups development
 help / color / mirror / Atom feed
* [PATCH 0/2] cgroup: list processes whose leader has exited where their threads are
@ 2026-11-24  3:35 Zhan Xusheng
  2026-11-24  3:35 ` [PATCH 1/2] cgroup: list a process whose leader has exited where its " Zhan Xusheng
  2026-11-24  3:35 ` [PATCH 2/2] mm: memcontrol: find the OOM group of a process " Zhan Xusheng
  0 siblings, 2 replies; 3+ messages in thread
From: Zhan Xusheng @ 2026-11-24  3:35 UTC (permalink / raw)
  To: tj
  Cc: hannes, mkoutny, mhocko, roman.gushchin, shakeel.butt,
	muchun.song, akpm, kolyshkin, chris, cgroups, linux-mm,
	linux-kernel, zhanxusheng

From: Zhan Xusheng <zhanxusheng@xiaomi.com>

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.

Unlike [1], the leader does not record the destination css_set at
migration time.  The walk looks up the css_set of the first live thread
instead, because a recorded css_set goes stale when the threads move
without a cgroup.procs write.  With a version that recorded it, writing
"+pids" to the parent's cgroup.subtree_control moved the threads to a
new css_set, and dst's cgroup.procs was empty again.

/proc/$PID/cgroup still shows the leader's cgroup, so for such a
process it now differs from the cgroup whose cgroup.procs lists it.
/proc/$PID/task/$TID/cgroup of a live thread shows the new cgroup, as
before.

Tested in a 2-CPU QEMU guest with KASAN and lockdep on for-7.4-fixes
acec9637e03c.  The process has an exited leader and two live threads,
and one thread ID is written to dst/cgroup.procs:

                                   base        1/2         1/2+2/2
  dst/cgroup.procs                 empty       pid         pid
  OOM in dst                       no kill     killed      killed
  OOM in src                       moved       not killed  not killed
                                   process
                                   killed
  OOM in dst with oom.group and    other       moved       both
  another process in dst           process     process     killed
                                   killed      killed
  test_kill, 5 runs                5 failures  pass        pass

test_core, test_freezer, test_pids and test_memcontrol give the same
results as base.  Patch 2 also applies to mm-hotfixes-unstable and
mm-new.

[1] https://lore.kernel.org/all/305c5803b904a57c188b505d6ed9e1e4@kernel.org/

Zhan Xusheng (2):
  cgroup: list a process whose leader has exited where its threads are
  mm: memcontrol: find the OOM group of a process where its threads are

 include/linux/cgroup.h                     | 18 ++++++
 include/linux/sched.h                      |  2 +
 kernel/cgroup/cgroup.c                     | 66 +++++++++++++++++++++-
 mm/memcontrol.c                            |  2 +-
 tools/testing/selftests/cgroup/test_kill.c | 16 ++++--
 5 files changed, 96 insertions(+), 8 deletions(-)


base-commit: acec9637e03ca54bd3c3a0c1a6ad5c6dfa07c0df
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-24  3:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24  3:35 [PATCH 0/2] cgroup: list processes whose leader has exited where their threads are Zhan Xusheng
2026-11-24  3:35 ` [PATCH 1/2] cgroup: list a process whose leader has exited where its " Zhan Xusheng
2026-11-24  3:35 ` [PATCH 2/2] mm: memcontrol: find the OOM group of a process " Zhan Xusheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox