[PATCH 11/16] time: optimize tick_check_preferred()

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

 



tick_check_preferred() calls cpumask_equal() even if
curdev->cpumask == newdev->cpumask. Fix it.

Caught with CONFIG_DEBUG_BITMAP:
[    0.079109] Call trace:
[    0.079124]  __bitmap_check_params+0x144/0x250
[    0.079161]  tick_check_replacement+0x1a4/0x320
[    0.079203]  tick_check_new_device+0x50/0x110
[    0.079237]  clockevents_register_device+0x74/0x1c0
[    0.079268]  dummy_timer_starting_cpu+0x6c/0x80
[    0.079310]  cpuhp_invoke_callback+0x104/0x20c
[    0.079353]  cpuhp_invoke_callback_range+0x70/0xf0
[    0.079401]  notify_cpu_starting+0xac/0xcc
[    0.079434]  secondary_start_kernel+0xe4/0x154
[    0.079471]  __secondary_switched+0xa0/0xa4
[    0.079516] ---[ end trace 0000000000000000 ]---
[    0.079542] b1:	ffffbfec4703b890
[    0.079553] b2:	ffffbfec4703b890
[    0.079566] b3:	0
[    0.079576] nbits:	256
[    0.079588] start:	0
[    0.079598] off:	0
[    0.079609] Bitmap: parameters check failed
[    0.079619] include/linux/bitmap.h [419]: bitmap_equal

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

diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c
index 46789356f856..fdd5ae1a074b 100644
--- a/kernel/time/tick-common.c
+++ b/kernel/time/tick-common.c
@@ -316,9 +316,13 @@ static bool tick_check_preferred(struct clock_event_device *curdev,
 	 * Use the higher rated one, but prefer a CPU local device with a lower
 	 * rating than a non-CPU local device
 	 */
-	return !curdev ||
-		newdev->rating > curdev->rating ||
-	       !cpumask_equal(curdev->cpumask, newdev->cpumask);
+	if (!curdev || newdev->rating > curdev->rating)
+		return true;
+
+	if (newdev->cpumask == curdev->cpumask)
+		return false;
+
+	return !cpumask_equal(curdev->cpumask, newdev->cpumask);
 }
 
 /*
-- 
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