Skip to contentSkip to conversation

cpuset: Fix the bug that subpart_cpus updated wrongly in update_cpumask()

PATCH Applied Tianchen Ding 3 participants 4 messages Jan 18, 2022 – Jan 26, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpuset: Fix the bug that subpart_cpus updated wrongly in update_cpumask()

subparts_cpus should be limited as a subset of cpus_allowed, but it is updated wrongly by using cpumask_andnot(). Use cpumask_and() instead to fix it.

Fixes ee8dde0cd2ce ("cpuset: Add new v2 cpuset.sched.partition flag")
---
 kernel/cgroup/cpuset.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/cgroup/cpuset.c +1 -2
index bb3531e7fda7..804ff5738c5f 100644
@@ -1635,8 +1635,7 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
 	 * Make sure that subparts_cpus is a subset of cpus_allowed.
 	 */
 	if (cs->nr_subparts_cpus) {
-		cpumask_andnot(cs->subparts_cpus, cs->subparts_cpus,
-			       cs->cpus_allowed);
+		cpumask_and(cs->subparts_cpus, cs->subparts_cpus, cs->cpus_allowed);
 		cs->nr_subparts_cpus = cpumask_weight(cs->subparts_cpus);
 	}
 	spin_unlock_irq(&callback_lock);
Signature · 1 line
2.33.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Tianchen Ding

subparts_cpus should be limited as a subset of cpus_allowed, but it is updated wrongly by using cpumask_andnot(). Use cpumask_and() instead to fix it.

Fixes ee8dde0cd2ce ("cpuset: Add new v2 cpuset.sched.partition flag")
---
  kernel/cgroup/cpuset.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
kernel/cgroup/cpuset.c +0 -0
index bb3531e7fda7..804ff5738c5f 100644

kernel/cgroup/cpuset.c static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs, · line 1641

Quoted 9 lines
kernel/cgroup/cpuset.c +1 -2
@@ -1635,8 +1635,7 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
  	 * Make sure that subparts_cpus is a subset of cpus_allowed.
  	 */
  	if (cs->nr_subparts_cpus) {
-		cpumask_andnot(cs->subparts_cpus, cs->subparts_cpus,
-			       cs->cpus_allowed);
+		cpumask_and(cs->subparts_cpus, cs->subparts_cpus, cs->cpus_allowed);
  		cs->nr_subparts_cpus = cpumask_weight(cs->subparts_cpus);
  	}
  	spin_unlock_irq(&callback_lock);

Thanks for the fix.

#2 lore raw
In reply to Tianchen Ding

Ping~
Any maintainer take a look?

Quoted 24 lines · Tianchen Ding

subparts_cpus should be limited as a subset of cpus_allowed, but it is updated wrongly by using cpumask_andnot(). Use cpumask_and() instead to fix it.

Fixes ee8dde0cd2ce ("cpuset: Add new v2 cpuset.sched.partition flag")
---
  kernel/cgroup/cpuset.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
kernel/cgroup/cpuset.c +1 -2
index bb3531e7fda7..804ff5738c5f 100644
@@ -1635,8 +1635,7 @@ static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
  	 * Make sure that subparts_cpus is a subset of cpus_allowed.
  	 */
  	if (cs->nr_subparts_cpus) {
-		cpumask_andnot(cs->subparts_cpus, cs->subparts_cpus,
-			       cs->cpus_allowed);
+		cpumask_and(cs->subparts_cpus, cs->subparts_cpus, cs->cpus_allowed);
  		cs->nr_subparts_cpus = cpumask_weight(cs->subparts_cpus);
  	}
  	spin_unlock_irq(&callback_lock);