[PATCH 13/16] time: optimize tick_setup_device()

From: Yury Norov
Date: Mon Jul 18 2022 - 15:30:32 EST


tick_setup_device() calls cpumask_equal(newdev->cpumask, cpumask)
even if newdev->cpumask == cpumask. Fix it.

Caught with CONFIG_DEBUG_BITMAP:
[ 0.070960] Call trace:
[ 0.070974] __bitmap_check_params+0x144/0x250
[ 0.071008] tick_setup_device+0x70/0x1a0
[ 0.071040] tick_check_new_device+0xc0/0x110
[ 0.071066] clockevents_register_device+0x74/0x1c0
[ 0.071090] clockevents_config_and_register+0x2c/0x3c
[ 0.071114] arch_timer_starting_cpu+0x170/0x470
[ 0.071147] cpuhp_invoke_callback+0x104/0x20c
[ 0.071180] cpuhp_invoke_callback_range+0x70/0xf0
[ 0.071205] notify_cpu_starting+0xac/0xcc
[ 0.071229] secondary_start_kernel+0xe4/0x154
[ 0.071259] __secondary_switched+0xa0/0xa4
[ 0.071297] ---[ end trace 0000000000000000 ]---
[ 0.071328] b1: ffffa1f27323b890
[ 0.071339] b2: ffffa1f27323b890
[ 0.071348] b3: 0
[ 0.071356] nbits: 256
[ 0.071366] start: 0
[ 0.071374] off: 0
[ 0.071383] Bitmap: parameters check failed
[ 0.071390] include/linux/bitmap.h [419]: bitmap_equal

Signed-off-by: Yury Norov <yury.norov@xxxxxxxxx>
---
kernel/time/tick-common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c
index 7205f76f8d10..7b2da8ef09ef 100644
--- a/kernel/time/tick-common.c
+++ b/kernel/time/tick-common.c
@@ -255,7 +255,7 @@ static void tick_setup_device(struct tick_device *td,
* When the device is not per cpu, pin the interrupt to the
* current cpu:
*/
- if (!cpumask_equal(newdev->cpumask, cpumask))
+ if (newdev->cpumask != cpumask && !cpumask_equal(newdev->cpumask, cpumask))
irq_set_affinity(newdev->irq, cpumask);

/*
--
2.34.1