forked from mirrors/linux
Replace `cpumask_any_and(a, b) >= nr_cpu_ids`
with the more readable `!cpumask_intersects(a, b)`.
Comparison between cpumask_any_and() and cpumask_intersects()
The cpumask_any_and() function expands using FIND_FIRST_BIT(),
resulting in a loop that iterates through each bit of the bitmask:
for (idx = 0; idx * BITS_PER_LONG < sz; idx++) {
val = (FETCH);
if (val) {
sz = min(idx * BITS_PER_LONG + __ffs(MUNGE(val)), sz);
break;
}
}
The cpumask_intersects() function expands using __bitmap_intersects(),
resulting in that the first loop iterates through each long word of the bitmask,
and the second through each bit within a long word:
unsigned int k, lim = bits/BITS_PER_LONG;
for (k = 0; k < lim; ++k)
if (bitmap1[k] & bitmap2[k])
return true;
if (bits % BITS_PER_LONG)
if ((bitmap1[k] & bitmap2[k]) & BITMAP_LAST_WORD_MASK(bits))
return true;
Conclusion: cpumask_intersects() is at least as efficient as cpumask_any_and(),
if not more so, as it typically performs fewer loops and comparisons.
Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://patch.msgid.link/20240926092623.399577-2-costa.shul@redhat.com
|
||
|---|---|---|
| .. | ||
| ge | ||
| xics | ||
| xive | ||
| 6xx-suspend.S | ||
| cpm2.c | ||
| cpm2_pic.c | ||
| cpm2_pic.h | ||
| cpm_common.c | ||
| cpm_gpio.c | ||
| dart.h | ||
| dart_iommu.c | ||
| dcr-low.S | ||
| dcr.c | ||
| ehv_pic.c | ||
| fsl_gtm.c | ||
| fsl_lbc.c | ||
| fsl_mpic_err.c | ||
| fsl_mpic_timer_wakeup.c | ||
| fsl_msi.c | ||
| fsl_msi.h | ||
| fsl_pci.c | ||
| fsl_pci.h | ||
| fsl_pmc.c | ||
| fsl_rcpm.c | ||
| fsl_rio.c | ||
| fsl_rio.h | ||
| fsl_rmu.c | ||
| fsl_soc.c | ||
| fsl_soc.h | ||
| grackle.c | ||
| i8259.c | ||
| indirect_pci.c | ||
| ipic.c | ||
| ipic.h | ||
| Kconfig | ||
| Makefile | ||
| mmio_nvram.c | ||
| mpc5xxx_clocks.c | ||
| mpic.c | ||
| mpic.h | ||
| mpic_msgr.c | ||
| mpic_msi.c | ||
| mpic_timer.c | ||
| mpic_u3msi.c | ||
| msi_bitmap.c | ||
| of_rtc.c | ||
| pmi.c | ||
| rtc_cmos_setup.c | ||
| tsi108_dev.c | ||
| tsi108_pci.c | ||
| udbg_memcons.c | ||