mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
cgroup/cpuset: Release invalid isolated CPUs with a shrunk root partition parent
It is also reported by sashiko that there may be leakages of isolated
CPUs when a root partition parent shrinks its effective_xcpus with
isolated partition children. Leakage here means that isolated_cpus may
contain extra CPUs that are not in any isolated partitions and not boot
time isolated. Those CPUs cannot be used in any isolated partitions
anymore.
There are 2 different cases here. The effective_xcpus becomes empty and
the isolated partition should be invalidated in this case. Alternatively
some of its effective_xcpus are not in parent's effective xcpus but
still have some valid effective_xcpus left. The isolated partition can
remain valid. In both cases, the invalid isolated CPUs will have to be
released from isolated_cpus if appropriate.
Fix that by calling isolated_cpus_release() to release those isolated
CPUs from isolated_cpus.
New test cases are added to test_cpuset_prs.sh to test this.
Fixes: 11e5f407b6 ("cgroup/cpuset: Keep track of CPUs in isolated partitions")
Signed-off-by: Waiman Long <[email protected]>
Reviewed-by: Guopeng Zhang <[email protected]>
Tested-by: Guopeng Zhang <[email protected]>
Signed-off-by: Tejun Heo <[email protected]>
This commit is contained in:
+15
-1
@@ -2012,8 +2012,22 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,
|
||||
*
|
||||
* A partition error happens when parent has tasks and all
|
||||
* its effective CPUs will have to be distributed out.
|
||||
*
|
||||
* For an isolated partition with a shrunk root partition parent
|
||||
* we may need to return some or all of its isolated CPUs.
|
||||
*/
|
||||
if (nocpu || cpumask_empty(tmp->delmask)) {
|
||||
nocpu |= cpumask_empty(tmp->delmask);
|
||||
if ((parent_prs == PRS_ROOT) && (old_prs == PRS_ISOLATED)) {
|
||||
cpumask_clear(tmp->addmask);
|
||||
if (nocpu)
|
||||
cpumask_copy(tmp->addmask, cs->effective_xcpus);
|
||||
else if (!cpumask_subset(cs->effective_xcpus, parent->effective_xcpus))
|
||||
cpumask_andnot(tmp->addmask, cs->effective_xcpus,
|
||||
parent->effective_xcpus);
|
||||
if (!cpumask_empty(tmp->addmask))
|
||||
isolated_cpus_release(cs, tmp->addmask);
|
||||
}
|
||||
if (nocpu) {
|
||||
part_error = PERR_NOCPUS;
|
||||
if (is_partition_valid(cs))
|
||||
adding = cpumask_and(tmp->addmask,
|
||||
|
||||
@@ -525,6 +525,12 @@ TEST_MATRIX=(
|
||||
# its effective xcpus will be removed from isolated_cpus.
|
||||
" C1-4:P1 C3-4:P2 . . T:C3-4 . . . 0 A1:3-4|A2:3-4 A1:P1|A2:P-2 ."
|
||||
|
||||
# When a root partition parent with an isolated partition child is shrunk
|
||||
# so that its effective xcpus is no longer a superset of its child effective
|
||||
# xcpus, the invalid isolated CPUs should be removed from cpuset.cpus.isolated.
|
||||
" C1-4:P1 C3-4:P2 . . T:C4-6 . . . 0 A1:5-6|A2:4 A1:P1|A2:P2 4"
|
||||
" C1-4:P1 C1-2:P2 . . T:C4-6 . . . 0 A1:4-6|A2:4-6 A1:P1|A2:P-2 ."
|
||||
|
||||
#
|
||||
# old-A1 old-A2 old-A3 old-B1 new-A1 new-A2 new-A3 new-B1 fail ECPUs Pstate ISOLCPUS
|
||||
# ------ ------ ------ ------ ------ ------ ------ ------ ---- ----- ------ --------
|
||||
|
||||
Reference in New Issue
Block a user