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

cgroup/cpuset: Clear effective_xcpus on cpus_allowed clearing only if cpus.exclusive not set

mainline inclusion
from mainline-v6.11-rc5
commit 311a1bdc44a8e06024df4fd3392be0dfc8298655
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAOPW2

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



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

Commit e2ffe502ba45 ("cgroup/cpuset: Add cpuset.cpus.exclusive for
v2") adds a user writable cpuset.cpus.exclusive file for setting
exclusive CPUs to be used for the creation of partitions. Since then
effective_xcpus depends on both the cpuset.cpus and cpuset.cpus.exclusive
setting. If cpuset.cpus.exclusive is set, effective_xcpus will depend
only on cpuset.cpus.exclusive.  When it is not set, effective_xcpus
will be set according to the cpuset.cpus value when the cpuset becomes
a valid partition root.

When cpuset.cpus is being cleared by the user, effective_xcpus should
only be cleared when cpuset.cpus.exclusive is not set. However, that
is not currently the case.

  # cd /sys/fs/cgroup/
  # mkdir test
  # echo +cpuset > cgroup.subtree_control
  # cd test
  # echo 3 > cpuset.cpus.exclusive
  # cat cpuset.cpus.exclusive.effective
  3
  # echo > cpuset.cpus
  # cat cpuset.cpus.exclusive.effective // was cleared

Fix it by clearing effective_xcpus only if cpuset.cpus.exclusive is
not set.

Fixes: 1e0b07ac ("cgroup/cpuset: Add cpuset.cpus.exclusive for v2")
Cc: stable@vger.kernel.org # v6.7+
Reported-by: default avatarChen Ridong <chenridong@huawei.com>
Signed-off-by: default avatarWaiman Long <longman@redhat.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarChen Ridong <chenridong@huawei.com>
parent 54cbde3b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2535,6 +2535,7 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
	 */
	if (!*buf) {
		cpumask_clear(trialcs->cpus_allowed);
		if (cpumask_empty(trialcs->exclusive_cpus))
			cpumask_clear(trialcs->effective_xcpus);
	} else {
		retval = cpulist_parse(buf, trialcs->cpus_allowed);