[PATCH 65/79] [PATCH] integrate start_secondary

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Glauber de Oliveira Costa
Date: Wednesday, March 19, 2008 - 10:26 am

From: Glauber Costa <gcosta@redhat.com>

It now looks the same between architectures, so we
merge it in smpboot.c. Minor differences goes inside
an ifdef

Signed-off-by: Glauber Costa <gcosta@redhat.com>
---
 arch/x86/kernel/smpboot.c    |   86 +++++++++++++++++++++++++++++++++++++++++-
 arch/x86/kernel/smpboot_32.c |   75 ------------------------------------
 arch/x86/kernel/smpboot_64.c |   63 ------------------------------
 3 files changed, 85 insertions(+), 139 deletions(-)

diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 69c1796..a36ae27 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -17,6 +17,7 @@
 #include <asm/tlbflush.h>
 #include <asm/mtrr.h>
 #include <asm/nmi.h>
+#include <asm/vmi.h>
 #include <linux/mc146818rtc.h>
 
 #include <mach_apic.h>
@@ -229,6 +230,90 @@ void __cpuinit smp_callin(void)
 	cpu_set(cpuid, cpu_callin_map);
 }
 
+/*
+ * Activate a secondary processor.
+ */
+void __cpuinit start_secondary(void *unused)
+{
+	/*
+	 * Don't put *anything* before cpu_init(), SMP booting is too
+	 * fragile that we want to limit the things done here to the
+	 * most necessary things.
+	 */
+#ifdef CONFIG_VMI
+	vmi_bringup();
+#endif
+	cpu_init();
+	preempt_disable();
+	smp_callin();
+
+	/* otherwise gcc will move up smp_processor_id before the cpu_init */
+	barrier();
+	/*
+	 * Check TSC synchronization with the BP:
+	 */
+	check_tsc_sync_target();
+
+	if (nmi_watchdog == NMI_IO_APIC) {
+		disable_8259A_irq(0);
+		enable_NMI_through_LVT0();
+		enable_8259A_irq(0);
+	}
+
+	/* This must be done before setting cpu_online_map */
+	set_cpu_sibling_map(raw_smp_processor_id());
+	wmb();
+
+	/*
+	 * We need to hold call_lock, so there is no inconsistency
+	 * between the time smp_call_function() determines number of
+	 * IPI recipients, 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();
+#ifdef CONFIG_X86_64
+	spin_lock(&vector_lock);
+
+	/* Setup the per cpu irq handling data structures */
+	__setup_vector_irq(smp_processor_id());
+	/*
+	 * Allow the master to continue.
+	 */
+	spin_unlock(&vector_lock);
+#endif
+	cpu_set(smp_processor_id(), cpu_online_map);
+	unlock_ipi_call_lock();
+	per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
+
+	setup_secondary_clock();
+
+	wmb();
+	cpu_idle();
+}
+
+#ifdef CONFIG_X86_32
+/*
+ * Everything has been set up for the secondary
+ * CPUs - they just need to reload everything
+ * from the task structure
+ * This function must not return.
+ */
+void __devinit initialize_secondary(void)
+{
+	/*
+	 * We don't actually need to load the full TSS,
+	 * basically just the stack pointer and the ip.
+	 */
+
+	asm volatile(
+		"movl %0,%%esp\n\t"
+		"jmp *%1"
+		:
+		:"m" (current->thread.sp), "m" (current->thread.ip));
+}
+#endif
 
 static void __cpuinit smp_apply_quirks(struct cpuinfo_x86 *c)
 {
@@ -533,7 +618,6 @@ wakeup_secondary_cpu(int logical_apicid, unsigned long start_eip)
 }
 #endif	/* WAKE_SECONDARY_VIA_NMI */
 
-extern void start_secondary(void *unused);
 #ifdef WAKE_SECONDARY_VIA_INIT
 static int __devinit
 wakeup_secondary_cpu(int phys_apicid, unsigned long start_eip)
diff --git a/arch/x86/kernel/smpboot_32.c b/arch/x86/kernel/smpboot_32.c
index e82eeb2..77b045c 100644
--- a/arch/x86/kernel/smpboot_32.c
+++ b/arch/x86/kernel/smpboot_32.c
@@ -80,81 +80,6 @@ extern void unmap_cpu_to_logical_apicid(int cpu);
 /* State of each CPU. */
 DEFINE_PER_CPU(int, cpu_state) = { 0 };
 
