]> git.ipfire.org Git - thirdparty/linux.git/commit
cgroup: relocate cgroup_attach_lock within cgroup_procs_write_start
authorYi Tao <escape@linux.alibaba.com>
Wed, 10 Sep 2025 06:59:34 +0000 (14:59 +0800)
committerTejun Heo <tj@kernel.org>
Wed, 10 Sep 2025 17:31:09 +0000 (07:31 -1000)
commit477abc2ec889a9dd3eb4ae0adbf6408a569bf2b6
tree8b22756d3cae591a2707fa442a6859698e7e4927
parenta1ffc8ad3165fa1cf6a60c6a4b4e00dfd6603cf2
cgroup: relocate cgroup_attach_lock within cgroup_procs_write_start

Later patches will introduce a new parameter `task` to
cgroup_attach_lock, thus adjusting the position of cgroup_attach_lock
within cgroup_procs_write_start.

Between obtaining the threadgroup leader via PID and acquiring the
cgroup attach lock, the threadgroup leader may change, which could lead
to incorrect cgroup migration. Therefore, after acquiring the cgroup
attach lock, we check whether the threadgroup leader has changed, and if
so, retry the operation.

tj: Minor comment adjustments.

Signed-off-by: Yi Tao <escape@linux.alibaba.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cgroup/cgroup.c