Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Drivers: hv: Compare cpumasks and not their weights in init_vp_index()

The condition is supposed to check whether 'allocated_mask' got fully
exhausted, i.e. there's no free CPU on the NUMA node left so we have
to use one of the already used CPUs. As only bits which correspond
to CPUs from 'cpumask_of_node(numa_node)' get set in 'allocated_mask',
checking for the equal weights is technically correct but not obvious.
Let's compare cpumasks directly.

No functional change intended.

Suggested-by: Michael Kelley <mikelley@microsoft.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Link: https://lore.kernel.org/r/20220128103412.3033736-3-vkuznets@redhat.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>

authored by

Vitaly Kuznetsov and committed by
Wei Liu
4ee52458 de96e8a0

+1 -2
+1 -2
drivers/hv/channel_mgmt.c
··· 762 762 } 763 763 allocated_mask = &hv_context.hv_numa_map[numa_node]; 764 764 765 - if (cpumask_weight(allocated_mask) == 766 - cpumask_weight(cpumask_of_node(numa_node))) { 765 + if (cpumask_equal(allocated_mask, cpumask_of_node(numa_node))) { 767 766 /* 768 767 * We have cycled through all the CPUs in the node; 769 768 * reset the allocated map.