Skip to content

Commit 311a1bd

Browse files
Waiman-Longhtejun
authored andcommitted
cgroup/cpuset: Clear effective_xcpus on cpus_allowed clearing only if cpus.exclusive not set
Commit e2ffe50 ("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: e2ffe50 ("cgroup/cpuset: Add cpuset.cpus.exclusive for v2") Cc: [email protected] # v6.7+ Reported-by: Chen Ridong <[email protected]> Signed-off-by: Waiman Long <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 959ab63 commit 311a1bd

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

kernel/cgroup/cpuset.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2525,7 +2525,8 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
25252525
*/
25262526
if (!*buf) {
25272527
cpumask_clear(trialcs->cpus_allowed);
2528-
cpumask_clear(trialcs->effective_xcpus);
2528+
if (cpumask_empty(trialcs->exclusive_cpus))
2529+
cpumask_clear(trialcs->effective_xcpus);
25292530
} else {
25302531
retval = cpulist_parse(buf, trialcs->cpus_allowed);
25312532
if (retval < 0)

0 commit comments

Comments
 (0)