-extern void smp_callin(void);
-
-/*
- * Activate a secondary processor.
- */
-void __cpuinit start_secondary(void *unused)
-{
-	/*
-	 * Don't put *anything* before cpu_init(), SMP booting is too
-	 * fragile that we want to limit the things done here to the
-	 * most necessary things.
-	 */
-#ifdef CONFIG_VMI
-	vmi_bringup();
-#endif
-	cpu_init();
-	preempt_disable();
-	smp_callin();
-
-	/* otherwise gcc will move up smp_processor_id before the cpu_init */
-	barrier();
-	/*
-	 * Check TSC synchronization with the BP:
-	 */
-	check_tsc_sync_target();
-
-	if (nmi_watchdog == NMI_IO_APIC) {
-		disable_8259A_irq(0);
-		enable_NMI_through_LVT0();
-		enable_8259A_irq(0);
-	}
-
-	/* This must be done before setting cpu_online_map */
-	set_cpu_sibling_map(raw_smp_processor_id());
-	wmb();
-
-	/*
-	 * We need to hold call_lock, so there is no inconsistency
-	 * between the time smp_call_function() determines number of
-	 * IPI recipients, 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();
-	per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
-
-	setup_secondary_clock();
-
-	wmb();
-	cpu_idle();
-}
-
-/*
- * Everything has been set up for the secondary
- * CPUs - they just need to reload everything
- * from the task structure
- * This function must not return.
- */
-void __devinit initialize_secondary(void)
-{
-	/*
-	 * We don't actually need to load the full TSS,
-	 * basically just the stack pointer and the ip.
-	 */
-
-	asm volatile(
-		"movl %0,%%esp\n\t"
-		"jmp *%1"
-		:
-		:"m" (current->thread.sp),"m" (current->thread.ip));
-}
-
 #ifdef CONFIG_HOTPLUG_CPU
 void cpu_exit_clear(void)
 {
diff --git a/arch/x86/kernel/smpboot_64.c b/arch/x86/kernel/smpboot_64.c
index 71f13b1..60cd8cf 100644
--- a/arch/x86/kernel/smpboot_64.c
+++ b/arch/x86/kernel/smpboot_64.c
@@ -71,69 +71,6 @@ int smp_threads_ready;
 /* State of each CPU */
 DEFINE_PER_CPU(int, cpu_state) = { 0 };
 
-extern void smp_callin(void);
-/*
- * Setup code on secondary processor (after comming out of the trampoline)
- */
-void __cpuinit start_secondary(void)
-{
-	/*
-	 * Dont put anything before smp_callin(), SMP
-	 * booting is too fragile that we want to limit the
-	 * things done here to the most necessary things.
-	 */
-	cpu_init();
-	preempt_disable();
-	smp_callin();
-
-	/* otherwise gcc will move up the smp_processor_id before the cpu_init */
-	barrier();
-
-	/*
-  	 * Check TSC sync first:
- 	 */
-	check_tsc_sync_target();
-
-	if (nmi_watchdog == NMI_IO_APIC) {
-		disable_8259A_irq(0);
-		enable_NMI_through_LVT0();
-		enable_8259A_irq(0);
-	}
-
-	/*
-	 * The sibling maps must be set before turing the online map on for
-	 * this cpu
-	 */
-	set_cpu_sibling_map(smp_processor_id());
-
-	/*
-	 * We need to hold call_lock, so there is no inconsistency
-	 * between the time smp_call_function() determines number of
-	 * IPI recipients, and the time when the determination is made
-	 * for which cpus receive the IPI in genapic_flat.c. Holding this
-	 * lock helps us to not include this cpu in a currently in progress
-	 * smp_call_function().
-	 */
-	lock_ipi_call_lock();
-	spin_lock(&vector_lock);
-
-	/* Setup the per cpu irq handling data structures */
-	__setup_vector_irq(smp_processor_id());
-	/*
-	 * Allow the master to continue.
-	 */
-	spin_unlock(&vector_lock);
-	cpu_set(smp_processor_id(), cpu_online_map);
-	unlock_ipi_call_lock();
-
-	per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
-
-	setup_secondary_clock();
-
-	wmb();
-	cpu_idle();
-}
-
 cycles_t cacheflush_time;
 unsigned long cache_decay_ticks;
 
-- 
1.5.0.6

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

Messages in current thread:
[PATCH 0/79] smpboot integration, Glauber de Oliveira ..., (Wed Mar 19, 10:24 am)
[PATCH 01/79] [PATCH] change var types in __inquire_remote ..., Glauber de Oliveira ..., (Wed Mar 19, 10:24 am)
[PATCH 02/79] [PATCH] add loglevel to printks, Glauber de Oliveira ..., (Wed Mar 19, 10:24 am)
[PATCH 03/79] [PATCH] use apic_*_around instead of apic_wr ..., Glauber de Oliveira ..., (Wed Mar 19, 10:24 am)
[PATCH 04/79] [PATCH] use start_ipi_hook in x86_64, Glauber de Oliveira ..., (Wed Mar 19, 10:24 am)
[PATCH 05/79] [PATCH] add an smp_apply_quirks to smpboot_32.c, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 06/79] [PATCH] decouple call to print_cpu_info from ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 07/79] [PATCH] provide specialized identification r ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 08/79] [PATCH] use identify_boot_cpu, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 09/79] [PATCH] call identify_secondary_cpu in smp_s ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 10/79] [PATCH] merge smp_store_cpu_info, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 11/79] [PATCH] always enable irqs when entering idle, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 12/79] [PATCH] don't call local_irq_enable before e ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 13/79] [PATCH] move setup_secondary_clock a little ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 14/79] [PATCH] move state update out of ipi_lock, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 15/79] [PATCH] provide APIC_INTEGRATED definition f ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 16/79] [PATCH] use APIC_INTEGRATED tests in x86_64, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 17/79] [PATCH] add barriers statement, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 18/79] [PATCH] isolate sanity checking, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 19/79] [PATCH] isolate logic to disable smp, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 20/79] [PATCH] do tests before do_boot_cpu in i386, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 21/79] [PATCH] make __smp_prepare_cpu void, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 22/79] [PATCH] move assignment of CPU_PREPARE befor ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 23/79] [PATCH] unify extern masks declaration, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 24/79] [PATCH] define bios to apicid mapping, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 25/79] [PATCH] initialize map pointers in setup_32.c, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 26/79] [PATCH] make node to apic mapping declaratio ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 27/79] [PATCH] fix alloc_bootmem_pages_node macro, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 28/79] [PATCH] use specialized routine for setup pe ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 29/79] [PATCH] fill bios cpu to apicid maps, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 30/79] [PATCH] fill cpu to apicid and present map i ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 31/79] [PATCH] get rid of cpucount, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 32/79] [PATCH] allow user to impress friends., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 33/79] [PATCH] do smp tainting checks in a separate ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 34/79] [PATCH] move impress_friends and smp_check t ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 35/79] [PATCH] add subarch support (for headers) to ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 36/79] [PATCH] include mach_wakecpu.h in smpboot_64, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 37/79] [PATCH] include smpboot_hooks.h in smpboot_64.c, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 38/79] [PATCH] move smp_intr_init away from smpboot ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 39/79] [PATCH] don't set maps in native_smp_prepare ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 40/79] [PATCH] wipe get_nmi_reason out of nmi_64.h, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 41/79] [PATCH] unify nmi_32.h and nmi_64.h, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 42/79] [PATCH] call check_nmi_watchdog explicitly i ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 43/79] [PATCH] call nmi_watchdog_default in i386, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 44/79] [PATCH] don't initialize sibling and core ma ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 45/79] [PATCH] fix apic acking of irqs, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 46/79] [PATCH] schedule work only if keventd is alr ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 47/79] [PATCH] do not zap_low_mappings in __smp_pre ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 48/79] [PATCH] boot cpus from cpu_up, instead of pr ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 49/79] [PATCH] get rid of commenced mask., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 50/79] [PATCH] use create_idle struct in do_boot_cpu, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 51/79] [PATCH] don't span a new worker in __smp_pre ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 52/79] [PATCH] modify smp_callin in x86_64 to look ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 53/79] [PATCH] wrap esr setting up in i386 in lapic ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 54/79] [PATCH] provide an end_local_APIC_setup function, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 55/79] [PATCH] calibrate delay with irqs enabled, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 56/79] [PATCH] minor adjustments for do_boot_cpu, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 57/79] [PATCH] call do_boot_cpu directly from nativ ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 58/79] [PATCH] include mach_apic.h in smpboot_64.c ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 59/79] [PATCH] change wakeup_secondary name, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 60/79] [PATCH] add callin tests to cpu_up, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 61/79] [PATCH] move {un}map_cpu_to_logical_apicid t ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 62/79] [PATCH] move stack_start to smp.h, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 63/79] [PATCH] change boot_cpu_id to boot_cpu_physi ..., Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 64/79] [PATCH] integrate do_boot_cpu, Glauber de Oliveira ..., (Wed Mar 19, 10:25 am)
[PATCH 65/79] [PATCH] integrate start_secondary, Glauber de Oliveira ..., (Wed Mar 19, 10:26 am)
[PATCH 66/79] [PATCH] merge smp_prepare_boot_cpu, Glauber de Oliveira ..., (Wed Mar 19, 10:26 am)
[PATCH 67/79] [PATCH] merge native_smp_cpus_done, Glauber de Oliveira ..., (Wed Mar 19, 10:26 am)
[PATCH 68/79] [PATCH] use physical id when disabling smp, Glauber de Oliveira ..., (Wed Mar 19, 10:26 am)
[PATCH 69/79] [PATCH] get rid of smp_boot_cpus, Glauber de Oliveira ..., (Wed Mar 19, 10:26 am)
[PATCH 70/79] [PATCH] additions to i386 native_smp_prepare ..., Glauber de Oliveira ..., (Wed Mar 19, 10:26 am)
[PATCH 71/79] [PATCH] assign nr_ioapics = 0 in smpboot_hooks.h, Glauber de Oliveira ..., (Wed Mar 19, 10:26 am)
[PATCH 72/79] [PATCH] change x86_64 native_smp_prepare_cpu ..., Glauber de Oliveira ..., (Wed Mar 19, 10:26 am)
[PATCH 73/79] [PATCH] add extra sanity check, Glauber de Oliveira ..., (Wed Mar 19, 10:26 am)
[PATCH 74/79] [PATCH] change x86_64 sanity checks to match ..., Glauber de Oliveira ..., (Wed Mar 19, 10:26 am)
[PATCH 75/79] [PATCH] introduce smpboot_clear_io_apic, Glauber de Oliveira ..., (Wed Mar 19, 10:26 am)
[PATCH 76/79] [PATCH] merge native_smp_prepare_cpus, Glauber de Oliveira ..., (Wed Mar 19, 10:26 am)
[PATCH 77/79] [PATCH] merge cpu_exit_clear, Glauber de Oliveira ..., (Wed Mar 19, 10:26 am)
[PATCH 78/79] [PATCH] move apicid mappings to smpboot.c, Glauber de Oliveira ..., (Wed Mar 19, 10:26 am)
[PATCH 79/79] [PATCH] remove smpboot_32.c and smpboot_64.c, Glauber de Oliveira ..., (Wed Mar 19, 10:26 am)
Re: [PATCH 0/79] smpboot integration, Ingo Molnar, (Wed Mar 19, 10:35 am)
Re: [PATCH 0/79] smpboot integration, Ingo Molnar, (Wed Mar 19, 11:48 am)
Re: [PATCH 0/79] smpboot integration, Ingo Molnar, (Wed Mar 19, 12:36 pm)
Re: [PATCH 0/79] smpboot integration, Yinghai Lu, (Wed Mar 19, 7:18 pm)
Re: [PATCH 0/79] smpboot integration, Yinghai Lu, (Wed Mar 19, 8:00 pm)
Re: [PATCH 0/79] smpboot integration, Yinghai Lu, (Wed Mar 19, 8:32 pm)
Re: [PATCH 0/79] smpboot integration, Glauber Costa, (Wed Mar 19, 9:40 pm)
Re: [PATCH 0/79] smpboot integration, Yinghai Lu, (Wed Mar 19, 9:59 pm)
Re: [PATCH 45/79] [PATCH] fix apic acking of irqs, Maciej W. Rozycki, (Thu Mar 20, 3:28 am)
Re: [PATCH 45/79] [PATCH] fix apic acking of irqs, Glauber Costa, (Thu Mar 20, 8:04 am)
Re: [PATCH 45/79] [PATCH] fix apic acking of irqs, Maciej W. Rozycki, (Thu Mar 20, 3:27 pm)
Re: [PATCH 45/79] [PATCH] fix apic acking of irqs, Glauber Costa, (Mon Mar 24, 7:51 am)
Re: [PATCH 45/79] [PATCH] fix apic acking of irqs, Maciej W. Rozycki, (Mon Mar 24, 4:19 pm)
Re: [PATCH 45/79] [PATCH] fix apic acking of irqs, Andi Kleen, (Tue Mar 25, 5:40 am)
Re: [PATCH 45/79] [PATCH] fix apic acking of irqs, Glauber Costa, (Tue Mar 25, 6:42 am)
Re: [PATCH 45/79] [PATCH] fix apic acking of irqs, Maciej W. Rozycki, (Tue Mar 25, 8:48 am)
Re: [PATCH 45/79] [PATCH] fix apic acking of irqs, Glauber Costa, (Tue Mar 25, 3:39 pm)