Skip to content

Commit 5596fe3

Browse files
dcuiKAGA-KOKO
authored andcommitted
tick/broadcast: Use for_each_cpu() specially on UP kernels
for_each_cpu() unintuitively reports CPU0 as set independent of the actual cpumask content on UP kernels. This causes an unexpected PIT interrupt storm on a UP kernel running in an SMP virtual machine on Hyper-V, and as a result, the virtual machine can suffer from a strange random delay of 1~20 minutes during boot-up, and sometimes it can hang forever. Protect if by checking whether the cpumask is empty before entering the for_each_cpu() loop. [ tglx: Use !IS_ENABLED(CONFIG_SMP) instead of #ifdeffery ] Signed-off-by: Dexuan Cui <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: Josh Poulson <[email protected]> Cc: "Michael Kelley (EOSG)" <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: [email protected] Cc: Rakib Mullick <[email protected]> Cc: Jork Loeser <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Andrew Morton <[email protected]> Cc: KY Srinivasan <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Alexey Dobriyan <[email protected]> Cc: Dmitry Vyukov <[email protected]> Link: https://lkml.kernel.org/r/KL1P15301MB000678289FE55BA365B3279ABF990@KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM Link: https://lkml.kernel.org/r/KL1P15301MB0006FA63BC22BEB64902EAA0BF930@KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM
1 parent 67b8d5c commit 5596fe3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

kernel/time/tick-broadcast.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,14 @@ static void tick_handle_oneshot_broadcast(struct clock_event_device *dev)
612612
now = ktime_get();
613613
/* Find all expired events */
614614
for_each_cpu(cpu, tick_broadcast_oneshot_mask) {
615+
/*
616+
* Required for !SMP because for_each_cpu() reports
617+
* unconditionally CPU0 as set on UP kernels.
618+
*/
619+
if (!IS_ENABLED(CONFIG_SMP) &&
620+
cpumask_empty(tick_broadcast_oneshot_mask))
621+
break;
622+
615623
td = &per_cpu(tick_cpu_device, cpu);
616624
if (td->evtdev->next_event <= now) {
617625
cpumask_set_cpu(cpu, tmpmask);

0 commit comments

Comments
 (0)