diff options
author | Yury Norov <yury.norov@gmail.com> | 2022-02-10 14:49:06 -0800 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2022-02-16 15:57:53 +0100 |
commit | 1087ad4e3f88c474b8134a482720782922bf3fdf (patch) | |
tree | 93a95570454dd39c349d0e99bf1aab4408e6e218 /kernel/sched | |
parent | 3624ba7b5e2acc02b01301ea5fd3534971eb9896 (diff) |
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: Yury Norov <yury.norov@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20220210224933.379149-23-yury.norov@gmail.com
Diffstat (limited to 'kernel/sched')
-rw-r--r-- | kernel/sched/core.c | 2 | ||||
-rw-r--r-- | kernel/sched/topology.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 1d863d7f6ad7..c620aab27acf 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -8708,7 +8708,7 @@ int cpuset_cpumask_can_shrink(const struct cpumask *cur, { int ret = 1; - if (!cpumask_weight(cur)) + if (cpumask_empty(cur)) return ret; ret = dl_cpuset_cpumask_can_shrink(cur, trial); diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index e6cd55951304..1c84b48def20 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -74,7 +74,7 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level, break; } - if (!cpumask_weight(sched_group_span(group))) { + if (cpumask_empty(sched_group_span(group))) { printk(KERN_CONT "\n"); printk(KERN_ERR "ERROR: empty group\n"); break; |