Commit e26aaac5 authored by Waiman Long's avatar Waiman Long Committed by Chen Ridong
Browse files

cgroup/cpuset: Prevent leakage of isolated CPUs into sched domains

mainline inclusion
from mainline-v6.13-rc7
commit 9b496a8bbed9cc292b0dfd796f38ec58b6d0375f
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBJ6GQ

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=9b496a8bbed9cc292b0dfd796f38ec58b6d0375f



----------------------------------------------------------------------

Isolated CPUs are not allowed to be used in a non-isolated partition.
The only exception is the top cpuset which is allowed to contain boot
time isolated CPUs.

Commit ccac8e8de99c ("cgroup/cpuset: Fix remote root partition creation
problem") introduces a simplified scheme of including only partition
roots in sched domain generation. However, it does not properly account
for this exception case. This can result in leakage of isolated CPUs
into a sched domain.

Fix it by making sure that isolated CPUs are excluded from the top
cpuset before generating sched domains.

Also update the way the boot time isolated CPUs are handled in
test_cpuset_prs.sh to make sure that those isolated CPUs are really
isolated instead of just skipping them in the tests.

Fixes: ccac8e8de99c ("cgroup/cpuset: Fix remote root partition creation problem")
Signed-off-by: default avatarWaiman Long <longman@redhat.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>

Conflicts:
	tools/testing/selftests/cgroup/test_cpuset_prs.sh
[selftests conflicts, did not apply for hulk]
Signed-off-by: default avatarChen Ridong <chenridong@huawei.com>
parent 6a2a7743
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -1247,6 +1247,14 @@ static int generate_sched_domains(cpumask_var_t **domains,
	 */
	if (cgrpv2) {
		for (i = 0; i < ndoms; i++) {
			/*
			 * The top cpuset may contain some boot time isolated
			 * CPUs that need to be excluded from the sched domain.
			 */
			if (csa[i] == &top_cpuset)
				cpumask_and(doms[i], csa[i]->effective_cpus,
					    housekeeping_cpumask(HK_TYPE_DOMAIN));
			else
				cpumask_copy(doms[i], csa[i]->effective_cpus);
			if (dattr)
				dattr[i] = SD_ATTR_INIT;