Skip to content

Commit

Permalink
clocksource: replace cpumask_weight with cpumask_empty in clocksource.c
Browse files Browse the repository at this point in the history
clocksource_verify_percpu() 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 <[email protected]>
  • Loading branch information
YuryNorov committed Jun 3, 2022
1 parent 99248e3 commit 95e3a97
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/time/clocksource.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ void clocksource_verify_percpu(struct clocksource *cs)
cpus_read_lock();
preempt_disable();
clocksource_verify_choose_cpus();
if (cpumask_weight(&cpus_chosen) == 0) {
if (cpumask_empty(&cpus_chosen)) {
preempt_enable();
cpus_read_unlock();
pr_warn("Not enough CPUs to check clocksource '%s'.\n", cs->name);
Expand Down

0 comments on commit 95e3a97

Please sign in to comment.