Commit 1eecd73c authored by Andi Kleen's avatar Andi Kleen Committed by Linus Torvalds

[PATCH] x86_64: Fix race in TSC synchronization

Plug a race in TSC synchronization

We need to do tsc_sync_wait() before the CPU is set online to prevent
multiple CPUs from doing it in parallel - which won't work because TSC
sync has global unprotected state.
Signed-off-by: default avatarAndi Kleen <ak@suse.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 5e5ec104
...@@ -492,6 +492,14 @@ void __cpuinit start_secondary(void) ...@@ -492,6 +492,14 @@ void __cpuinit start_secondary(void)
*/ */
set_cpu_sibling_map(smp_processor_id()); set_cpu_sibling_map(smp_processor_id());
/*
* Wait for TSC sync to not schedule things before.
* We still process interrupts, which could see an inconsistent
* time in that window unfortunately.
* Do this here because TSC sync has global unprotected state.
*/
tsc_sync_wait();
/* /*
* We need to hold call_lock, so there is no inconsistency * We need to hold call_lock, so there is no inconsistency
* between the time smp_call_function() determines number of * between the time smp_call_function() determines number of
...@@ -509,13 +517,6 @@ void __cpuinit start_secondary(void) ...@@ -509,13 +517,6 @@ void __cpuinit start_secondary(void)
per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE; per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
unlock_ipi_call_lock(); unlock_ipi_call_lock();
mb();
/* Wait for TSC sync to not schedule things before.
We still process interrupts, which could see an inconsistent
time in that window unfortunately. */
tsc_sync_wait();
cpu_idle(); cpu_idle();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment