diff mbox series

[13/16] time: optimize tick_setup_device()

Message ID 20220718192844.1805158-14-yury.norov@gmail.com (mailing list archive)
State New
Headers show
Series Introduce DEBUG_BITMAP config option and bitmap_check_params() | expand

Commit Message

Yury Norov July 18, 2022, 7:28 p.m. UTC
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@gmail.com>
---
 kernel/time/tick-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Peter Zijlstra July 18, 2022, 9:35 p.m. UTC | #1
On Mon, Jul 18, 2022 at 12:28:41PM -0700, Yury Norov wrote:
>  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);

This is again making a slow path harder to read for now benefit.
diff mbox series

Patch

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);
 
 	/*