From: Yury Norov Date: Sun, 23 Jan 2022 18:38:56 +0000 (-0800) Subject: mm/vmstat: replace cpumask_weight with cpumask_empty where appropriate X-Git-Tag: v6.1-rc5~1137^2~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b55032f1067a02c7f80943dd118060952e8bd7ac;p=platform%2Fkernel%2Flinux-starfive.git mm/vmstat: replace cpumask_weight with cpumask_empty where appropriate mm/vmstat.c 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 Acked-by: Mike Rapoport --- diff --git a/mm/vmstat.c b/mm/vmstat.c index b75b1a64b54c..12c771e4d195 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -2042,7 +2042,7 @@ static void __init init_cpu_node_state(void) int node; for_each_online_node(node) { - if (cpumask_weight(cpumask_of_node(node)) > 0) + if (!cpumask_empty(cpumask_of_node(node))) node_set_state(node, N_CPU); } } @@ -2074,7 +2074,7 @@ static int vmstat_cpu_dead(unsigned int cpu) refresh_zone_stat_thresholds(); node_cpus = cpumask_of_node(node); - if (cpumask_weight(node_cpus) > 0) + if (!cpumask_empty(node_cpus)) return 0; node_clear_state(node, N_CPU);