From: Ashok Raj We need to hold call-lock when updating cpu-online-map to ensure the newly upcoming cpu is excluded in an ongoing smp_call_function. Signed-off-by: Ashok Raj Acked-by: Shaohua Li Signed-off-by: Andrew Morton --- arch/i386/kernel/smp.c | 10 ++++++++++ arch/i386/kernel/smpboot.c | 10 ++++++++++ include/asm-i386/smp.h | 2 ++ 3 files changed, 22 insertions(+) diff -puN arch/i386/kernel/smpboot.c~i386-hold-call_lock-when-updating-cpu_online_map arch/i386/kernel/smpboot.c --- 25/arch/i386/kernel/smpboot.c~i386-hold-call_lock-when-updating-cpu_online_map 2005-06-07 20:58:52.000000000 -0700 +++ 25-akpm/arch/i386/kernel/smpboot.c 2005-06-07 20:58:52.000000000 -0700 @@ -454,7 +454,17 @@ static void __init start_secondary(void */ local_flush_tlb(); + /* + * We need to hold call_lock, so there is no inconsistency + * between the time smp_call_function() determines number of + * IPI receipients, and the time when the determination is made + * for which cpus receive the IPI. Holding this + * lock helps us to not include this cpu in a currently in progress + * smp_call_function(). + */ + lock_ipi_call_lock(); cpu_set(smp_processor_id(), cpu_online_map); + unlock_ipi_call_lock(); /* We can take interrupts now: we're officially "up". */ local_irq_enable(); diff -puN arch/i386/kernel/smp.c~i386-hold-call_lock-when-updating-cpu_online_map arch/i386/kernel/smp.c --- 25/arch/i386/kernel/smp.c~i386-hold-call_lock-when-updating-cpu_online_map 2005-06-07 20:58:52.000000000 -0700 +++ 25-akpm/arch/i386/kernel/smp.c 2005-06-07 20:58:52.000000000 -0700 @@ -495,6 +495,16 @@ struct call_data_struct { int wait; }; +void lock_ipi_call_lock(void) +{ + spin_lock_irq(&call_lock); +} + +void unlock_ipi_call_lock(void) +{ + spin_unlock_irq(&call_lock); +} + static struct call_data_struct * call_data; /* diff -puN include/asm-i386/smp.h~i386-hold-call_lock-when-updating-cpu_online_map include/asm-i386/smp.h --- 25/include/asm-i386/smp.h~i386-hold-call_lock-when-updating-cpu_online_map 2005-06-07 20:58:52.000000000 -0700 +++ 25-akpm/include/asm-i386/smp.h 2005-06-07 20:58:52.000000000 -0700 @@ -42,6 +42,8 @@ extern void smp_message_irq(int cpl, voi extern void smp_invalidate_rcv(void); /* Process an NMI */ extern void (*mtrr_hook) (void); extern void zap_low_mappings (void); +extern void lock_ipi_call_lock(void); +extern void unlock_ipi_call_lock(void); #define MAX_APICID 256 extern u8 x86_cpu_to_apicid[]; _