Commit 260fbcb
committed
cgroup: Move dying_tasks cleanup from cgroup_task_release() to cgroup_task_free()
Currently, cgroup_task_exit() adds thread group leaders with live member
threads to their css_set's dying_tasks list (so cgroup.procs iteration can
still see the leader), and cgroup_task_release() later removes them with
list_del_init(&task->cg_list).
An upcoming patch will defer the dying_tasks list addition, moving it from
cgroup_task_exit() (called from do_exit()) to a new function called from
finish_task_switch(). However, release_task() (which calls
cgroup_task_release()) can run either before or after finish_task_switch(),
creating a race where cgroup_task_release() might try to remove the task from
dying_tasks before or while it's being added.
Move the list_del_init() from cgroup_task_release() to cgroup_task_free() to
fix this race. cgroup_task_free() runs from __put_task_struct(), which is
always after both paths, making the cleanup safe.
Cc: Dan Schatzberg <dschatzberg@meta.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Tejun Heo <tj@kernel.org>1 parent 16dad78 commit 260fbcb
1 file changed
Lines changed: 5 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7019 | 7019 | | |
7020 | 7020 | | |
7021 | 7021 | | |
| 7022 | + | |
| 7023 | + | |
| 7024 | + | |
| 7025 | + | |
| 7026 | + | |
7022 | 7027 | | |
7023 | 7028 | | |
7024 | 7029 | | |
7025 | 7030 | | |
7026 | 7031 | | |
7027 | 7032 | | |
7028 | 7033 | | |
7029 | | - | |
7030 | 7034 | | |
7031 | | - | |
7032 | | - | |
7033 | | - | |
7034 | 7035 | | |
7035 | 7036 | | |
7036 | 7037 | | |
| |||
0 commit comments