]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
clocksource: Replace cpumask_weight() with cpumask_empty()
authorYury Norov <yury.norov@gmail.com>
Thu, 10 Feb 2022 22:49:07 +0000 (14:49 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Mar 2025 11:47:20 +0000 (12:47 +0100)
[ Upstream commit 8afbcaf8690dac19ebf570a4e4fef9c59c75bf8e ]

clocksource_verify_percpu() calls cpumask_weight() to check if any bit of a
given cpumask is set.

This can be done 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: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20220210224933.379149-24-yury.norov@gmail.com
Stable-dep-of: 6bb05a33337b ("clocksource: Use migrate_disable() to avoid calling get_random_u32() in atomic context")
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/time/clocksource.c

index e44fb1e12a2816ac0b535c14c2a2b6514813636b..658b90755dd723f182963942637305c5786c3ff5 100644 (file)
@@ -338,7 +338,7 @@ static 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);