cgroup: list processes whose leader has exited where their threads are
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest2 patches 0 repliesNew
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | cgroup: list a process whose leader has exited where its threads areinclude/ kernel/ tools/ | +66 | 0 replies | |
| 2/2 | mm: memcontrol: find the OOM group of a process where its threads areinclude/ kernel/ mm/ | +30 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/2] cgroup: list processes whose leader has exited where their threads are
From: Zhan Xusheng <[email protected]>
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 passtest_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/[email protected]/
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
Signature · 1 line
2.43.0