summaryrefslogtreecommitdiff
path: root/kernel/cgroup/cpuset-internal.h
diff options
context:
space:
mode:
authorWaiman Long <longman@redhat.com>2026-01-12 11:00:21 -0500
committerTejun Heo <tj@kernel.org>2026-01-12 09:03:22 -1000
commit272bd8183376a9e20fe08bacbaa44003d7c8acaa (patch)
tree056bbaea9eee14c38049d9d6e0285b553538aa75 /kernel/cgroup/cpuset-internal.h
parent2a3602030d800b6600ef55c31e21bc54611f7770 (diff)
downloadlinux-next-272bd8183376a9e20fe08bacbaa44003d7c8acaa.tar.gz
linux-next-272bd8183376a9e20fe08bacbaa44003d7c8acaa.zip
cgroup/cpuset: Move the v1 empty cpus/mems check to cpuset1_validate_change()
As stated in commit 1c09b195d37f ("cpuset: fix a regression in validating config change"), it is not allowed to clear masks of a cpuset if there're tasks in it. This is specific to v1 since empty "cpuset.cpus" or "cpuset.mems" will cause the v2 cpuset to inherit the effective CPUs or memory nodes from its parent. So it is OK to have empty cpus or mems even if there are tasks in the cpuset. Move this empty cpus/mems check in validate_change() to cpuset1_validate_change() to allow more flexibility in setting cpus or mems in v2. cpuset_is_populated() needs to be moved into cpuset-internal.h as it is needed by the empty cpus/mems checking code. Also add a test case to test_cpuset_prs.sh to verify that. Reported-by: Chen Ridong <chenridong@huaweicloud.com> Closes: https://lore.kernel.org/lkml/7a3ec392-2e86-4693-aa9f-1e668a668b9c@huaweicloud.com/ Signed-off-by: Waiman Long <longman@redhat.com> Reviewed-by: Chen Ridong <chenridong@huawei.com> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/cgroup/cpuset-internal.h')
-rw-r--r--kernel/cgroup/cpuset-internal.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/kernel/cgroup/cpuset-internal.h b/kernel/cgroup/cpuset-internal.h
index e8e2683cb067..fd7d19842ded 100644
--- a/kernel/cgroup/cpuset-internal.h
+++ b/kernel/cgroup/cpuset-internal.h
@@ -260,6 +260,15 @@ static inline int nr_cpusets(void)
return static_key_count(&cpusets_enabled_key.key) + 1;
}
+static inline bool cpuset_is_populated(struct cpuset *cs)
+{
+ lockdep_assert_cpuset_lock_held();
+
+ /* Cpusets in the process of attaching should be considered as populated */
+ return cgroup_is_populated(cs->css.cgroup) ||
+ cs->attach_in_progress;
+}
+
/**
* cpuset_for_each_child - traverse online children of a cpuset
* @child_cs: loop cursor pointing to the current child