]> Gentwo Git Trees - linux/.git/commit
cpuset: Treat cpusets in attaching as populated
authorChen Ridong <chenridong@huawei.com>
Fri, 14 Nov 2025 02:08:47 +0000 (02:08 +0000)
committerTejun Heo <tj@kernel.org>
Fri, 21 Nov 2025 02:25:26 +0000 (16:25 -1000)
commitb1bcaed1e39a9e0dfbe324a15d2ca4253deda316
treee019156c6a93257b43f679c4ed10fd40a59d1ee2
parent318e18ed22e89397635e15095c014accaf47ed30
cpuset: Treat cpusets in attaching as populated

Currently, the check for whether a partition is populated does not
account for tasks in the cpuset of attaching. This is a corner case
that can leave a task stuck in a partition with no effective CPUs.

The race condition occurs as follows:

cpu0 cpu1
//cpuset A  with cpu N
migrate task p to A
cpuset_can_attach
// with effective cpus
// check ok

// cpuset_mutex is not held // clear cpuset.cpus.exclusive
// making effective cpus empty
update_exclusive_cpumask
// tasks_nocpu_error check ok
// empty effective cpus, partition valid
cpuset_attach
...
// task p stays in A, with non-effective cpus.

To fix this issue, this patch introduces cs_is_populated, which considers
tasks in the attaching cpuset. This new helper is used in validate_change
and partition_is_populated.

Fixes: e2d59900d936 ("cgroup/cpuset: Allow no-task partition to have empty cpuset.cpus.effective")
Signed-off-by: Chen Ridong <chenridong@huawei.com>
Reviewed-by: Waiman Long <longman@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cgroup/cpuset.c