Skip to content

Commit b55032f

Browse files
committed
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 <[email protected]> Acked-by: Mike Rapoport <[email protected]>
1 parent 95e3a97 commit b55032f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mm/vmstat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2042,7 +2042,7 @@ static void __init init_cpu_node_state(void)
20422042
int node;
20432043

20442044
for_each_online_node(node) {
2045-
if (cpumask_weight(cpumask_of_node(node)) > 0)
2045+
if (!cpumask_empty(cpumask_of_node(node)))
20462046
node_set_state(node, N_CPU);
20472047
}
20482048
}
@@ -2074,7 +2074,7 @@ static int vmstat_cpu_dead(unsigned int cpu)
20742074

20752075
refresh_zone_stat_thresholds();
20762076
node_cpus = cpumask_of_node(node);
2077-
if (cpumask_weight(node_cpus) > 0)
2077+
if (!cpumask_empty(node_cpus))
20782078
return 0;
20792079

20802080
node_clear_state(node, N_CPU);

0 commit comments

Comments
 (0)