]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
33ef6924260669efd9c5caec21bdaabfc8f5c395
[thirdparty/kernel/stable-queue.git] /
1 From 311a1bdc44a8e06024df4fd3392be0dfc8298655 Mon Sep 17 00:00:00 2001
2 From: Waiman Long <longman@redhat.com>
3 Date: Sun, 4 Aug 2024 21:30:16 -0400
4 Subject: cgroup/cpuset: Clear effective_xcpus on cpus_allowed clearing only if cpus.exclusive not set
5
6 From: Waiman Long <longman@redhat.com>
7
8 commit 311a1bdc44a8e06024df4fd3392be0dfc8298655 upstream.
9
10 Commit e2ffe502ba45 ("cgroup/cpuset: Add cpuset.cpus.exclusive for
11 v2") adds a user writable cpuset.cpus.exclusive file for setting
12 exclusive CPUs to be used for the creation of partitions. Since then
13 effective_xcpus depends on both the cpuset.cpus and cpuset.cpus.exclusive
14 setting. If cpuset.cpus.exclusive is set, effective_xcpus will depend
15 only on cpuset.cpus.exclusive. When it is not set, effective_xcpus
16 will be set according to the cpuset.cpus value when the cpuset becomes
17 a valid partition root.
18
19 When cpuset.cpus is being cleared by the user, effective_xcpus should
20 only be cleared when cpuset.cpus.exclusive is not set. However, that
21 is not currently the case.
22
23 # cd /sys/fs/cgroup/
24 # mkdir test
25 # echo +cpuset > cgroup.subtree_control
26 # cd test
27 # echo 3 > cpuset.cpus.exclusive
28 # cat cpuset.cpus.exclusive.effective
29 3
30 # echo > cpuset.cpus
31 # cat cpuset.cpus.exclusive.effective // was cleared
32
33 Fix it by clearing effective_xcpus only if cpuset.cpus.exclusive is
34 not set.
35
36 Fixes: e2ffe502ba45 ("cgroup/cpuset: Add cpuset.cpus.exclusive for v2")
37 Cc: stable@vger.kernel.org # v6.7+
38 Reported-by: Chen Ridong <chenridong@huawei.com>
39 Signed-off-by: Waiman Long <longman@redhat.com>
40 Signed-off-by: Tejun Heo <tj@kernel.org>
41 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
42 ---
43 kernel/cgroup/cpuset.c | 3 ++-
44 1 file changed, 2 insertions(+), 1 deletion(-)
45
46 --- a/kernel/cgroup/cpuset.c
47 +++ b/kernel/cgroup/cpuset.c
48 @@ -2474,7 +2474,8 @@ static int update_cpumask(struct cpuset
49 */
50 if (!*buf) {
51 cpumask_clear(trialcs->cpus_allowed);
52 - cpumask_clear(trialcs->effective_xcpus);
53 + if (cpumask_empty(trialcs->exclusive_cpus))
54 + cpumask_clear(trialcs->effective_xcpus);
55 } else {
56 retval = cpulist_parse(buf, trialcs->cpus_allowed);
57 if (retval < 0)