[PATCH 6/7] x86: Separate generic cpu disabling code from APIC writes in cpu_disable

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Alex Nixon
Date: Thursday, August 21, 2008 - 11:04 am

It allows paravirt implementations of cpu_disable to share the cpu_disable_common code, without having to take on board APIC writes, which may not be appropriate.

Signed-off-by: Alex Nixon <alex.nixon@citrix.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Ingo Molnar <mingo@elte.hu>
---
 arch/x86/kernel/smpboot.c |   40 +++++++++++++++++++++++-----------------
 include/asm-x86/smp.h     |    1 +
 2 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 83e9591..ccb3b12 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1340,25 +1340,9 @@ static void __ref remove_cpu_from_maps(int cpu)
 	numa_remove_cpu(cpu);
 }
 
-int native_cpu_disable(void)
+void cpu_disable_common(void)
 {
 	int cpu = smp_processor_id();
-
-	/*
-	 * Perhaps use cpufreq to drop frequency, but that could go
-	 * into generic code.
-	 *
-	 * We won't take down the boot processor on i386 due to some
-	 * interrupts only being able to be serviced by the BSP.
-	 * Especially so if we're not using an IOAPIC	-zwane
-	 */
-	if (cpu == 0)
-		return -EBUSY;
-
-	if (nmi_watchdog == NMI_LOCAL_APIC)
-		stop_apic_nmi_watchdog(NULL);
-	clear_local_APIC();
-
 	/*
 	 * HACK:
 	 * Allow any queued timer interrupts to get serviced
@@ -1376,6 +1360,28 @@ int native_cpu_disable(void)
 	remove_cpu_from_maps(cpu);
 	unlock_vector_lock();
 	fixup_irqs(cpu_online_map);
+}
+
+int native_cpu_disable(void)
+{
+	int cpu = smp_processor_id();
+
+	/*
+	 * Perhaps use cpufreq to drop frequency, but that could go
+	 * into generic code.
+	 *
+	 * We won't take down the boot processor on i386 due to some
+	 * interrupts only being able to be serviced by the BSP.
+	 * Especially so if we're not using an IOAPIC	-zwane
+	 */
+	if (cpu == 0)
+		return -EBUSY;
+
+	if (nmi_watchdog == NMI_LOCAL_APIC)
+		stop_apic_nmi_watchdog(NULL);
+	clear_local_APIC();
+
+	cpu_disable_common();
 	return 0;
 }
 
diff --git a/include/asm-x86/smp.h b/include/asm-x86/smp.h
index fd2a070..bff3fa6 100644
--- a/include/asm-x86/smp.h
+++ b/include/asm-x86/smp.h
@@ -109,6 +109,7 @@ static inline void arch_send_call_function_ipi(cpumask_t mask)
 	smp_ops.send_call_func_ipi(mask);
 }
 
+void cpu_disable_common(void);
 void native_smp_prepare_boot_cpu(void);
 void native_smp_prepare_cpus(unsigned int max_cpus);
 void native_smp_cpus_done(unsigned int max_cpus);
-- 
1.5.4.3

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 3/7] Xen: Add Xen implementation of wbinvd_halt, Alex Nixon, (Thu Aug 21, 11:04 am)
[PATCH 4/7] x86_32: Clean up play_dead., Alex Nixon, (Thu Aug 21, 11:04 am)
[PATCH 6/7] x86: Separate generic cpu disabling code from ..., Alex Nixon, (Thu Aug 21, 11:04 am)
[PATCH 7/7] Xen: Implement CPU hotplugging, Alex Nixon, (Thu Aug 21, 11:04 am)
Re: [PATCH 2/7] x86/paravirt: Add paravirt hook for wbinv ..., Jeremy Fitzhardinge, (Thu Aug 21, 11:16 am)
Re: [PATCH 1/7] x86/paravirt: Add hooks for CPU hotplugging, Jeremy Fitzhardinge, (Thu Aug 21, 11:19 am)
Re: [PATCH 7/7] Xen: Implement CPU hotplugging, Jeremy Fitzhardinge, (Thu Aug 21, 11:37 am)