Commit 1087ad4e authored by Yury Norov's avatar Yury Norov Committed by Peter Zijlstra

sched: replace cpumask_weight with cpumask_empty where appropriate

In some places, kernel/sched code calls cpumask_weight() to check if
any bit of a given cpumask is set. We can do it more efficiently with
cpumask_empty() because cpumask_empty() stops traversing the cpumask as
soon as it finds first set bit, while cpumask_weight() counts all bits
unconditionally.
Signed-off-by: default avatarYury Norov <yury.norov@gmail.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20220210224933.379149-23-yury.norov@gmail.com
parent 3624ba7b
...@@ -8708,7 +8708,7 @@ int cpuset_cpumask_can_shrink(const struct cpumask *cur, ...@@ -8708,7 +8708,7 @@ int cpuset_cpumask_can_shrink(const struct cpumask *cur,
{ {
int ret = 1; int ret = 1;
if (!cpumask_weight(cur)) if (cpumask_empty(cur))
return ret; return ret;
ret = dl_cpuset_cpumask_can_shrink(cur, trial); ret = dl_cpuset_cpumask_can_shrink(cur, trial);
......
...@@ -74,7 +74,7 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level, ...@@ -74,7 +74,7 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
break; break;
} }
if (!cpumask_weight(sched_group_span(group))) { if (cpumask_empty(sched_group_span(group))) {
printk(KERN_CONT "\n"); printk(KERN_CONT "\n");
printk(KERN_ERR "ERROR: empty group\n"); printk(KERN_ERR "ERROR: empty group\n");
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment