Skip to contentSkip to conversation

cgroup/cpuset: drop useless cpumask_empty() in compute_effective_exclusive_cpumask()

PATCH Applied Yury Norov 3 participants 3 messages May 8, 2025 – May 9, 2025

Subsystems (2)
lore
Share & tools
lore

Yury Norov

author
#0 lore raw

PATCH 1/1 cgroup/cpuset: drop useless cpumask_empty() in compute_effective_exclusive_cpumask()

Empty cpumasks can't intersect with any others. Therefore, testing for non-emptyness is useless.

---
 kernel/cgroup/cpuset.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
kernel/cgroup/cpuset.c +2 -4
index 306b60430091..df308072f268 100644
@@ -1388,14 +1388,12 @@ static int compute_effective_exclusive_cpumask(struct cpuset *cs,
 		if (sibling == cs)
 			continue;
 
-		if (!cpumask_empty(sibling->exclusive_cpus) &&
-		    cpumask_intersects(xcpus, sibling->exclusive_cpus)) {
+		if (cpumask_intersects(xcpus, sibling->exclusive_cpus)) {
 			cpumask_andnot(xcpus, xcpus, sibling->exclusive_cpus);
 			retval++;
 			continue;
 		}
-		if (!cpumask_empty(sibling->effective_xcpus) &&
-		    cpumask_intersects(xcpus, sibling->effective_xcpus)) {
+		if (cpumask_intersects(xcpus, sibling->effective_xcpus)) {
 			cpumask_andnot(xcpus, xcpus, sibling->effective_xcpus);
 			retval++;
 		}
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Yury Norov

Empty cpumasks can't intersect with any others. Therefore, testing for non-emptyness is useless.

---
  kernel/cgroup/cpuset.c | 6 ++----
  1 file changed, 2 insertions(+), 4 deletions(-)
kernel/cgroup/cpuset.c +1 -2
index 306b60430091..df308072f268 100644
@@ -1388,14 +1388,12 @@ static int compute_effective_exclusive_cpumask(struct cpuset *cs,
  		if (sibling == cs)
  			continue;
 
-		if (!cpumask_empty(sibling->exclusive_cpus) &&
-		    cpumask_intersects(xcpus, sibling->exclusive_cpus)) {
+		if (cpumask_intersects(xcpus, sibling->exclusive_cpus)) {

kernel/cgroup/cpuset.c static int compute_effective_exclusive_cpumask(struct cpuset *cs, · line 1399

Quoted 10 lines
kernel/cgroup/cpuset.c +1 -2
  			cpumask_andnot(xcpus, xcpus, sibling->exclusive_cpus);
  			retval++;
  			continue;
  		}
-		if (!cpumask_empty(sibling->effective_xcpus) &&
-		    cpumask_intersects(xcpus, sibling->effective_xcpus)) {
+		if (cpumask_intersects(xcpus, sibling->effective_xcpus)) {
  			cpumask_andnot(xcpus, xcpus, sibling->effective_xcpus);
  			retval++;
  		}

You are right. Non-emptiness check is useless.