Skip to content

Commit 933563a

Browse files
Waiman-Longgregkh
authored andcommitted
cgroup/cpuset: Fix a partition error with CPU hotplug
[ Upstream commit 150e298 ] It was found during testing that an invalid leaf partition with an empty effective exclusive CPU list can become a valid empty partition with no CPU afer an offline/online operation of an unrelated CPU. An empty partition root is allowed in the special case that it has no task in its cgroup and has distributed out all its CPUs to its child partitions. That is certainly not the case here. The problem is in the cpumask_subsets() test in the hotplug case (update with no new mask) of update_parent_effective_cpumask() as it also returns true if the effective exclusive CPU list is empty. Fix that by addding the cpumask_empty() test to root out this exception case. Also add the cpumask_empty() test in cpuset_hotplug_update_tasks() to avoid calling update_parent_effective_cpumask() for this special case. Fixes: 0c7f293 ("cgroup/cpuset: Add cpuset.cpus.exclusive.effective for v2") Signed-off-by: Waiman Long <longman@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent de2e883 commit 933563a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

kernel/cgroup/cpuset.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,7 +1843,7 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,
18431843
if (is_partition_valid(cs))
18441844
adding = cpumask_and(tmp->addmask,
18451845
xcpus, parent->effective_xcpus);
1846-
} else if (is_partition_invalid(cs) &&
1846+
} else if (is_partition_invalid(cs) && !cpumask_empty(xcpus) &&
18471847
cpumask_subset(xcpus, parent->effective_xcpus)) {
18481848
struct cgroup_subsys_state *css;
18491849
struct cpuset *child;
@@ -3870,9 +3870,10 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp)
38703870
partcmd = partcmd_invalidate;
38713871
/*
38723872
* On the other hand, an invalid partition root may be transitioned
3873-
* back to a regular one.
3873+
* back to a regular one with a non-empty effective xcpus.
38743874
*/
3875-
else if (is_partition_valid(parent) && is_partition_invalid(cs))
3875+
else if (is_partition_valid(parent) && is_partition_invalid(cs) &&
3876+
!cpumask_empty(cs->effective_xcpus))
38763877
partcmd = partcmd_update;
38773878

38783879
if (partcmd >= 0) {

0 commit comments

Comments
 (0)