[PATCH 12/16] time: optimize tick_check_percpu()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tick_check_percpu() calls cpumask_equal() even if
curdev->cpumask == cpumask_of(cpu). Fix it.

Caught with CONFIG_DEBUG_BITMAP:
[    0.077622] Call trace:
[    0.077637]  __bitmap_check_params+0x144/0x250
[    0.077675]  tick_check_replacement+0xac/0x320
[    0.077716]  tick_check_new_device+0x50/0x110
[    0.077747]  clockevents_register_device+0x74/0x1c0
[    0.077779]  dummy_timer_starting_cpu+0x6c/0x80
[    0.077817]  cpuhp_invoke_callback+0x104/0x20c
[    0.077856]  cpuhp_invoke_callback_range+0x70/0xf0
[    0.077890]  notify_cpu_starting+0xac/0xcc
[    0.077921]  secondary_start_kernel+0xe4/0x154
[    0.077951]  __secondary_switched+0xa0/0xa4
[    0.077992] ---[ end trace 0000000000000000 ]---
[    0.078021] b1:	ffffbfec4703b890
[    0.078031] b2:	ffffbfec4703b890
[    0.078043] b3:	0
[    0.078052] nbits:	256
[    0.078065] start:	0
[    0.078075] off:	0
[    0.078086] Bitmap: parameters check failed
[    0.078095] include/linux/bitmap.h [419]: bitmap_equal

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

diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c
index fdd5ae1a074b..7205f76f8d10 100644
--- a/kernel/time/tick-common.c
+++ b/kernel/time/tick-common.c
@@ -290,13 +290,15 @@ static bool tick_check_percpu(struct clock_event_device *curdev,
 {
 	if (!cpumask_test_cpu(cpu, newdev->cpumask))
 		return false;
-	if (cpumask_equal(newdev->cpumask, cpumask_of(cpu)))
+	if (newdev->cpumask == cpumask_of(cpu) ||
+			cpumask_equal(newdev->cpumask, cpumask_of(cpu)))
 		return true;
 	/* Check if irq affinity can be set */
 	if (newdev->irq >= 0 && !irq_can_set_affinity(newdev->irq))
 		return false;
 	/* Prefer an existing cpu local device */
-	if (curdev && cpumask_equal(curdev->cpumask, cpumask_of(cpu)))
+	if (curdev && (curdev->cpumask == cpumask_of(cpu) ||
+			cpumask_equal(curdev->cpumask, cpumask_of(cpu))))
 		return false;
 	return true;
 }
-- 
2.34.1




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux