Skip to contentSkip to conversation

First attempt at smp integration

PATCH In review Glauber Costa 4 participants 57 messages Mar 3, 2008 x86

lore
Share & tools
lore
#0 lore raw

cover First attempt at smp integration

Hi,

This series of patches does a first attempt at smp integration (I call it first, although I don't believe it's too far away from a real one). The series comprises 52 patches, and the full diffstat says in the end:

	 34 files changed, 1858 insertions(+), 2344 deletions(-)

smp_32.c and smp_64.c are completely gone. smp.h and smpboot_{32,64}.c are not, although substantially reduced. I know that ideally, no leftovers are wanted, but the series were already big enough (I tried to split the patches as much as I could), so I considered this a good cutting point. If this is all agreed upon and merged, I'll start looking at the other bits that are left.

All patches are tested is various random x86 subarchitectures, and all of them works. The result also boots fine in mine x86_64 and i386 boxes.

Comments are welcome.

 arch/x86/kernel/Makefile               |   11 
 arch/x86/kernel/apic_32.c              |    7 
 arch/x86/kernel/smp_32.c               |  730 ---------------------------------
 arch/x86/kernel/smp_64.c               |  674 +++---------------------------
 arch/x86/kernel/smpboot.c              |  372 ++++++++++++++++
 arch/x86/kernel/smpboot_32.c           |  363 ----------------
 arch/x86/kernel/smpboot_64.c           |  432 -------------------
 arch/x86/mach-voyager/voyager_smp.c    |    3 
 b/arch/x86/kernel/Makefile             |    2 
 b/arch/x86/kernel/apic_32.c            |   74 +--
 b/arch/x86/kernel/ipi.c                |  178 ++++++++
 b/arch/x86/kernel/mpparse_32.c         |    7 
 b/arch/x86/kernel/mpparse_64.c         |    7 
 b/arch/x86/kernel/smp.c                |  253 +++++++++++
 b/arch/x86/kernel/smp_32.c             |    2 
 b/arch/x86/kernel/smp_64.c             |    2 
 b/arch/x86/kernel/smpboot.c            |   53 ++
 b/arch/x86/kernel/smpboot_32.c         |    6 
 b/arch/x86/kernel/smpboot_64.c         |    2 
 b/arch/x86/kernel/smpcommon.c          |   83 +++
 b/arch/x86/kernel/smpcommon_32.c       |   82 ---
 b/arch/x86/kernel/tlb_32.c             |  243 ++++++++++
 b/arch/x86/kernel/tlb_64.c             |  274 ++++++++++++
 b/arch/x86/mach-voyager/voyager_smp.c  |    9 
 b/include/asm-x86/processor.h          |   10 
 b/include/asm-x86/smp.h                |    8 
 b/include/asm-x86/smp_32.h             |    4 
 b/include/asm-x86/smp_64.h             |    5 
 include/asm-x86/processor.h            |    5 
 include/asm-x86/smp.h                  |   99 ++++
 include/asm-x86/smp_32.h               |   86 ---
 include/asm-x86/smp_64.h               |   21 
 linux-2.6-x86/arch/x86/kernel/Makefile |    4 
 linux-2.6-x86/arch/x86/kernel/smp.c    |   91 ++++
 34 files changed, 1858 insertions(+), 2344 deletions(-)
#1 lore raw

PATCH 1/52 commonize smp.h

this is the first step of integrating smp.h between x86_64 and i386

---
 include/asm-x86/smp.h |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
include/asm-x86/smp.h +7 -0
index f2e8319..f250d1c 100644
@@ -1,5 +1,12 @@
+#ifndef _ASM_X86_SMP_H_
+#define _ASM_X86_SMP_H_
+#ifndef __ASSEMBLY__
+
 #ifdef CONFIG_X86_32
 # include "smp_32.h"
 #else
 # include "smp_64.h"
 #endif
+
+#endif /* __ASSEMBLY__ */
+#endif
Signature · 1 line
1.5.0.6
#2 lore raw

PATCH 2/52 merge extern function definitions

move extern function definitions that are the same between smp_{32,64}.h to smp.h

---
 include/asm-x86/smp.h    |    3 +++
 include/asm-x86/smp_32.h |    4 ----
 include/asm-x86/smp_64.h |    4 ----
 3 files changed, 3 insertions(+), 8 deletions(-)
include/asm-x86/smp.h +3 -0
index f250d1c..ad7b99d 100644
@@ -8,5 +8,8 @@
 # include "smp_64.h"
 #endif
 
+extern void smp_alloc_memory(void);
+extern void lock_ipi_call_lock(void);
+extern void unlock_ipi_call_lock(void);
 #endif /* __ASSEMBLY__ */
 #endif
include/asm-x86/smp_32.h +0 -4
index 56152e3..2781225 100644
@@ -22,10 +22,6 @@ extern cpumask_t cpu_callin_map;
 extern int smp_num_siblings;
 extern unsigned int num_processors;
 
-extern void smp_alloc_memory(void);
-extern void lock_ipi_call_lock(void);
-extern void unlock_ipi_call_lock(void);
-
 extern void (*mtrr_hook) (void);
 extern void zap_low_mappings (void);
 
include/asm-x86/smp_64.h +0 -4
index e0a7551..2c21df2 100644
@@ -19,10 +19,6 @@ extern cpumask_t cpu_initialized;
 extern int smp_num_siblings;
 extern unsigned int num_processors;
 
-extern void smp_alloc_memory(void);
-extern void lock_ipi_call_lock(void);
-extern void unlock_ipi_call_lock(void);
-
 extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *),
 				  void *info, int wait);
 
Signature · 1 line
1.5.0.6
#3 lore raw

PATCH 3/52 merge extern variables definitions

move extern definitions that are the same between smp_{32,64}.h to smp.h

---
 include/asm-x86/smp.h    |    6 ++++++
 include/asm-x86/smp_32.h |    4 ----
 include/asm-x86/smp_64.h |    4 ----
 3 files changed, 6 insertions(+), 8 deletions(-)
include/asm-x86/smp.h +6 -0
index ad7b99d..c130a87 100644
@@ -1,6 +1,12 @@
 #ifndef _ASM_X86_SMP_H_
 #define _ASM_X86_SMP_H_
 #ifndef __ASSEMBLY__
+#include <linux/cpumask.h>
+
+extern cpumask_t cpu_callout_map;
+
+extern int smp_num_siblings;
+extern unsigned int num_processors;
 
 #ifdef CONFIG_X86_32
 # include "smp_32.h"
include/asm-x86/smp_32.h +0 -4
index 2781225..9a4057d 100644
@@ -16,12 +16,8 @@
 # endif
 #endif
 
-extern cpumask_t cpu_callout_map;
 extern cpumask_t cpu_callin_map;
 
-extern int smp_num_siblings;
-extern unsigned int num_processors;
-
 extern void (*mtrr_hook) (void);
 extern void zap_low_mappings (void);
 
include/asm-x86/smp_64.h +0 -4
index 2c21df2..284f701 100644
@@ -13,12 +13,8 @@
 #include <asm/pda.h>
 #include <asm/thread_info.h>
 
-extern cpumask_t cpu_callout_map;
 extern cpumask_t cpu_initialized;
 
-extern int smp_num_siblings;
-extern unsigned int num_processors;
-
 extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *),
 				  void *info, int wait);
 
Signature · 1 line
1.5.0.6
#4 lore raw

PATCH 4/52 define smp_ops in common header

x86_64 will benefit from it

---
 include/asm-x86/smp.h    |   14 ++++++++++++++
 include/asm-x86/smp_32.h |   14 --------------
 2 files changed, 14 insertions(+), 14 deletions(-)
include/asm-x86/smp.h +14 -0
index c130a87..d11b92b 100644
@@ -8,6 +8,20 @@ extern cpumask_t cpu_callout_map;
 extern int smp_num_siblings;
 extern unsigned int num_processors;
 
+struct smp_ops {
+	void (*smp_prepare_boot_cpu)(void);
+	void (*smp_prepare_cpus)(unsigned max_cpus);
+	int (*cpu_up)(unsigned cpu);
+	void (*smp_cpus_done)(unsigned max_cpus);
+
+	void (*smp_send_stop)(void);
+	void (*smp_send_reschedule)(int cpu);
+	int (*smp_call_function_mask)(cpumask_t mask,
+				      void (*func)(void *info), void *info,
+				      int wait);
+};
+
+
 #ifdef CONFIG_X86_32
 # include "smp_32.h"
 #else
include/asm-x86/smp_32.h +0 -14
index 9a4057d..72faad6 100644
@@ -38,20 +38,6 @@ extern void remove_siblinginfo(int cpu);
 /* Globals due to paravirt */
 extern void set_cpu_sibling_map(int cpu);
 
-struct smp_ops
-{
-	void (*smp_prepare_boot_cpu)(void);
-	void (*smp_prepare_cpus)(unsigned max_cpus);
-	int (*cpu_up)(unsigned cpu);
-	void (*smp_cpus_done)(unsigned max_cpus);
-
-	void (*smp_send_stop)(void);
-	void (*smp_send_reschedule)(int cpu);
-	int (*smp_call_function_mask)(cpumask_t mask,
-				      void (*func)(void *info), void *info,
-				      int wait);
-};
-
 #ifdef CONFIG_SMP
 extern struct smp_ops smp_ops;
 
Signature · 1 line
1.5.0.6
#5 lore raw

PATCH 5/52 move smp_ops extern declaration to common header

the smp_ops symbol is temporarily defined in smp_64.c, but it will soon be unified

---
 arch/x86/kernel/smp_64.c |    2 ++
 include/asm-x86/smp.h    |    3 +++
 include/asm-x86/smp_32.h |    2 --
 3 files changed, 5 insertions(+), 2 deletions(-)
arch/x86/kernel/smp_64.c +2 -0
index 2fd74b0..80dba12 100644
@@ -528,3 +528,5 @@ asmlinkage void smp_call_function_interrupt(void)
 	}
 }
 
+struct smp_ops smp_ops;
+EXPORT_SYMBOL_GPL(smp_ops);
include/asm-x86/smp.h +3 -0
index d11b92b..ee98bee 100644
@@ -21,6 +21,9 @@ struct smp_ops {
 				      int wait);
 };
 
+#ifdef CONFIG_SMP
+extern struct smp_ops smp_ops;
+#endif
 
 #ifdef CONFIG_X86_32
 # include "smp_32.h"
include/asm-x86/smp_32.h +0 -2
index 72faad6..74755e8 100644
@@ -39,8 +39,6 @@ extern void remove_siblinginfo(int cpu);
 extern void set_cpu_sibling_map(int cpu);
 
 #ifdef CONFIG_SMP
-extern struct smp_ops smp_ops;
-
 static inline void smp_prepare_boot_cpu(void)
 {
 	smp_ops.smp_prepare_boot_cpu();
Signature · 1 line
1.5.0.6
#6 lore raw

PATCH 6/52 merge smp_send_reschedule

function definition is moved to common header, x86_64 version is now called native_smp_send_reschedule

---
 arch/x86/kernel/smp_64.c |    7 +++++--
 include/asm-x86/smp.h    |    5 +++++
 include/asm-x86/smp_32.h |    4 ----
 include/asm-x86/smp_64.h |    2 --
 4 files changed, 10 insertions(+), 8 deletions(-)
arch/x86/kernel/smp_64.c +5 -2
index 80dba12..fd18161 100644
@@ -290,8 +290,9 @@ void flush_tlb_all(void)
  * anything. Worst case is that we lose a reschedule ...
  */
 
-void smp_send_reschedule(int cpu)
+static void native_smp_send_reschedule(int cpu)
 {
+	WARN_ON(cpu_is_offline(cpu));
 	send_IPI_mask(cpumask_of_cpu(cpu), RESCHEDULE_VECTOR);
 }
 
@@ -528,5 +529,7 @@ asmlinkage void smp_call_function_interrupt(void)
 	}
 }
 
-struct smp_ops smp_ops;
+struct smp_ops smp_ops = {
+	.smp_send_reschedule = native_smp_send_reschedule,
+};
 EXPORT_SYMBOL_GPL(smp_ops);
include/asm-x86/smp.h +5 -0
index ee98bee..28f33c0 100644
@@ -23,6 +23,11 @@ struct smp_ops {
 
 #ifdef CONFIG_SMP
 extern struct smp_ops smp_ops;
+
+static inline void smp_send_reschedule(int cpu)
+{
+	smp_ops.smp_send_reschedule(cpu);
+}
 #endif
 
 #ifdef CONFIG_X86_32
include/asm-x86/smp_32.h +0 -4
index 74755e8..c60a3dd 100644
@@ -60,10 +60,6 @@ static inline void smp_send_stop(void)
 {
 	smp_ops.smp_send_stop();
 }
-static inline void smp_send_reschedule(int cpu)
-{
-	smp_ops.smp_send_reschedule(cpu);
-}
 static inline int smp_call_function_mask(cpumask_t mask,
 					 void (*func) (void *info), void *info,
 					 int wait)
include/asm-x86/smp_64.h +0 -2
index 284f701..b920458 100644
@@ -65,8 +65,6 @@ static inline int num_booting_cpus(void)
 	return cpus_weight(cpu_callout_map);
 }
 
-extern void smp_send_reschedule(int cpu);
-
 #else /* CONFIG_SMP */
 
 extern unsigned int boot_cpu_id;
Signature · 1 line
1.5.0.6
#7 lore raw

PATCH 7/52 unify smp_call_function_mask

definition is moved to common header, x86_64 function name now is native_smp_call_function_mask

---
 arch/x86/kernel/smp_64.c |    7 ++++---
 include/asm-x86/smp.h    |    7 +++++++
 include/asm-x86/smp_32.h |    6 ------
 3 files changed, 11 insertions(+), 9 deletions(-)
arch/x86/kernel/smp_64.c +4 -3
index fd18161..225b765 100644
@@ -386,9 +386,9 @@ static int __smp_call_function_mask(cpumask_t mask,
  * You must not call this function with disabled interrupts or from a
  * hardware interrupt handler or from a bottom half handler.
  */
-int smp_call_function_mask(cpumask_t mask,
-			   void (*func)(void *), void *info,
-			   int wait)
+int native_smp_call_function_mask(cpumask_t mask,
+				  void (*func)(void *), void *info,
+				  int wait)
 {
 	int ret;
 
@@ -531,5 +531,6 @@ asmlinkage void smp_call_function_interrupt(void)
 
 struct smp_ops smp_ops = {
 	.smp_send_reschedule = native_smp_send_reschedule,
+	.smp_call_function_mask = native_smp_call_function_mask,
 };
 EXPORT_SYMBOL_GPL(smp_ops);
include/asm-x86/smp.h +7 -0
index 28f33c0..d9782f4 100644
@@ -28,6 +28,13 @@ static inline void smp_send_reschedule(int cpu)
 {
 	smp_ops.smp_send_reschedule(cpu);
 }
+
+static inline int smp_call_function_mask(cpumask_t mask,
+					 void (*func) (void *info), void *info,
+					 int wait)
+{
+	return smp_ops.smp_call_function_mask(mask, func, info, wait);
+}
 #endif
 
 #ifdef CONFIG_X86_32
include/asm-x86/smp_32.h +0 -6
index c60a3dd..d9337ee 100644
@@ -60,12 +60,6 @@ static inline void smp_send_stop(void)
 {
 	smp_ops.smp_send_stop();
 }
-static inline int smp_call_function_mask(cpumask_t mask,
-					 void (*func) (void *info), void *info,
-					 int wait)
-{
-	return smp_ops.smp_call_function_mask(mask, func, info, wait);
-}
 
 void native_smp_prepare_boot_cpu(void);
 void native_smp_prepare_cpus(unsigned int max_cpus);
Signature · 1 line
1.5.0.6
#8 lore raw

PATCH 8/52 unify __cpu_up.

function definition is moved to common header. x86_64 version is now called native_cpu_up

---
 arch/x86/kernel/smp_64.c     |    1 +
 arch/x86/kernel/smpboot_64.c |    2 +-
 include/asm-x86/smp.h        |    7 +++++++
 include/asm-x86/smp_32.h     |    5 -----
 4 files changed, 9 insertions(+), 6 deletions(-)
arch/x86/kernel/smp_64.c +1 -0
index 225b765..7cc20a3 100644
@@ -532,5 +532,6 @@ asmlinkage void smp_call_function_interrupt(void)
 struct smp_ops smp_ops = {
 	.smp_send_reschedule = native_smp_send_reschedule,
 	.smp_call_function_mask = native_smp_call_function_mask,
+	.cpu_up = native_cpu_up,
 };
 EXPORT_SYMBOL_GPL(smp_ops);
arch/x86/kernel/smpboot_64.c +1 -1
index 0880f2c..e381fe7 100644
@@ -929,7 +929,7 @@ void __init smp_prepare_boot_cpu(void)
 /*
  * Entry point to boot a CPU.
  */
-int __cpuinit __cpu_up(unsigned int cpu)
+int __cpuinit native_cpu_up(unsigned int cpu)
 {
 	int apicid = cpu_present_to_apicid(cpu);
 	unsigned long flags;
include/asm-x86/smp.h +7 -0
index d9782f4..7dd7141 100644
@@ -24,6 +24,11 @@ struct smp_ops {
 #ifdef CONFIG_SMP
 extern struct smp_ops smp_ops;
 
+static inline int __cpu_up(unsigned int cpu)
+{
+	return smp_ops.cpu_up(cpu);
+}
+
 static inline void smp_send_reschedule(int cpu)
 {
 	smp_ops.smp_send_reschedule(cpu);
@@ -35,6 +40,8 @@ static inline int smp_call_function_mask(cpumask_t mask,
 {
 	return smp_ops.smp_call_function_mask(mask, func, info, wait);
 }
+
+int native_cpu_up(unsigned int cpunum);
 #endif
 
 #ifdef CONFIG_X86_32
include/asm-x86/smp_32.h +0 -5
index d9337ee..a7fab8e 100644
@@ -47,10 +47,6 @@ static inline void smp_prepare_cpus(unsigned int max_cpus)
 {
 	smp_ops.smp_prepare_cpus(max_cpus);
 }
-static inline int __cpu_up(unsigned int cpu)
-{
-	return smp_ops.cpu_up(cpu);
-}
 static inline void smp_cpus_done(unsigned int max_cpus)
 {
 	smp_ops.smp_cpus_done(max_cpus);
@@ -63,7 +59,6 @@ static inline void smp_send_stop(void)
 
 void native_smp_prepare_boot_cpu(void);
 void native_smp_prepare_cpus(unsigned int max_cpus);
-int native_cpu_up(unsigned int cpunum);
 void native_smp_cpus_done(unsigned int max_cpus);
 
 #ifndef CONFIG_PARAVIRT
Signature · 1 line
1.5.0.6
#9 lore raw

PATCH 9/52 unify prepare_boot_cpu

definition is moved to common header. x86_64 version is now called native_prepare_boot_cpu

---
 arch/x86/kernel/smp_64.c     |    1 +
 arch/x86/kernel/smpboot_64.c |    2 +-
 include/asm-x86/smp.h        |    6 ++++++
 include/asm-x86/smp_32.h     |    5 -----
 4 files changed, 8 insertions(+), 6 deletions(-)
arch/x86/kernel/smp_64.c +1 -0
index 7cc20a3..05116c1 100644
@@ -530,6 +530,7 @@ asmlinkage void smp_call_function_interrupt(void)
 }
 
 struct smp_ops smp_ops = {
+	.smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
 	.smp_send_reschedule = native_smp_send_reschedule,
 	.smp_call_function_mask = native_smp_call_function_mask,
 	.cpu_up = native_cpu_up,
arch/x86/kernel/smpboot_64.c +1 -1
index e381fe7..47e654c 100644
@@ -918,7 +918,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
 /*
  * Early setup to make printk work.
  */
-void __init smp_prepare_boot_cpu(void)
+void __init native_smp_prepare_boot_cpu(void)
 {
 	int me = smp_processor_id();
 	/* already set me in cpu_online_map in boot_cpu_init() */
include/asm-x86/smp.h +6 -0
index 7dd7141..a2d69a1 100644
@@ -24,6 +24,11 @@ struct smp_ops {
 #ifdef CONFIG_SMP
 extern struct smp_ops smp_ops;
 
+static inline void smp_prepare_boot_cpu(void)
+{
+	smp_ops.smp_prepare_boot_cpu();
+}
+
 static inline int __cpu_up(unsigned int cpu)
 {
 	return smp_ops.cpu_up(cpu);
@@ -41,6 +46,7 @@ static inline int smp_call_function_mask(cpumask_t mask,
 	return smp_ops.smp_call_function_mask(mask, func, info, wait);
 }
 
+void native_smp_prepare_boot_cpu(void);
 int native_cpu_up(unsigned int cpunum);
 #endif
 
include/asm-x86/smp_32.h +0 -5
index a7fab8e..2c7ecfa 100644
@@ -39,10 +39,6 @@ extern void remove_siblinginfo(int cpu);
 extern void set_cpu_sibling_map(int cpu);
 
 #ifdef CONFIG_SMP
-static inline void smp_prepare_boot_cpu(void)
-{
-	smp_ops.smp_prepare_boot_cpu();
-}
 static inline void smp_prepare_cpus(unsigned int max_cpus)
 {
 	smp_ops.smp_prepare_cpus(max_cpus);
@@ -57,7 +53,6 @@ static inline void smp_send_stop(void)
 	smp_ops.smp_send_stop();
 }
 
-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);
 
Signature · 1 line
1.5.0.6
#10 lore raw

PATCH 10/52 unify smp_prepare_cpus

definition is moved to common header. x86_64 version is now called native_smp_prepare_cpus

---
 arch/x86/kernel/smp_64.c     |    1 +
 arch/x86/kernel/smpboot_64.c |    2 +-
 include/asm-x86/smp.h        |    6 ++++++
 include/asm-x86/smp_32.h     |    5 -----
 4 files changed, 8 insertions(+), 6 deletions(-)
arch/x86/kernel/smp_64.c +1 -0
index 05116c1..c520374 100644
@@ -531,6 +531,7 @@ asmlinkage void smp_call_function_interrupt(void)
 
 struct smp_ops smp_ops = {
 	.smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
+	.smp_prepare_cpus = native_smp_prepare_cpus,
 	.smp_send_reschedule = native_smp_send_reschedule,
 	.smp_call_function_mask = native_smp_call_function_mask,
 	.cpu_up = native_cpu_up,
arch/x86/kernel/smpboot_64.c +1 -1
index 47e654c..b106983 100644
@@ -867,7 +867,7 @@ static void __init smp_cpu_index_default(void)
  * Prepare for SMP bootup.  The MP table or ACPI has been read
  * earlier.  Just do some sanity checking here and enable APIC mode.
  */
-void __init smp_prepare_cpus(unsigned int max_cpus)
+void __init native_smp_prepare_cpus(unsigned int max_cpus)
 {
 	nmi_watchdog_default();
 	smp_cpu_index_default();
include/asm-x86/smp.h +6 -0
index a2d69a1..31bd99d 100644
@@ -29,6 +29,11 @@ static inline void smp_prepare_boot_cpu(void)
 	smp_ops.smp_prepare_boot_cpu();
 }
 
+static inline void smp_prepare_cpus(unsigned int max_cpus)
+{
+	smp_ops.smp_prepare_cpus(max_cpus);
+}
+
 static inline int __cpu_up(unsigned int cpu)
 {
 	return smp_ops.cpu_up(cpu);
@@ -47,6 +52,7 @@ static inline int smp_call_function_mask(cpumask_t mask,
 }
 
 void native_smp_prepare_boot_cpu(void);
+void native_smp_prepare_cpus(unsigned int max_cpus);
 int native_cpu_up(unsigned int cpunum);
 #endif
 
include/asm-x86/smp_32.h +0 -5
index 2c7ecfa..5078538 100644
@@ -39,10 +39,6 @@ extern void remove_siblinginfo(int cpu);
 extern void set_cpu_sibling_map(int cpu);
 
 #ifdef CONFIG_SMP
-static inline void smp_prepare_cpus(unsigned int max_cpus)
-{
-	smp_ops.smp_prepare_cpus(max_cpus);
-}
 static inline void smp_cpus_done(unsigned int max_cpus)
 {
 	smp_ops.smp_cpus_done(max_cpus);
@@ -53,7 +49,6 @@ static inline void smp_send_stop(void)
 	smp_ops.smp_send_stop();
 }
 
-void native_smp_prepare_cpus(unsigned int max_cpus);
 void native_smp_cpus_done(unsigned int max_cpus);
 
 #ifndef CONFIG_PARAVIRT
Signature · 1 line
1.5.0.6
#11 lore raw

PATCH 11/52 unify smp_cpus_done

definition is moved to common header. x86_64 version is now called native_smp_cpus_done

---
 arch/x86/kernel/smp_64.c     |    2 ++
 arch/x86/kernel/smpboot_64.c |    2 +-
 include/asm-x86/smp.h        |    6 ++++++
 include/asm-x86/smp_32.h     |    7 -------
 4 files changed, 9 insertions(+), 8 deletions(-)
arch/x86/kernel/smp_64.c +2 -0
index c520374..275101a 100644
@@ -532,6 +532,8 @@ asmlinkage void smp_call_function_interrupt(void)
 struct smp_ops smp_ops = {
 	.smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
 	.smp_prepare_cpus = native_smp_prepare_cpus,
+	.smp_cpus_done = native_smp_cpus_done,
+
 	.smp_send_reschedule = native_smp_send_reschedule,
 	.smp_call_function_mask = native_smp_call_function_mask,
 	.cpu_up = native_cpu_up,
arch/x86/kernel/smpboot_64.c +1 -1
index b106983..fd0d3a9 100644
@@ -987,7 +987,7 @@ int __cpuinit native_cpu_up(unsigned int cpu)
 /*
  * Finish the SMP boot.
  */
-void __init smp_cpus_done(unsigned int max_cpus)
+void __init native_smp_cpus_done(unsigned int max_cpus)
 {
 	smp_cleanup_boot();
 	setup_ioapic_dest();
include/asm-x86/smp.h +6 -0
index 31bd99d..9620165 100644
@@ -34,6 +34,11 @@ static inline void smp_prepare_cpus(unsigned int max_cpus)
 	smp_ops.smp_prepare_cpus(max_cpus);
 }
 
+static inline void smp_cpus_done(unsigned int max_cpus)
+{
+	smp_ops.smp_cpus_done(max_cpus);
+}
+
 static inline int __cpu_up(unsigned int cpu)
 {
 	return smp_ops.cpu_up(cpu);
@@ -53,6 +58,7 @@ static inline int smp_call_function_mask(cpumask_t mask,
 
 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);
 int native_cpu_up(unsigned int cpunum);
 #endif
 
include/asm-x86/smp_32.h +0 -7
index 5078538..bc90a4e 100644
@@ -39,18 +39,11 @@ extern void remove_siblinginfo(int cpu);
 extern void set_cpu_sibling_map(int cpu);
 
 #ifdef CONFIG_SMP
-static inline void smp_cpus_done(unsigned int max_cpus)
-{
-	smp_ops.smp_cpus_done(max_cpus);
-}
-
 static inline void smp_send_stop(void)
 {
 	smp_ops.smp_send_stop();
 }
 
-void native_smp_cpus_done(unsigned int max_cpus);
-
 #ifndef CONFIG_PARAVIRT
 #define startup_ipi_hook(phys_apicid, start_eip, start_esp) do { } while (0)
 #endif
Signature · 1 line
1.5.0.6
#12 lore raw

PATCH 12/52 move disabled_cpus to common header

disabled_cpus is (up to now) a x86_64-only contruction. But it's extern declaration can be moved to common header anyway

---
 include/asm-x86/smp.h    |    3 +++
 include/asm-x86/smp_64.h |    1 -
 2 files changed, 3 insertions(+), 1 deletions(-)
include/asm-x86/smp.h +3 -0
index 9620165..be8a511 100644
@@ -2,6 +2,7 @@
 #define _ASM_X86_SMP_H_
 #ifndef __ASSEMBLY__
 #include <linux/cpumask.h>
+#include <linux/init.h>
 
 extern cpumask_t cpu_callout_map;
 
@@ -60,6 +61,8 @@ 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);
 int native_cpu_up(unsigned int cpunum);
+
+extern unsigned disabled_cpus;
 #endif
 
 #ifdef CONFIG_X86_32
include/asm-x86/smp_64.h +0 -1
index b920458..c7a00ca 100644
@@ -44,7 +44,6 @@ static inline int cpu_present_to_apicid(int mps_cpu)
 extern int __cpu_disable(void);
 extern void __cpu_die(unsigned int cpu);
 extern void prefill_possible_map(void);
-extern unsigned __cpuinitdata disabled_cpus;
 
 #define raw_smp_processor_id()	read_pda(cpunumber)
 #define cpu_physical_id(cpu)	per_cpu(x86_cpu_to_apicid, cpu)
Signature · 1 line
1.5.0.6
#13 lore raw

PATCH 13/52 use disabled_cpus in i386

this patch allows a cpu to be marked as present but disabled in i386, just as x86_64 currently does.

---
 arch/x86/kernel/mpparse_32.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
arch/x86/kernel/mpparse_32.c +5 -1
index f349e68..b2aded3 100644
@@ -70,6 +70,8 @@ unsigned int boot_cpu_physical_apicid = -1U;
 /* Internal processor count */
 unsigned int num_processors;
 
+unsigned disabled_cpus __cpuinitdata;
+
 /* Bitmask of physically existing CPUs */
 physid_mask_t phys_cpu_present_map;
 
@@ -108,8 +110,10 @@ static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
  	int ver, apicid;
 	physid_mask_t phys_cpu;
  	
-	if (!(m->mpc_cpuflag & CPU_ENABLED))
+	if (!(m->mpc_cpuflag & CPU_ENABLED)) {
+		disabled_cpus++;
 		return;
+	}
 
 	apicid = mpc_apic_id(m, translation_table[mpc_record]);
 
Signature · 1 line
1.5.0.6
#14 lore raw

PATCH 14/52 move prefill_possible_map to common file

this patches moves prefill_possible_map() to smpboot.c Right now it is x86_64-specific, but nothing intrinsically prevents it to be used by i386

---
 arch/x86/kernel/Makefile     |    2 +-
 arch/x86/kernel/smpboot.c    |   53 ++++++++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/smpboot_64.c |   51 ----------------------------------------
 include/asm-x86/smp.h        |    1 +
 include/asm-x86/smp_64.h     |    1 -
 5 files changed, 55 insertions(+), 53 deletions(-)
 create mode 100644 arch/x86/kernel/smpboot.c
arch/x86/kernel/Makefile +1 -1
index df10327..4c68bfc 100644
@@ -46,7 +46,7 @@ obj-$(CONFIG_MICROCODE)		+= microcode.o
 obj-$(CONFIG_PCI)		+= early-quirks.o
 apm-y				:= apm_32.o
 obj-$(CONFIG_APM)		+= apm.o
-obj-$(CONFIG_X86_SMP)		+= smp_$(BITS).o smpboot_$(BITS).o tsc_sync.o
+obj-$(CONFIG_X86_SMP)		+= smp_$(BITS).o smpboot_$(BITS).o smpboot.o tsc_sync.o
 obj-$(CONFIG_X86_32_SMP)	+= smpcommon_32.o
 obj-$(CONFIG_X86_64_SMP)	+= smp_64.o smpboot_64.o tsc_sync.o
 obj-$(CONFIG_X86_TRAMPOLINE)	+= trampoline_$(BITS).o
arch/x86/kernel/smpboot.c new file +53 -0

53 lines not on this page · raw message

arch/x86/kernel/smpboot_64.c +0 -51

63 lines not on this page · raw message

include/asm-x86/smp.h +1 -0
index be8a511..28cb1f8 100644
@@ -63,6 +63,7 @@ void native_smp_cpus_done(unsigned int max_cpus);
 int native_cpu_up(unsigned int cpunum);
 
 extern unsigned disabled_cpus;
+extern void prefill_possible_map(void);
 #endif
 
 #ifdef CONFIG_X86_32
include/asm-x86/smp_64.h +0 -1
index c7a00ca..e5bc1be 100644
@@ -43,7 +43,6 @@ static inline int cpu_present_to_apicid(int mps_cpu)
 
 extern int __cpu_disable(void);
 extern void __cpu_die(unsigned int cpu);
-extern void prefill_possible_map(void);
 
 #define raw_smp_processor_id()	read_pda(cpunumber)
 #define cpu_physical_id(cpu)	per_cpu(x86_cpu_to_apicid, cpu)
Signature · 1 line
1.5.0.6
#15 lore raw

PATCH 15/52 remove export for smp_call_function_mask.

with this removal, exports for both i386 and x86_64, regarding the "smp_call_function" series are now the same.

---
 arch/x86/kernel/smp_64.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
arch/x86/kernel/smp_64.c +0 -1
index 275101a..a434f6c 100644
@@ -400,7 +400,6 @@ int native_smp_call_function_mask(cpumask_t mask,
 	spin_unlock(&call_lock);
 	return ret;
 }
-EXPORT_SYMBOL(smp_call_function_mask);
 
 /*
  * smp_call_function_single - Run a function on a specific CPU
Signature · 1 line
1.5.0.6
#16 lore raw

PATCH 16/52 remove irqs disabled warning.

there's already a warning in the topmost function

---
 arch/x86/kernel/smp_64.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
arch/x86/kernel/smp_64.c +0 -3
index a434f6c..b040224 100644
@@ -420,9 +420,6 @@ int smp_call_function_single (int cpu, void (*func) (void *info), void *info,
 	/* prevent preemption and reschedule on another processor */
 	int ret, me = get_cpu();
 
-	/* Can deadlock when called with interrupts disabled */
-	WARN_ON(irqs_disabled());
-
 	if (cpu == me) {
 		local_irq_disable();
 		func(info);
Signature · 1 line
1.5.0.6
#17 lore raw

PATCH 17/52 create smpcommon.c

This patch creates smpcommon.c with functions that are equal between architectures. The i386-only init_gdt is ifdef'd.

Note that smpcommon.o figures twice in the Makefile:
this is because sub-architectures like voyager that does not use the normal smp_$(BITS) files also have to access them

---
 arch/x86/kernel/Makefile       |    4 +-
 arch/x86/kernel/smp_64.c       |   56 ---------------------------
 arch/x86/kernel/smpcommon.c    |   83 ++++++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/smpcommon_32.c |   81 ---------------------------------------
 4 files changed, 85 insertions(+), 139 deletions(-)
 create mode 100644 arch/x86/kernel/smpcommon.c
arch/x86/kernel/Makefile +2 -2
index 4c68bfc..018d04d 100644
@@ -47,8 +47,8 @@ obj-$(CONFIG_PCI)		+= early-quirks.o
 apm-y				:= apm_32.o
 obj-$(CONFIG_APM)		+= apm.o
 obj-$(CONFIG_X86_SMP)		+= smp_$(BITS).o smpboot_$(BITS).o smpboot.o tsc_sync.o
-obj-$(CONFIG_X86_32_SMP)	+= smpcommon_32.o
-obj-$(CONFIG_X86_64_SMP)	+= smp_64.o smpboot_64.o tsc_sync.o
+obj-$(CONFIG_X86_32_SMP)	+= smpcommon.o
+obj-$(CONFIG_X86_64_SMP)	+= smp_64.o smpboot_64.o tsc_sync.o smpcommon.o
 obj-$(CONFIG_X86_TRAMPOLINE)	+= trampoline_$(BITS).o
 obj-$(CONFIG_X86_MPPARSE)	+= mpparse_$(BITS).o
 obj-$(CONFIG_X86_LOCAL_APIC)	+= apic_$(BITS).o nmi_$(BITS).o
arch/x86/kernel/smp_64.c +0 -56

62 lines not on this page · raw message

arch/x86/kernel/smpcommon.c new file +83 -0

83 lines not on this page · raw message

arch/x86/kernel/smpcommon_32.c +0 -81

82 lines not on this page · raw message

Signature · 1 line
1.5.0.6
#18 lore raw

PATCH 18/52 provide __smp_call_function

This function is used in smp_send_stop(). It's like smp_call_function_mask, but always go to all online cpus, and does not take any locks.

It is added to x86_64, but will soon be unified in a common file

---
 arch/x86/kernel/smp_64.c |   34 +++++++++++++++++++++++++++++++++-
 1 files changed, 33 insertions(+), 1 deletions(-)
arch/x86/kernel/smp_64.c +33 -1
index 1d8b863..aa2edb7 100644
@@ -322,6 +322,38 @@ void unlock_ipi_call_lock(void)
 	spin_unlock_irq(&call_lock);
 }
 
+static void __smp_call_function(void (*func) (void *info), void *info,
+				int nonatomic, int wait)
+{
+	struct call_data_struct data;
+	int cpus = num_online_cpus() - 1;
+
+	if (!cpus)
+		return;
+
+	data.func = func;
+	data.info = info;
+	atomic_set(&data.started, 0);
+	data.wait = wait;
+	if (wait)
+		atomic_set(&data.finished, 0);
+
+	call_data = &data;
+	mb();
+
+	/* Send a message to all other CPUs and wait for them to respond */
+	send_IPI_allbutself(CALL_FUNCTION_VECTOR);
+
+	/* Wait for response */
+	while (atomic_read(&data.started) != cpus)
+		cpu_relax();
+
+	if (wait)
+		while (atomic_read(&data.finished) != cpus)
+			cpu_relax();
+}
+
+
 /*
  * this function sends a 'generic call function' IPI to all other CPU
  * of the system defined in the mask.
@@ -424,7 +456,7 @@ void smp_send_stop(void)
 	/* Don't deadlock on the call lock in panic */
 	nolock = !spin_trylock(&call_lock);
 	local_irq_save(flags);
-	__smp_call_function_mask(cpu_online_map, stop_this_cpu, NULL, 0);
+	__smp_call_function(stop_this_cpu, NULL, 0, 0);
 	if (!nolock)
 		spin_unlock(&call_lock);
 	disable_local_APIC();
Signature · 1 line
1.5.0.6
#19 lore raw

PATCH 19/52 change x86_64 smp_call_function_mask to look alike i386

the two versions (the inner version, and the outer version, that takes the locks) of smp_call_function_mask are made into one. With the changes, i386 and x86_64 versions look exactly the same.

---
 arch/x86/kernel/smp_32.c |    2 +-
 arch/x86/kernel/smp_64.c |   57 +++++++++++++---------------------------------
 2 files changed, 17 insertions(+), 42 deletions(-)
arch/x86/kernel/smp_32.c +1 -1
index dc0cde9..e4a6b66 100644
@@ -583,7 +583,7 @@ native_smp_call_function_mask(cpumask_t mask,
 		atomic_set(&data.finished, 0);
 
 	call_data = &data;
-	mb();
+	wmb();
 
 	/* Send a message to other CPUs */
 	if (cpus_equal(mask, allbutself))
arch/x86/kernel/smp_64.c +16 -41

85 lines not on this page · raw message

Signature · 1 line
1.5.0.6
#20 lore raw

PATCH 20/52 provide hlt_works function.

In x86_64, hlt always work. in i386, we'll query the cpuinfo associated with this cpu

---
 include/asm-x86/processor.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
include/asm-x86/processor.h +9 -0
index 9054734..8bec23c 100644
@@ -144,6 +144,15 @@ DECLARE_PER_CPU(struct cpuinfo_x86, cpu_info);
 #define current_cpu_data	boot_cpu_data
 #endif
 
+static inline int hlt_works(int cpu)
+{
+#ifdef CONFIG_X86_32
+	return cpu_data(cpu).hlt_works_ok;
+#else
+	return 1;
+#endif
+}
+
 #define cache_line_size()	(boot_cpu_data.x86_cache_alignment)
 
 extern void cpu_detect(struct cpuinfo_x86 *c);
Signature · 1 line
1.5.0.6
#21 lore raw

PATCH 21/52 make stop_this_cpu looks exactly equal in both arches

with the hlt_works change, it is possible to have i386 and x86_64 stop_this_cpu() looking exactly the same. They can, after that, be merged.

---
 arch/x86/kernel/smp_32.c |    2 +-
 arch/x86/kernel/smp_64.c |    5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)
arch/x86/kernel/smp_32.c +1 -1
index e4a6b66..cde3a0e 100644
@@ -611,7 +611,7 @@ static void stop_this_cpu (void * dummy)
 	 */
 	cpu_clear(smp_processor_id(), cpu_online_map);
 	disable_local_APIC();
-	if (cpu_data(smp_processor_id()).hlt_works_ok)
+	if (hlt_works(smp_processor_id()))
 		for(;;) halt();
 	for (;;);
 }
arch/x86/kernel/smp_64.c +3 -2
index e4494e8..4e1e2bc 100644
@@ -416,8 +416,9 @@ static void stop_this_cpu(void *dummy)
 	 */
 	cpu_clear(smp_processor_id(), cpu_online_map);
 	disable_local_APIC();
-	for (;;)
-		halt();
+	if (hlt_works(smp_processor_id()))
+		for (;;) halt();
+	for (;;);
 }
 
 void smp_send_stop(void)
Signature · 1 line
1.5.0.6
#22 lore raw

PATCH 22/52 add reboot_force test to native_smp_send_stop

This can be safely added to i386. After that,
functions look exactly the same for both arches

---
 arch/x86/kernel/smp_32.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
arch/x86/kernel/smp_32.c +7 -2
index cde3a0e..8be3e09 100644
@@ -24,6 +24,7 @@
 #include <asm/tlbflush.h>
 #include <asm/mmu_context.h>
 #include <mach_apic.h>
+#include <asm/proto.h>
 
 /*
  *	Some notes on x86 processor bugs affecting SMP operation:
@@ -622,10 +623,14 @@ static void stop_this_cpu (void * dummy)
 
 static void native_smp_send_stop(void)
 {
-	/* Don't deadlock on the call lock in panic */
-	int nolock = !spin_trylock(&call_lock);
+	int nolock;
 	unsigned long flags;
 
+	if (reboot_force)
+		return;
+
+	/* Don't deadlock on the call lock in panic */
+	nolock = !spin_trylock(&call_lock);
 	local_irq_save(flags);
 	__smp_call_function(stop_this_cpu, NULL, 0, 0);
 	if (!nolock)
Signature · 1 line
1.5.0.6
#23 lore raw

PATCH 23/52 unify smp_send_stop

function definition is moved to common header.
x86_64 version is now called native_smp_send_stop

---
 arch/x86/kernel/smp_64.c |    3 ++-
 include/asm-x86/smp.h    |    5 +++++
 include/asm-x86/smp_32.h |    5 -----
 3 files changed, 7 insertions(+), 6 deletions(-)
arch/x86/kernel/smp_64.c +2 -1
index 4e1e2bc..ad11ef0 100644
@@ -421,7 +421,7 @@ static void stop_this_cpu(void *dummy)
 	for (;;);
 }
 
-void smp_send_stop(void)
+void native_smp_send_stop(void)
 {
 	int nolock;
 	unsigned long flags;
@@ -482,6 +482,7 @@ struct smp_ops smp_ops = {
 	.smp_prepare_cpus = native_smp_prepare_cpus,
 	.smp_cpus_done = native_smp_cpus_done,
 
+	.smp_send_stop = native_smp_send_stop,
 	.smp_send_reschedule = native_smp_send_reschedule,
 	.smp_call_function_mask = native_smp_call_function_mask,
 	.cpu_up = native_cpu_up,
include/asm-x86/smp.h +5 -0
index 28cb1f8..2ab8ed4 100644
@@ -25,6 +25,11 @@ struct smp_ops {
 #ifdef CONFIG_SMP
 extern struct smp_ops smp_ops;
 
+static inline void smp_send_stop(void)
+{
+	smp_ops.smp_send_stop();
+}
+
 static inline void smp_prepare_boot_cpu(void)
 {
 	smp_ops.smp_prepare_boot_cpu();
include/asm-x86/smp_32.h +0 -5
index bc90a4e..41b58e0 100644
@@ -39,11 +39,6 @@ extern void remove_siblinginfo(int cpu);
 extern void set_cpu_sibling_map(int cpu);
 
 #ifdef CONFIG_SMP
-static inline void smp_send_stop(void)
-{
-	smp_ops.smp_send_stop();
-}
-
 #ifndef CONFIG_PARAVIRT
 #define startup_ipi_hook(phys_apicid, start_eip, start_esp) do { } while (0)
 #endif
Signature · 1 line
1.5.0.6
#24 lore raw

PATCH 24/52 create smp.c

this patch moves all the functions and data structures that look like exactly the same from smp_{32,64}.c to smp.c

---
 arch/x86/kernel/Makefile |    3 +-
 arch/x86/kernel/smp.c    |  253 ++++++++++++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/smp_32.c |  223 ----------------------------------------
 arch/x86/kernel/smp_64.c |  205 -------------------------------------
 4 files changed, 255 insertions(+), 429 deletions(-)
 create mode 100644 arch/x86/kernel/smp.c
arch/x86/kernel/Makefile +2 -1
index 018d04d..0a4b088 100644
@@ -46,7 +46,8 @@ obj-$(CONFIG_MICROCODE)		+= microcode.o
 obj-$(CONFIG_PCI)		+= early-quirks.o
 apm-y				:= apm_32.o
 obj-$(CONFIG_APM)		+= apm.o
-obj-$(CONFIG_X86_SMP)		+= smp_$(BITS).o smpboot_$(BITS).o smpboot.o tsc_sync.o
+obj-$(CONFIG_X86_SMP)		+= smp_$(BITS).o smpboot_$(BITS).o smp.o
+obj-$(CONFIG_X86_SMP)		+= smpboot.o tsc_sync.o
 obj-$(CONFIG_X86_32_SMP)	+= smpcommon.o
 obj-$(CONFIG_X86_64_SMP)	+= smp_64.o smpboot_64.o tsc_sync.o smpcommon.o
 obj-$(CONFIG_X86_TRAMPOLINE)	+= trampoline_$(BITS).o
arch/x86/kernel/smp.c new file +253 -0

253 lines not on this page · raw message

arch/x86/kernel/smp_32.c +0 -223

232 lines not on this page · raw message

arch/x86/kernel/smp_64.c +0 -205

208 lines not on this page · raw message

Signature · 1 line
1.5.0.6
#25 lore raw

PATCH 25/52 create ipi.c

This patch moves all ipi and apic related functions from smp_32.c to ipi.c

---
 arch/x86/kernel/Makefile |    2 +-
 arch/x86/kernel/ipi.c    |  178 ++++++++++++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/smp_32.c |  153 ---------------------------------------
 3 files changed, 179 insertions(+), 154 deletions(-)
 create mode 100644 arch/x86/kernel/ipi.c
arch/x86/kernel/Makefile +1 -1
index 0a4b088..e3b01f9 100644
@@ -47,7 +47,7 @@ obj-$(CONFIG_PCI)		+= early-quirks.o
 apm-y				:= apm_32.o
 obj-$(CONFIG_APM)		+= apm.o
 obj-$(CONFIG_X86_SMP)		+= smp_$(BITS).o smpboot_$(BITS).o smp.o
-obj-$(CONFIG_X86_SMP)		+= smpboot.o tsc_sync.o
+obj-$(CONFIG_X86_SMP)		+= smpboot.o tsc_sync.o ipi.o
 obj-$(CONFIG_X86_32_SMP)	+= smpcommon.o
 obj-$(CONFIG_X86_64_SMP)	+= smp_64.o smpboot_64.o tsc_sync.o smpcommon.o
 obj-$(CONFIG_X86_TRAMPOLINE)	+= trampoline_$(BITS).o
arch/x86/kernel/ipi.c new file +178 -0

178 lines not on this page · raw message

arch/x86/kernel/smp_32.c +0 -153

162 lines not on this page · raw message

Signature · 1 line
1.5.0.6
#26 lore raw

PATCH 26/52 create tlb files

this patch creates tlb_32.c and tlb_64.c, with tlb-related functions that used to live in smp*.c files.

---
 arch/x86/kernel/Makefile |    2 +-
 arch/x86/kernel/smp_32.c |  235 ---------------------------------------
 arch/x86/kernel/smp_64.c |  275 ----------------------------------------------
 arch/x86/kernel/tlb_32.c |  243 ++++++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/tlb_64.c |  273 +++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 517 insertions(+), 511 deletions(-)
 create mode 100644 arch/x86/kernel/tlb_32.c
 create mode 100644 arch/x86/kernel/tlb_64.c
arch/x86/kernel/Makefile +1 -1
index e3b01f9..362ab6a 100644
@@ -47,7 +47,7 @@ obj-$(CONFIG_PCI)		+= early-quirks.o
 apm-y				:= apm_32.o
 obj-$(CONFIG_APM)		+= apm.o
 obj-$(CONFIG_X86_SMP)		+= smp_$(BITS).o smpboot_$(BITS).o smp.o
-obj-$(CONFIG_X86_SMP)		+= smpboot.o tsc_sync.o ipi.o
+obj-$(CONFIG_X86_SMP)		+= smpboot.o tsc_sync.o ipi.o tlb_$(BITS).o
 obj-$(CONFIG_X86_32_SMP)	+= smpcommon.o
 obj-$(CONFIG_X86_64_SMP)	+= smp_64.o smpboot_64.o tsc_sync.o smpcommon.o
 obj-$(CONFIG_X86_TRAMPOLINE)	+= trampoline_$(BITS).o
arch/x86/kernel/smp_32.c +0 -235

238 lines not on this page · raw message

arch/x86/kernel/smp_64.c +0 -275

278 lines not on this page · raw message

arch/x86/kernel/tlb_32.c new file +243 -0

243 lines not on this page · raw message

arch/x86/kernel/tlb_64.c new file +273 -0

273 lines not on this page · raw message

Signature · 1 line
1.5.0.6
#27 lore raw

PATCH 27/52 get rid of smp_32.c and smp_64.c

This patch merges the copyright notices, and valuable comments that were left back on smp_{32,64}.c. With that, files are empty, and are deleted

---
 arch/x86/kernel/Makefile |    2 +-
 arch/x86/kernel/smp.c    |   91 +++++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/smp_32.c |  106 ----------------------------------------------
 arch/x86/kernel/smp_64.c |   10 ----
 4 files changed, 92 insertions(+), 117 deletions(-)
 delete mode 100644 arch/x86/kernel/smp_32.c
 delete mode 100644 arch/x86/kernel/smp_64.c
arch/x86/kernel/Makefile +2 -2
Index: linux-2.6-x86/arch/x86/kernel/Makefile
===================================================================
@@ -46,10 +46,10 @@
 obj-$(CONFIG_PCI)		+= early-quirks.o
 apm-y				:= apm_32.o
 obj-$(CONFIG_APM)		+= apm.o
-obj-$(CONFIG_X86_SMP)		+= smp_$(BITS).o smpboot_$(BITS).o smp.o
+obj-$(CONFIG_X86_SMP)		+= smpboot_$(BITS).o smp.o
 obj-$(CONFIG_X86_SMP)		+= smpboot.o tsc_sync.o ipi.o tlb_$(BITS).o
 obj-$(CONFIG_X86_32_SMP)	+= smpcommon.o
-obj-$(CONFIG_X86_64_SMP)	+= smp_64.o smpboot_64.o tsc_sync.o smpcommon.o
+obj-$(CONFIG_X86_64_SMP)	+= smpboot_64.o tsc_sync.o smpcommon.o
 obj-$(CONFIG_X86_TRAMPOLINE)	+= trampoline_$(BITS).o
 obj-$(CONFIG_X86_MPPARSE)	+= mpparse_$(BITS).o
 obj-$(CONFIG_X86_LOCAL_APIC)	+= apic_$(BITS).o nmi_$(BITS).o
arch/x86/kernel/smp.c +91 -0

100 lines not on this page · raw message

arch/x86/kernel/smp_32.c deleted +0 -106

106 lines not on this page · raw message

arch/x86/kernel/smp_64.c deleted +0 -10
Index: linux-2.6-x86/arch/x86/kernel/smp_64.c
===================================================================
@@ -1,10 +0,0 @@
-/*
- *	Intel SMP support routines.
- *
- *	(c) 1995 Alan Cox, Building #3 <[email protected]>
- *	(c) 1998-99, 2000 Ingo Molnar <[email protected]>
- *      (c) 2002,2003 Andi Kleen, SuSE Labs.
- *
- *	This code is released under the GNU General Public License version 2 or
- *	later.
- */
#28 lore raw

PATCH 28/52 remove cpu_llc_id from processor.h

it is already defined in smp.h

---
 include/asm-x86/processor.h |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
include/asm-x86/processor.h +1 -3
index 8bec23c..e49e5e6 100644
@@ -355,9 +355,7 @@ union i387_union {
 	struct i387_soft_struct		soft;
 };
 
-#ifdef CONFIG_X86_32
-DECLARE_PER_CPU(u8, cpu_llc_id);
-#else
+#ifdef CONFIG_X86_64
 DECLARE_PER_CPU(struct orig_ist, orig_ist);
 #endif
 
Signature · 1 line
1.5.0.6
#29 lore raw

PATCH 29/52 adjust types in smpcommon_32.c

so they can have the same type as x86_64

---
 arch/x86/kernel/smpboot_32.c |    6 +++---
 include/asm-x86/smp_32.h     |    6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)
arch/x86/kernel/smpboot_32.c +3 -3
index 579b9b7..5a446f0 100644
@@ -67,7 +67,7 @@ int smp_num_siblings = 1;
 EXPORT_SYMBOL(smp_num_siblings);
 
 /* Last level cache ID of each logical CPU */
-DEFINE_PER_CPU(u8, cpu_llc_id) = BAD_APICID;
+DEFINE_PER_CPU(u16, cpu_llc_id) = BAD_APICID;
 
 /* representing HT siblings of each logical CPU */
 DEFINE_PER_CPU(cpumask_t, cpu_sibling_map);
@@ -92,10 +92,10 @@ DEFINE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info);
 EXPORT_PER_CPU_SYMBOL(cpu_info);
 
 /* which logical CPU number maps to which CPU (physical APIC ID) */
-u8 x86_cpu_to_apicid_init[NR_CPUS] __initdata =
+u16 x86_cpu_to_apicid_init[NR_CPUS] __initdata =
 			{ [0 ... NR_CPUS-1] = BAD_APICID };
 void *x86_cpu_to_apicid_early_ptr;
-DEFINE_PER_CPU(u8, x86_cpu_to_apicid) = BAD_APICID;
+DEFINE_PER_CPU(u16, x86_cpu_to_apicid) = BAD_APICID;
 EXPORT_PER_CPU_SYMBOL(x86_cpu_to_apicid);
 
 u8 apicid_2_node[MAX_APICID];
include/asm-x86/smp_32.h +3 -3
index 41b58e0..29f6195 100644
@@ -21,13 +21,13 @@ extern cpumask_t cpu_callin_map;
 extern void (*mtrr_hook) (void);
 extern void zap_low_mappings (void);
 
-extern u8 __initdata x86_cpu_to_apicid_init[];
+extern u16 __initdata x86_cpu_to_apicid_init[];
 extern void *x86_cpu_to_apicid_early_ptr;
 
 DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
 DECLARE_PER_CPU(cpumask_t, cpu_core_map);
-DECLARE_PER_CPU(u8, cpu_llc_id);
-DECLARE_PER_CPU(u8, x86_cpu_to_apicid);
+DECLARE_PER_CPU(u16, cpu_llc_id);
+DECLARE_PER_CPU(u16, x86_cpu_to_apicid);
 
 #ifdef CONFIG_HOTPLUG_CPU
 extern void cpu_exit_clear(void);
Signature · 1 line
1.5.0.6
#30 lore raw

PATCH 30/52 move equal types to common file

move definitions that are now equal in type from
smpboot_{32,64}.c to smpboot.c

cpu_callin_map is put temporarily in smp_64.h (already exists in smp_32.h), and will soon be merged.

---
 arch/x86/kernel/smpboot.c    |   28 ++++++++++++++++++++++++++++
 arch/x86/kernel/smpboot_32.c |   27 ---------------------------
 arch/x86/kernel/smpboot_64.c |   33 ---------------------------------
 include/asm-x86/smp_64.h     |    1 +
 4 files changed, 29 insertions(+), 60 deletions(-)
arch/x86/kernel/smpboot.c +28 -0
index bffe108..40a3b56 100644
@@ -1,6 +1,34 @@
 #include <linux/init.h>
 #include <linux/smp.h>
+#include <linux/module.h>
 
+/* Number of siblings per CPU package */
+int smp_num_siblings = 1;
+EXPORT_SYMBOL(smp_num_siblings);
+
+/* Last level cache ID of each logical CPU */
+DEFINE_PER_CPU(u16, cpu_llc_id) = BAD_APICID;
+
+/* bitmap of online cpus */
+cpumask_t cpu_online_map __read_mostly;
+EXPORT_SYMBOL(cpu_online_map);
+
+cpumask_t cpu_callin_map;
+cpumask_t cpu_callout_map;
+cpumask_t cpu_possible_map;
+EXPORT_SYMBOL(cpu_possible_map);
+
+/* representing HT siblings of each logical CPU */
+DEFINE_PER_CPU(cpumask_t, cpu_sibling_map);
+EXPORT_PER_CPU_SYMBOL(cpu_sibling_map);
+
+/* representing HT and core siblings of each logical CPU */
+DEFINE_PER_CPU(cpumask_t, cpu_core_map);
+EXPORT_PER_CPU_SYMBOL(cpu_core_map);
+
+/* Per CPU bogomips and other parameters */
+DEFINE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info);
+EXPORT_PER_CPU_SYMBOL(cpu_info);
 #ifdef CONFIG_HOTPLUG_CPU
 
 int additional_cpus __initdata = -1;
arch/x86/kernel/smpboot_32.c +0 -27
index 5a446f0..0fbc981 100644
@@ -62,35 +62,8 @@
 /* Set if we find a B stepping CPU */
 static int __cpuinitdata smp_b_stepping;
 
-/* Number of siblings per CPU package */
-int smp_num_siblings = 1;
-EXPORT_SYMBOL(smp_num_siblings);
-
-/* Last level cache ID of each logical CPU */
-DEFINE_PER_CPU(u16, cpu_llc_id) = BAD_APICID;
-
-/* representing HT siblings of each logical CPU */
-DEFINE_PER_CPU(cpumask_t, cpu_sibling_map);
-EXPORT_PER_CPU_SYMBOL(cpu_sibling_map);
-
-/* representing HT and core siblings of each logical CPU */
-DEFINE_PER_CPU(cpumask_t, cpu_core_map);
-EXPORT_PER_CPU_SYMBOL(cpu_core_map);
-
-/* bitmap of online cpus */
-cpumask_t cpu_online_map __read_mostly;
-EXPORT_SYMBOL(cpu_online_map);
-
-cpumask_t cpu_callin_map;
-cpumask_t cpu_callout_map;
-cpumask_t cpu_possible_map;
-EXPORT_SYMBOL(cpu_possible_map);
 static cpumask_t smp_commenced_mask;
 
-/* Per CPU bogomips and other parameters */
-DEFINE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info);
-EXPORT_PER_CPU_SYMBOL(cpu_info);
-
 /* which logical CPU number maps to which CPU (physical APIC ID) */
 u16 x86_cpu_to_apicid_init[NR_CPUS] __initdata =
 			{ [0 ... NR_CPUS-1] = BAD_APICID };
arch/x86/kernel/smpboot_64.c +0 -33
index 953b0ff..c51279f 100644
@@ -60,42 +60,9 @@
 #include <asm/hw_irq.h>
 #include <asm/numa.h>
 
-/* Number of siblings per CPU package */
-int smp_num_siblings = 1;
-EXPORT_SYMBOL(smp_num_siblings);
-
-/* Last level cache ID of each logical CPU */
-DEFINE_PER_CPU(u16, cpu_llc_id) = BAD_APICID;
-
-/* Bitmask of currently online CPUs */
-cpumask_t cpu_online_map __read_mostly;
-
-EXPORT_SYMBOL(cpu_online_map);
-
-/*
- * Private maps to synchronize booting between AP and BP.
- * Probably not needed anymore, but it makes for easier debugging. -AK
- */
-cpumask_t cpu_callin_map;
-cpumask_t cpu_callout_map;
-cpumask_t cpu_possible_map;
-EXPORT_SYMBOL(cpu_possible_map);
-
-/* Per CPU bogomips and other parameters */
-DEFINE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info);
-EXPORT_PER_CPU_SYMBOL(cpu_info);
-
 /* Set when the idlers are all forked */
 int smp_threads_ready;
 
-/* representing HT siblings of each logical CPU */
-DEFINE_PER_CPU(cpumask_t, cpu_sibling_map);
-EXPORT_PER_CPU_SYMBOL(cpu_sibling_map);
-
-/* representing HT and core siblings of each logical CPU */
-DEFINE_PER_CPU(cpumask_t, cpu_core_map);
-EXPORT_PER_CPU_SYMBOL(cpu_core_map);
-
 /*
  * Trampoline 80x86 program as an array.
  */
include/asm-x86/smp_64.h +1 -0
index e5bc1be..1ecf813 100644
@@ -14,6 +14,7 @@
 #include <asm/thread_info.h>
 
 extern cpumask_t cpu_initialized;
+extern cpumask_t cpu_callin_map;
 
 extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *),
 				  void *info, int wait);
Signature · 1 line
1.5.0.6
#31 lore raw

PATCH 31/52 make set_cpu_sibling_map nonstatic

And move its extern definition to smp.h, the common header

---
 arch/x86/kernel/smpboot_64.c |    2 +-
 include/asm-x86/smp.h        |    3 +++
 include/asm-x86/smp_32.h     |    3 ---
 3 files changed, 4 insertions(+), 4 deletions(-)
arch/x86/kernel/smpboot_64.c +1 -1
index c51279f..1e8f00a 100644
@@ -228,7 +228,7 @@ cpumask_t cpu_coregroup_map(int cpu)
 /* representing cpus for which sibling maps can be computed */
 static cpumask_t cpu_sibling_setup_map;
 
-static inline void set_cpu_sibling_map(int cpu)
+void __cpuinit set_cpu_sibling_map(int cpu)
 {
 	int i;
 	struct cpuinfo_x86 *c = &cpu_data(cpu);
include/asm-x86/smp.h +3 -0
index 2ab8ed4..1b4481a 100644
@@ -22,6 +22,9 @@ struct smp_ops {
 				      int wait);
 };
 
+/* Globals due to paravirt */
+extern void set_cpu_sibling_map(int cpu);
+
 #ifdef CONFIG_SMP
 extern struct smp_ops smp_ops;
 
include/asm-x86/smp_32.h +0 -3
index 29f6195..76247a9 100644
@@ -35,9 +35,6 @@ extern void cpu_uninit(void);
 extern void remove_siblinginfo(int cpu);
 #endif
 
-/* Globals due to paravirt */
-extern void set_cpu_sibling_map(int cpu);
-
 #ifdef CONFIG_SMP
 #ifndef CONFIG_PARAVIRT
 #define startup_ipi_hook(phys_apicid, start_eip, start_esp) do { } while (0)
Signature · 1 line
1.5.0.6
#32 lore raw

PATCH 32/52 make remove_siblinginfo non-static

this is done to match i386

---
 arch/x86/kernel/smpboot_64.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kernel/smpboot_64.c +1 -1
index 1e8f00a..20f1c7d 100644
@@ -918,7 +918,7 @@ void __init native_smp_cpus_done(unsigned int max_cpus)
 
 #ifdef CONFIG_HOTPLUG_CPU
 
-static void remove_siblinginfo(int cpu)
+void remove_siblinginfo(int cpu)
 {
 	int sibling;
 	struct cpuinfo_x86 *c = &cpu_data(cpu);
Signature · 1 line
1.5.0.6
#33 lore raw

PATCH 33/52 move hotplug related extern definitions to smp.h

definitions that are inside CONFIG_HOTPLUG_CPU in the arch-specific smp*.h files are moved to common header

---
 include/asm-x86/smp.h    |    6 ++++++
 include/asm-x86/smp_32.h |    6 ------
 2 files changed, 6 insertions(+), 6 deletions(-)
include/asm-x86/smp.h +6 -0
index 1b4481a..c800b81 100644
@@ -80,6 +80,12 @@ extern void prefill_possible_map(void);
 # include "smp_64.h"
 #endif
 
+#ifdef CONFIG_HOTPLUG_CPU
+extern void cpu_exit_clear(void);
+extern void cpu_uninit(void);
+extern void remove_siblinginfo(int cpu);
+#endif
+
 extern void smp_alloc_memory(void);
 extern void lock_ipi_call_lock(void);
 extern void unlock_ipi_call_lock(void);
include/asm-x86/smp_32.h +0 -6
index 76247a9..0b25134 100644
@@ -29,12 +29,6 @@ DECLARE_PER_CPU(cpumask_t, cpu_core_map);
 DECLARE_PER_CPU(u16, cpu_llc_id);
 DECLARE_PER_CPU(u16, x86_cpu_to_apicid);
 
-#ifdef CONFIG_HOTPLUG_CPU
-extern void cpu_exit_clear(void);
-extern void cpu_uninit(void);
-extern void remove_siblinginfo(int cpu);
-#endif
-
 #ifdef CONFIG_SMP
 #ifndef CONFIG_PARAVIRT
 #define startup_ipi_hook(phys_apicid, start_eip, start_esp) do { } while (0)
Signature · 1 line
1.5.0.6
#34 lore raw

PATCH 34/52 move sibling functions to common file

set_cpu_sibling_map() and remove_sibling_info() are equal between architectures, and are now moved to common file

---
 arch/x86/kernel/smpboot.c    |   88 +++++++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/smpboot_32.c |   88 -----------------------------------------
 arch/x86/kernel/smpboot_64.c |   89 ------------------------------------------
 3 files changed, 88 insertions(+), 177 deletions(-)
arch/x86/kernel/smpboot.c +88 -0
index 40a3b56..d774520 100644
@@ -29,7 +29,95 @@ EXPORT_PER_CPU_SYMBOL(cpu_core_map);
 /* Per CPU bogomips and other parameters */
 DEFINE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info);
 EXPORT_PER_CPU_SYMBOL(cpu_info);
+
+/* representing cpus for which sibling maps can be computed */
+static cpumask_t cpu_sibling_setup_map;
+
+void __cpuinit set_cpu_sibling_map(int cpu)
+{
+	int i;
+	struct cpuinfo_x86 *c = &cpu_data(cpu);
+
+	cpu_set(cpu, cpu_sibling_setup_map);
+
+	if (smp_num_siblings > 1) {
+		for_each_cpu_mask(i, cpu_sibling_setup_map) {
+			if (c->phys_proc_id == cpu_data(i).phys_proc_id &&
+			    c->cpu_core_id == cpu_data(i).cpu_core_id) {
+				cpu_set(i, per_cpu(cpu_sibling_map, cpu));
+				cpu_set(cpu, per_cpu(cpu_sibling_map, i));
+				cpu_set(i, per_cpu(cpu_core_map, cpu));
+				cpu_set(cpu, per_cpu(cpu_core_map, i));
+				cpu_set(i, c->llc_shared_map);
+				cpu_set(cpu, cpu_data(i).llc_shared_map);
+			}
+		}
+	} else {
+		cpu_set(cpu, per_cpu(cpu_sibling_map, cpu));
+	}
+
+	cpu_set(cpu, c->llc_shared_map);
+
+	if (current_cpu_data.x86_max_cores == 1) {
+		per_cpu(cpu_core_map, cpu) = per_cpu(cpu_sibling_map, cpu);
+		c->booted_cores = 1;
+		return;
+	}
+
+	for_each_cpu_mask(i, cpu_sibling_setup_map) {
+		if (per_cpu(cpu_llc_id, cpu) != BAD_APICID &&
+		    per_cpu(cpu_llc_id, cpu) == per_cpu(cpu_llc_id, i)) {
+			cpu_set(i, c->llc_shared_map);
+			cpu_set(cpu, cpu_data(i).llc_shared_map);
+		}
+		if (c->phys_proc_id == cpu_data(i).phys_proc_id) {
+			cpu_set(i, per_cpu(cpu_core_map, cpu));
+			cpu_set(cpu, per_cpu(cpu_core_map, i));
+			/*
+			 *  Does this new cpu bringup a new core?
+			 */
+			if (cpus_weight(per_cpu(cpu_sibling_map, cpu)) == 1) {
+				/*
+				 * for each core in package, increment
+				 * the booted_cores for this new cpu
+				 */
+				if (first_cpu(per_cpu(cpu_sibling_map, i)) == i)
+					c->booted_cores++;
+				/*
+				 * increment the core count for all
+				 * the other cpus in this package
+				 */
+				if (i != cpu)
+					cpu_data(i).booted_cores++;
+			} else if (i != cpu && !c->booted_cores)
+				c->booted_cores = cpu_data(i).booted_cores;
+		}
+	}
+}
+
 #ifdef CONFIG_HOTPLUG_CPU
+void remove_siblinginfo(int cpu)
+{
+	int sibling;
+	struct cpuinfo_x86 *c = &cpu_data(cpu);
+
+	for_each_cpu_mask(sibling, per_cpu(cpu_core_map, cpu)) {
+		cpu_clear(cpu, per_cpu(cpu_core_map, sibling));
+		/*/
+		 * last thread sibling in this cpu core going down
+		 */
+		if (cpus_weight(per_cpu(cpu_sibling_map, cpu)) == 1)
+			cpu_data(sibling).booted_cores--;
+	}
+
+	for_each_cpu_mask(sibling, per_cpu(cpu_sibling_map, cpu))
+		cpu_clear(cpu, per_cpu(cpu_sibling_map, sibling));
+	cpus_clear(per_cpu(cpu_sibling_map, cpu));
+	cpus_clear(per_cpu(cpu_core_map, cpu));
+	c->phys_proc_id = 0;
+	c->cpu_core_id = 0;
+	cpu_clear(cpu, cpu_sibling_setup_map);
+}
 
 int additional_cpus __initdata = -1;
 
arch/x86/kernel/smpboot_32.c +0 -88

100 lines not on this page · raw message

arch/x86/kernel/smpboot_64.c +0 -89

101 lines not on this page · raw message

Signature · 1 line
1.5.0.6
#35 lore raw

PATCH 35/52 move cpu_coregroup_map to common file

it is equal between architectures

---
 arch/x86/kernel/smpboot.c    |   16 ++++++++++++++++
 arch/x86/kernel/smpboot_32.c |   14 --------------
 arch/x86/kernel/smpboot_64.c |   14 --------------
 3 files changed, 16 insertions(+), 28 deletions(-)
arch/x86/kernel/smpboot.c +16 -0
index d774520..644e609 100644
@@ -1,6 +1,7 @@
 #include <linux/init.h>
 #include <linux/smp.h>
 #include <linux/module.h>
+#include <linux/sched.h>
 
 /* Number of siblings per CPU package */
 int smp_num_siblings = 1;
@@ -95,6 +96,21 @@ void __cpuinit set_cpu_sibling_map(int cpu)
 	}
 }
 
+/* maps the cpu to the sched domain representing multi-core */
+cpumask_t cpu_coregroup_map(int cpu)
+{
+	struct cpuinfo_x86 *c = &cpu_data(cpu);
+	/*
+	 * For perf, we return last level cache shared map.
+	 * And for power savings, we return cpu_core_map
+	 */
+	if (sched_mc_power_savings || sched_smt_power_savings)
+		return per_cpu(cpu_core_map, cpu);
+	else
+		return c->llc_shared_map;
+}
+
+
 #ifdef CONFIG_HOTPLUG_CPU
 void remove_siblinginfo(int cpu)
 {
arch/x86/kernel/smpboot_32.c +0 -14
index 322f466..a58ca7f 100644
@@ -260,20 +260,6 @@ static void __cpuinit smp_callin(void)
 
 static int cpucount;
 
-/* maps the cpu to the sched domain representing multi-core */
-cpumask_t cpu_coregroup_map(int cpu)
-{
-	struct cpuinfo_x86 *c = &cpu_data(cpu);
-	/*
-	 * For perf, we return last level cache shared map.
-	 * And for power savings, we return cpu_core_map
-	 */
-	if (sched_mc_power_savings || sched_smt_power_savings)
-		return per_cpu(cpu_core_map, cpu);
-	else
-		return c->llc_shared_map;
-}
-
 /*
  * Activate a secondary processor.
  */
arch/x86/kernel/smpboot_64.c +0 -14
index 329f9c5..1a59240 100644
@@ -211,20 +211,6 @@ void __cpuinit smp_callin(void)
 	cpu_set(cpuid, cpu_callin_map);
 }
 
-/* maps the cpu to the sched domain representing multi-core */
-cpumask_t cpu_coregroup_map(int cpu)
-{
-	struct cpuinfo_x86 *c = &cpu_data(cpu);
-	/*
-	 * For perf, we return last level cache shared map.
-	 * And for power savings, we return cpu_core_map
-	 */
-	if (sched_mc_power_savings || sched_smt_power_savings)
-		return per_cpu(cpu_core_map, cpu);
-	else
-		return c->llc_shared_map;
-}
-
 /*
  * Setup code on secondary processor (after comming out of the trampoline)
  */
Signature · 1 line
1.5.0.6
#36 lore raw

PATCH 36/52 remove vector_lock around cpu_online_map

This lock does not protect cpu_online_map, so its length can be shortened, and in some cases, removed.

---
 arch/x86/kernel/smpboot_64.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
arch/x86/kernel/smpboot_64.c +1 -3
index 1a59240..ca3a3c5 100644
@@ -261,9 +261,9 @@ void __cpuinit start_secondary(void)
 	/*
 	 * Allow the master to continue.
 	 */
+	spin_unlock(&vector_lock);
 	cpu_set(smp_processor_id(), cpu_online_map);
 	per_cpu(cpu_state, smp_processor_id()) = CPU_ONLINE;
-	spin_unlock(&vector_lock);
 
 	unlock_ipi_call_lock();
 
@@ -879,10 +879,8 @@ int __cpu_disable(void)
 	local_irq_disable();
 	remove_siblinginfo(cpu);
 
-	spin_lock(&vector_lock);
 	/* It's now safe to remove this processor from the online map */
 	cpu_clear(cpu, cpu_online_map);
-	spin_unlock(&vector_lock);
 	remove_cpu_from_maps();
 	fixup_irqs(cpu_online_map);
 	return 0;
Signature · 1 line
1.5.0.6
#37 lore raw

PATCH 37/52 use remove_from_maps in cpu_disable

it is already used in x86_64. In i386, it only
removes from cpu_online_map

---
 arch/x86/kernel/smpboot_32.c |    7 ++++++-
 arch/x86/kernel/smpboot_64.c |    8 +++-----
 2 files changed, 9 insertions(+), 6 deletions(-)
arch/x86/kernel/smpboot_32.c +6 -1
index a58ca7f..4939b3a 100644
@@ -1041,6 +1041,11 @@ void __init native_smp_prepare_boot_cpu(void)
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
+static void __ref remove_cpu_from_maps(int cpu)
+{
+	cpu_clear(cpu, cpu_online_map);
+}
+
 int __cpu_disable(void)
 {
 	cpumask_t map = cpu_online_map;
@@ -1066,7 +1071,7 @@ int __cpu_disable(void)
 
 	remove_siblinginfo(cpu);
 
-	cpu_clear(cpu, map);
+	remove_cpu_from_maps(cpu);
 	fixup_irqs(map);
 	/* It's now safe to remove this processor from the online map */
 	cpu_clear(cpu, cpu_online_map);
arch/x86/kernel/smpboot_64.c +3 -5
index ca3a3c5..6509d3c 100644
@@ -838,10 +838,9 @@ void __init native_smp_cpus_done(unsigned int max_cpus)
 }
 
 #ifdef CONFIG_HOTPLUG_CPU
-static void __ref remove_cpu_from_maps(void)
+static void __ref remove_cpu_from_maps(int cpu)
 {
-	int cpu = smp_processor_id();
-
+	cpu_clear(cpu, cpu_online_map);
 	cpu_clear(cpu, cpu_callout_map);
 	cpu_clear(cpu, cpu_callin_map);
 	clear_bit(cpu, (unsigned long *)&cpu_initialized); /* was set by cpu_init() */
@@ -880,8 +879,7 @@ int __cpu_disable(void)
 	remove_siblinginfo(cpu);
 
 	/* It's now safe to remove this processor from the online map */
-	cpu_clear(cpu, cpu_online_map);
-	remove_cpu_from_maps();
+	remove_cpu_from_maps(cpu);
 	fixup_irqs(cpu_online_map);
 	return 0;
 }
Signature · 1 line
1.5.0.6
#38 lore raw

PATCH 38/52 do not clear cpu_online_map

it was already cleared two lines above, and so, this removal is bogus

---
 arch/x86/kernel/smpboot_32.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
arch/x86/kernel/smpboot_32.c +1 -2
index 4939b3a..3d21c66 100644
@@ -1073,8 +1073,7 @@ int __cpu_disable(void)
 
 	remove_cpu_from_maps(cpu);
 	fixup_irqs(map);
-	/* It's now safe to remove this processor from the online map */
-	cpu_clear(cpu, cpu_online_map);
+
 	return 0;
 }
 
Signature · 1 line
1.5.0.6
#39 lore raw

PATCH 39/52 merge __cpu_disable and cpu_die

They are now equal, and are moved to a common file

---
 arch/x86/kernel/smpboot.c    |   85 ++++++++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/smpboot_32.c |   67 ---------------------------------
 arch/x86/kernel/smpboot_64.c |   79 ---------------------------------------
 include/asm-x86/smp.h        |    3 +
 include/asm-x86/smp_32.h     |    3 -
 include/asm-x86/smp_64.h     |    3 -
 6 files changed, 88 insertions(+), 152 deletions(-)
arch/x86/kernel/smpboot.c +85 -0
index 644e609..c35cd31 100644
@@ -2,6 +2,13 @@
 #include <linux/smp.h>
 #include <linux/module.h>
 #include <linux/sched.h>
+#include <linux/percpu.h>
+
+#include <asm/nmi.h>
+#include <asm/irq.h>
+#include <asm/smp.h>
+#include <asm/cpu.h>
+#include <asm/numa.h>
 
 /* Number of siblings per CPU package */
 int smp_num_siblings = 1;
@@ -181,5 +188,83 @@ __init void prefill_possible_map(void)
 	for (i = 0; i < possible; i++)
 		cpu_set(i, cpu_possible_map);
 }
+
+static void __ref remove_cpu_from_maps(int cpu)
+{
+	cpu_clear(cpu, cpu_online_map);
+#ifdef CONFIG_X86_64
+	cpu_clear(cpu, cpu_callout_map);
+	cpu_clear(cpu, cpu_callin_map);
+	/* was set by cpu_init() */
+	clear_bit(cpu, (unsigned long *)&cpu_initialized);
+	clear_node_cpumask(cpu);
+#endif
+}
+
+int __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();
+
+	/*
+	 * HACK:
+	 * Allow any queued timer interrupts to get serviced
+	 * This is only a temporary solution until we cleanup
+	 * fixup_irqs as we do for IA64.
+	 */
+	local_irq_enable();
+	mdelay(1);
+
+	local_irq_disable();
+	remove_siblinginfo(cpu);
+
+	/* It's now safe to remove this processor from the online map */
+	remove_cpu_from_maps(cpu);
+	fixup_irqs(cpu_online_map);
+	return 0;
+}
+
+void __cpu_die(unsigned int cpu)
+{
+	/* We don't do anything here: idle task is faking death itself. */
+	unsigned int i;
+
+	for (i = 0; i < 10; i++) {
+		/* They ack this in play_dead by setting CPU_DEAD */
+		if (per_cpu(cpu_state, cpu) == CPU_DEAD) {
+			printk(KERN_INFO "CPU %d is now offline\n", cpu);
+			if (1 == num_online_cpus())
+				alternatives_smp_switch(0);
+			return;
+		}
+		msleep(100);
+	}
+	printk(KERN_ERR "CPU %u didn't die...\n", cpu);
+}
+#else /* ... !CONFIG_HOTPLUG_CPU */
+int __cpu_disable(void)
+{
+	return -ENOSYS;
+}
+
+void __cpu_die(unsigned int cpu)
+{
+	/* We said "no" in __cpu_disable */
+	BUG();
+}
 #endif
 
arch/x86/kernel/smpboot_32.c +0 -67

73 lines not on this page · raw message

arch/x86/kernel/smpboot_64.c +0 -79

82 lines not on this page · raw message

include/asm-x86/smp.h +3 -0
index c800b81..27d9f65 100644
@@ -70,6 +70,9 @@ void native_smp_prepare_cpus(unsigned int max_cpus);
 void native_smp_cpus_done(unsigned int max_cpus);
 int native_cpu_up(unsigned int cpunum);
 
+extern int __cpu_disable(void);
+extern void __cpu_die(unsigned int cpu);
+
 extern unsigned disabled_cpus;
 extern void prefill_possible_map(void);
 #endif
include/asm-x86/smp_32.h +0 -3
index 0b25134..4fec2fe 100644
@@ -34,9 +34,6 @@ DECLARE_PER_CPU(u16, x86_cpu_to_apicid);
 #define startup_ipi_hook(phys_apicid, start_eip, start_esp) do { } while (0)
 #endif
 
-extern int __cpu_disable(void);
-extern void __cpu_die(unsigned int cpu);
-
 /*
  * This function is needed by all SMP systems. It must _always_ be valid
  * from the initial startup. We map APIC_BASE very early in page_setup(),
include/asm-x86/smp_64.h +0 -3
index 1ecf813..d554d7d 100644
@@ -42,9 +42,6 @@ static inline int cpu_present_to_apicid(int mps_cpu)
 
 #define SMP_TRAMPOLINE_BASE 0x6000
 
-extern int __cpu_disable(void);
-extern void __cpu_die(unsigned int cpu);
-
 #define raw_smp_processor_id()	read_pda(cpunumber)
 #define cpu_physical_id(cpu)	per_cpu(x86_cpu_to_apicid, cpu)
 
Signature · 1 line
1.5.0.6
#40 lore raw

PATCH 40/52 make x86_64 accept the max_cpus parameter

The parameter passing parsing is done in the common smpboot.c

---
 arch/x86/kernel/mpparse_64.c |    7 +++++++
 arch/x86/kernel/smpboot.c    |   12 ++++++++++++
 arch/x86/kernel/smpboot_32.c |   13 -------------
 3 files changed, 19 insertions(+), 13 deletions(-)
arch/x86/kernel/mpparse_64.c +7 -0
index 72ab140..2a1f788 100644
@@ -32,6 +32,7 @@
 
 /* Have we found an MP table */
 int smp_found_config;
+unsigned int __cpuinitdata maxcpus = NR_CPUS;
 
 /*
  * Various Linux-internal data structures created from the
@@ -115,6 +116,12 @@ static void __cpuinit MP_processor_info(struct mpc_config_processor *m)
 		return;
 	}
 
+	if (num_processors >= maxcpus) {
+		printk(KERN_WARNING "WARNING: maxcpus limit of %i reached."
+			" Processor ignored.\n", maxcpus);
+		return;
+	}
+
 	num_processors++;
 	cpus_complement(tmp_map, cpu_present_map);
 	cpu = first_cpu(tmp_map);
arch/x86/kernel/smpboot.c +12 -0
index c35cd31..34c3117 100644
@@ -268,3 +268,15 @@ void __cpu_die(unsigned int cpu)
 }
 #endif
 
+/*
+ * If the BIOS enumerates physical processors before logical,
+ * maxcpus=N at enumeration-time can be used to disable HT.
+ */
+static int __init parse_maxcpus(char *arg)
+{
+	extern unsigned int maxcpus;
+
+	maxcpus = simple_strtoul(arg, NULL, 0);
+	return 0;
+}
+early_param("maxcpus", parse_maxcpus);
arch/x86/kernel/smpboot_32.c +0 -13
index 00b1b59..3236e84 100644
@@ -1113,16 +1113,3 @@ void __init smp_intr_init(void)
 	/* IPI for generic function call */
 	set_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt);
 }
-
-/*
- * If the BIOS enumerates physical processors before logical,
- * maxcpus=N at enumeration-time can be used to disable HT.
- */
-static int __init parse_maxcpus(char *arg)
-{
-	extern unsigned int maxcpus;
-
-	maxcpus = simple_strtoul(arg, NULL, 0);
-	return 0;
-}
-early_param("maxcpus", parse_maxcpus);
Signature · 1 line
1.5.0.6
#41 lore raw

PATCH 41/52 move trampoline arrays extern definition to smp.h

In here, they can serve both architectures

---
 arch/x86/kernel/smpboot_32.c |    6 ------
 arch/x86/kernel/smpboot_64.c |    7 -------
 include/asm-x86/smp.h        |    6 ++++++
 3 files changed, 6 insertions(+), 13 deletions(-)
arch/x86/kernel/smpboot_32.c +0 -6
index 3236e84..a21f254 100644
@@ -73,12 +73,6 @@ EXPORT_PER_CPU_SYMBOL(x86_cpu_to_apicid);
 
 u8 apicid_2_node[MAX_APICID];
 
-/*
- * Trampoline 80x86 program as an array.
- */
-
-extern const unsigned char trampoline_data [];
-extern const unsigned char trampoline_end  [];
 static unsigned char *trampoline_base;
 
 static void map_cpu_to_logical_apicid(void);
arch/x86/kernel/smpboot_64.c +0 -7
index 0c67e5a..2cc1b8b 100644
@@ -63,13 +63,6 @@
 /* Set when the idlers are all forked */
 int smp_threads_ready;
 
-/*
- * Trampoline 80x86 program as an array.
- */
-
-extern const unsigned char trampoline_data[];
-extern const unsigned char trampoline_end[];
-
 /* State of each CPU */
 DEFINE_PER_CPU(int, cpu_state) = { 0 };
 
include/asm-x86/smp.h +6 -0
index 27d9f65..b2a1697 100644
@@ -9,6 +9,12 @@ extern cpumask_t cpu_callout_map;
 extern int smp_num_siblings;
 extern unsigned int num_processors;
 
+/*
+ * Trampoline 80x86 program as an array.
+ */
+extern const unsigned char trampoline_data [];
+extern const unsigned char trampoline_end  [];
+
 struct smp_ops {
 	void (*smp_prepare_boot_cpu)(void);
 	void (*smp_prepare_cpus)(unsigned max_cpus);
Signature · 1 line
1.5.0.6
#42 lore raw

PATCH 42/52 adapt voyager's trampoline_base

Change voyager's trampoline base to unsigned char * instead of u32. This way, it won't conflict with the other architectures when including smp.h

---
 arch/x86/mach-voyager/voyager_smp.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
arch/x86/mach-voyager/voyager_smp.c +4 -4
index 0b3f52a..0ab236e 100644
@@ -210,7 +210,7 @@ static int cpucount = 0;
 /* steal a page from the bottom of memory for the trampoline and
  * squirrel its address away here.  This will be in kernel virtual
  * space */
-static __u32 trampoline_base;
+unsigned char *trampoline_base;
 
 /* The per cpu profile stuff - used in smp_local_timer_interrupt */
 static DEFINE_PER_CPU(int, prof_multiplier) = 1;
@@ -435,9 +435,9 @@ static __u32 __init setup_trampoline(void)
 	extern const __u8 trampoline_end[];
 	extern const __u8 trampoline_data[];
 
-	memcpy((__u8 *) trampoline_base, trampoline_data,
+	memcpy(trampoline_base, trampoline_data,
 	       trampoline_end - trampoline_data);
-	return virt_to_phys((__u8 *) trampoline_base);
+	return virt_to_phys(trampoline_base);
 }
 
 /* Routine initially called when a non-boot CPU is brought online */
@@ -1166,7 +1166,7 @@ void flush_tlb_all(void)
  * is sorted out */
 void __init smp_alloc_memory(void)
 {
-	trampoline_base = (__u32) alloc_bootmem_low_pages(PAGE_SIZE);
+	trampoline_base = alloc_bootmem_low_pages(PAGE_SIZE);
 	if (__pa(trampoline_base) >= 0x93000)
 		BUG();
 }
Signature · 1 line
1.5.0.6
#43 lore raw

PATCH 43/52 adapt voyager's setup_trampoline

make setup_trampoline non-static. This way, it won't conflict with the extern declaration in smp.h

---
 arch/x86/mach-voyager/voyager_smp.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/mach-voyager/voyager_smp.c +1 -1
index 0ab236e..9ff687a 100644
@@ -429,7 +429,7 @@ void __init smp_store_cpu_info(int id)
 }
 
 /* set up the trampoline and return the physical address of the code */
-static __u32 __init setup_trampoline(void)
+unsigned long __init setup_trampoline(void)
 {
 	/* these two are global symbols in trampoline.S */
 	extern const __u8 trampoline_end[];
Signature · 1 line
1.5.0.6
#44 lore raw

PATCH 44/52 unify setup_trampoline

setup_trampoline() looks very similar between architectures, and this patch unifies them. The i386 version allocates bootmem memory, while the x86_64 version uses a fixed address.

In this patch, we initialize the global trampoline_base to the x86_64 version, and i386 allocation can later override it.

---
 arch/x86/kernel/smpboot.c    |   33 +++++++++++++++++++++++++++++++++
 arch/x86/kernel/smpboot_32.c |   29 -----------------------------
 arch/x86/kernel/smpboot_64.c |   14 --------------
 include/asm-x86/smp.h        |    4 ++++
 include/asm-x86/smp_64.h     |    2 --
 5 files changed, 37 insertions(+), 45 deletions(-)
arch/x86/kernel/smpboot.c +33 -0
index 34c3117..b13b9d5 100644
@@ -3,6 +3,7 @@
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/percpu.h>
+#include <linux/bootmem.h>
 
 #include <asm/nmi.h>
 #include <asm/irq.h>
@@ -38,6 +39,9 @@ EXPORT_PER_CPU_SYMBOL(cpu_core_map);
 DEFINE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info);
 EXPORT_PER_CPU_SYMBOL(cpu_info);
 
+/* ready for x86_64, no harm for x86, since it will overwrite after alloc */
+unsigned char *trampoline_base = __va(SMP_TRAMPOLINE_BASE);
+
 /* representing cpus for which sibling maps can be computed */
 static cpumask_t cpu_sibling_setup_map;
 
@@ -117,6 +121,35 @@ cpumask_t cpu_coregroup_map(int cpu)
 		return c->llc_shared_map;
 }
 
+/*
+ * Currently trivial. Write the real->protected mode
+ * bootstrap into the page concerned. The caller
+ * has made sure it's suitably aligned.
+ */
+
+unsigned long __cpuinit setup_trampoline(void)
+{
+	memcpy(trampoline_base, trampoline_data,
+	       trampoline_end - trampoline_data);
+	return virt_to_phys(trampoline_base);
+}
+
+#ifdef CONFIG_X86_32
+/*
+ * We are called very early to get the low memory for the
+ * SMP bootup trampoline page.
+ */
+void __init smp_alloc_memory(void)
+{
+	trampoline_base = alloc_bootmem_low_pages(PAGE_SIZE);
+	/*
+	 * Has to be in very low memory so we can execute
+	 * real-mode AP code.
+	 */
+	if (__pa(trampoline_base) >= 0x9F000)
+		BUG();
+}
+#endif
 
 #ifdef CONFIG_HOTPLUG_CPU
 void remove_siblinginfo(int cpu)
arch/x86/kernel/smpboot_32.c +0 -29
index a21f254..ee82659 100644
@@ -73,41 +73,12 @@ EXPORT_PER_CPU_SYMBOL(x86_cpu_to_apicid);
 
 u8 apicid_2_node[MAX_APICID];
 
-static unsigned char *trampoline_base;
-
 static void map_cpu_to_logical_apicid(void);
 
 /* State of each CPU. */
 DEFINE_PER_CPU(int, cpu_state) = { 0 };
 
 /*
- * Currently trivial. Write the real->protected mode
- * bootstrap into the page concerned. The caller
- * has made sure it's suitably aligned.
- */
-
-static unsigned long __cpuinit setup_trampoline(void)
-{
-	memcpy(trampoline_base, trampoline_data, trampoline_end - trampoline_data);
-	return virt_to_phys(trampoline_base);
-}
-
-/*
- * We are called very early to get the low memory for the
- * SMP bootup trampoline page.
- */
-void __init smp_alloc_memory(void)
-{
-	trampoline_base = alloc_bootmem_low_pages(PAGE_SIZE);
-	/*
-	 * Has to be in very low memory so we can execute
-	 * real-mode AP code.
-	 */
-	if (__pa(trampoline_base) >= 0x9F000)
-		BUG();
-}
-
-/*
  * The bootstrap kernel entry code has set these up. Save them for
  * a given CPU
  */
arch/x86/kernel/smpboot_64.c +0 -14
index 2cc1b8b..9f4935e 100644
@@ -85,20 +85,6 @@ struct task_struct *idle_thread_array[NR_CPUS] __cpuinitdata ;
 #define set_idle_for_cpu(x,p)   (idle_thread_array[(x)] = (p))
 #endif
 
-
-/*
- * Currently trivial. Write the real->protected mode
- * bootstrap into the page concerned. The caller
- * has made sure it's suitably aligned.
- */
-
-static unsigned long __cpuinit setup_trampoline(void)
-{
-	void *tramp = __va(SMP_TRAMPOLINE_BASE); 
-	memcpy(tramp, trampoline_data, trampoline_end - trampoline_data);
-	return virt_to_phys(tramp);
-}
-
 /*
  * The bootstrap kernel entry code has set these up. Save them for
  * a given CPU
include/asm-x86/smp.h +4 -0
index b2a1697..513c857 100644
@@ -14,6 +14,7 @@ extern unsigned int num_processors;
  */
 extern const unsigned char trampoline_data [];
 extern const unsigned char trampoline_end  [];
+extern unsigned char *trampoline_base;
 
 struct smp_ops {
 	void (*smp_prepare_boot_cpu)(void);
@@ -81,6 +82,9 @@ extern void __cpu_die(unsigned int cpu);
 
 extern unsigned disabled_cpus;
 extern void prefill_possible_map(void);
+
+#define SMP_TRAMPOLINE_BASE 0x6000
+extern unsigned long setup_trampoline(void);
 #endif
 
 #ifdef CONFIG_X86_32
include/asm-x86/smp_64.h +0 -2
index d554d7d..394c785 100644
@@ -40,8 +40,6 @@ static inline int cpu_present_to_apicid(int mps_cpu)
 
 #ifdef CONFIG_SMP
 
-#define SMP_TRAMPOLINE_BASE 0x6000
-
 #define raw_smp_processor_id()	read_pda(cpunumber)
 #define cpu_physical_id(cpu)	per_cpu(x86_cpu_to_apicid, cpu)
 
Signature · 1 line
1.5.0.6
#45 lore raw

PATCH 45/52 use wait_for_init_deassert in x86_64

wraps the busy loop for wait_for_init_deasserted() in a function, so smp_callin in x86_64 looks like more i386

---
 arch/x86/kernel/smpboot_64.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
arch/x86/kernel/smpboot_64.c +8 -2
index 9f4935e..4f6d976 100644
@@ -100,6 +100,13 @@ static void __cpuinit smp_store_cpu_info(int id)
 	print_cpu_info(c);
 }
 
+static inline void wait_for_init_deassert(atomic_t *deassert)
+{
+	while (!atomic_read(deassert))
+		cpu_relax();
+	return;
+}
+
 static atomic_t init_deasserted __cpuinitdata;
 
 /*
@@ -117,8 +124,7 @@ void __cpuinit smp_callin(void)
 	 * our local APIC.  We have to wait for the IPI or we'll
 	 * lock up on an APIC access.
 	 */
-	while (!atomic_read(&init_deasserted))
-		cpu_relax();
+	wait_for_init_deassert(&init_deasserted);
 
 	/*
 	 * (This works even if the APIC is not enabled.)
Signature · 1 line
1.5.0.6
#46 lore raw

PATCH 46/52 use cpu_relax instead of rep_nop

This is done for smpboot_32.c

---
 arch/x86/kernel/smpboot_32.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/smpboot_32.c +2 -2
index ee82659..2dd95ba 100644
@@ -185,7 +185,7 @@ static void __cpuinit smp_callin(void)
 		 */
 		if (cpu_isset(cpuid, cpu_callout_map))
 			break;
-		rep_nop();
+		cpu_relax();
 	}
 
 	if (!time_before(jiffies, timeout)) {
@@ -242,7 +242,7 @@ static void __cpuinit start_secondary(void *unused)
 	preempt_disable();
 	smp_callin();
 	while (!cpu_isset(smp_processor_id(), smp_commenced_mask))
-		rep_nop();
+		cpu_relax();
 	/*
 	 * Check TSC synchronization with the BP:
 	 */
Signature · 1 line
1.5.0.6
#47 lore raw

PATCH 47/52 leave irqs enabled while calibrating delay.

although i386 appearantly does not have problems with the nmi, we leave irqs enabled, as it is common ground between it and x86_64.

---
 arch/x86/kernel/smpboot_32.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
arch/x86/kernel/smpboot_32.c +5 -0
index 2dd95ba..8c39369 100644
@@ -208,8 +208,13 @@ static void __cpuinit smp_callin(void)
 
 	/*
 	 * Get our bogomips.
+	 *
+	 * Need to enable IRQs because it can take longer and then
+	 * the NMI watchdog might kill us.
 	 */
+	local_irq_enable();
 	calibrate_delay();
+	local_irq_disable();
 	Dprintk("Stack at about %p\n",&cpuid);
 
 	/*
Signature · 1 line
1.5.0.6
#48 lore raw

PATCH 48/52 modify x86_64 smp_callin so it looks like i386

This is done by introducing the empty smp_callin_clear_local_apic() and map_cpu_to_logical_apicid()

---
 arch/x86/kernel/smpboot_64.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
arch/x86/kernel/smpboot_64.c +4 -0
index 4f6d976..b6a5da5 100644
@@ -106,6 +106,8 @@ static inline void wait_for_init_deassert(atomic_t *deassert)
 		cpu_relax();
 	return;
 }
+#define smp_callin_clear_local_apic() do {} while (0)
+#define map_cpu_to_logical_apicid() do {} while (0)
 
 static atomic_t init_deasserted __cpuinitdata;
 
@@ -171,8 +173,10 @@ void __cpuinit smp_callin(void)
 	 */
 
 	Dprintk("CALLIN, before setup_local_APIC().\n");
+	smp_callin_clear_local_apic();
 	setup_local_APIC();
 	end_local_APIC_setup();
+	map_cpu_to_logical_apicid();
 
 	/*
 	 * Get our bogomips.
Signature · 1 line
1.5.0.6
#49 lore raw

PATCH 49/52 wrap esr setting up in i386 in lapic_setup_esr

it is a little bit more complicated than x86_64 due to erratas and other stuff, but its existance will ease integration

---
 arch/x86/kernel/apic_32.c |   73 ++++++++++++++++++++++++--------------------
 1 files changed, 40 insertions(+), 33 deletions(-)
arch/x86/kernel/apic_32.c +40 -33
index 6aa93db..4a754ee 100644
@@ -897,12 +897,50 @@ void __init init_bsp_APIC(void)
 	apic_write_around(APIC_LVT1, value);
 }
 
+void __cpuinit lapic_setup_esr(void)
+{
+	unsigned long oldvalue, value, maxlvt;
+	if (lapic_is_integrated() && !esr_disable) {
+		/* !82489DX */
+		maxlvt = lapic_get_maxlvt();
+		if (maxlvt > 3)		/* Due to the Pentium erratum 3AP. */
+			apic_write(APIC_ESR, 0);
+		oldvalue = apic_read(APIC_ESR);
+
+		/* enables sending errors */
+		value = ERROR_APIC_VECTOR;
+		apic_write_around(APIC_LVTERR, value);
+		/*
+		 * spec says clear errors after enabling vector.
+		 */
+		if (maxlvt > 3)
+			apic_write(APIC_ESR, 0);
+		value = apic_read(APIC_ESR);
+		if (value != oldvalue)
+			apic_printk(APIC_VERBOSE, "ESR value before enabling "
+				"vector: 0x%08lx  after: 0x%08lx\n",
+				oldvalue, value);
+	} else {
+		if (esr_disable)
+			/*
+			 * Something untraceable is creating bad interrupts on
+			 * secondary quads ... for the moment, just leave the
+			 * ESR disabled - we can't do anything useful with the
+			 * errors anyway - mbligh
+			 */
+			printk(KERN_INFO "Leaving ESR disabled.\n");
+		else
+			printk(KERN_INFO "No ESR for 82489DX.\n");
+	}
+}
+
+
 /**
  * setup_local_APIC - setup the local APIC
  */
 void __cpuinit setup_local_APIC(void)
 {
-	unsigned long oldvalue, value, maxlvt, integrated;
+	unsigned long value, integrated;
 	int i, j;
 
 	/* Pound the ESR really hard over the head with a big hammer - mbligh */
@@ -1027,38 +1065,7 @@ void __cpuinit setup_local_APIC(void)
 		value |= APIC_LVT_LEVEL_TRIGGER;
 	apic_write_around(APIC_LVT1, value);
 
-	if (integrated && !esr_disable) {
-		/* !82489DX */
-		maxlvt = lapic_get_maxlvt();
-		if (maxlvt > 3)		/* Due to the Pentium erratum 3AP. */
-			apic_write(APIC_ESR, 0);
-		oldvalue = apic_read(APIC_ESR);
-
-		/* enables sending errors */
-		value = ERROR_APIC_VECTOR;
-		apic_write_around(APIC_LVTERR, value);
-		/*
-		 * spec says clear errors after enabling vector.
-		 */
-		if (maxlvt > 3)
-			apic_write(APIC_ESR, 0);
-		value = apic_read(APIC_ESR);
-		if (value != oldvalue)
-			apic_printk(APIC_VERBOSE, "ESR value before enabling "
-				"vector: 0x%08lx  after: 0x%08lx\n",
-				oldvalue, value);
-	} else {
-		if (esr_disable)
-			/*
-			 * Something untraceable is creating bad interrupts on
-			 * secondary quads ... for the moment, just leave the
-			 * ESR disabled - we can't do anything useful with the
-			 * errors anyway - mbligh
-			 */
-			printk(KERN_INFO "Leaving ESR disabled.\n");
-		else
-			printk(KERN_INFO "No ESR for 82489DX.\n");
-	}
+	lapic_setup_esr();
 
 	/* Disable the local apic timer */
 	value = apic_read(APIC_LVTT);
Signature · 1 line
1.5.0.6
#50 lore raw

PATCH 50/52 provide an end_local_APIC_setup function

It splits setup_local_APIC in two, providing a function corresponding to the ending part of it. As a side effect, smp_callin looks the same between i386 and x86_64.

---
 arch/x86/kernel/apic_32.c    |    7 ++++++-
 arch/x86/kernel/smpboot_32.c |    1 +
 2 files changed, 7 insertions(+), 1 deletions(-)
arch/x86/kernel/apic_32.c +6 -1
index 4a754ee..6d132a9 100644
@@ -1064,9 +1064,13 @@ void __cpuinit setup_local_APIC(void)
 	if (!integrated)		/* 82489DX */
 		value |= APIC_LVT_LEVEL_TRIGGER;
 	apic_write_around(APIC_LVT1, value);
+}
 
-	lapic_setup_esr();
+void __cpuinit end_local_APIC_setup(void)
+{
+	unsigned long value;
 
+	lapic_setup_esr();
 	/* Disable the local apic timer */
 	value = apic_read(APIC_LVTT);
 	value |= (APIC_LVT_MASKED | LOCAL_TIMER_VECTOR);
@@ -1256,6 +1260,7 @@ int __init APIC_init_uniprocessor(void)
 
 	setup_local_APIC();
 
+	end_local_APIC_setup();
 #ifdef CONFIG_X86_IO_APIC
 	if (smp_found_config)
 		if (!skip_ioapic_setup && nr_ioapics)
arch/x86/kernel/smpboot_32.c +1 -0
index 8c39369..4a08822 100644
@@ -204,6 +204,7 @@ static void __cpuinit smp_callin(void)
 	Dprintk("CALLIN, before setup_local_APIC().\n");
 	smp_callin_clear_local_apic();
 	setup_local_APIC();
+	end_local_APIC_setup();
 	map_cpu_to_logical_apicid();
 
 	/*
Signature · 1 line
1.5.0.6
#51 lore raw

PATCH 51/52 make map_cpu_to_logical_apicid nonstatic

it is used by smp_callin, that is about to be removed from this file.

---
 arch/x86/kernel/smpboot_32.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/smpboot_32.c +2 -2
index 4a08822..adad1ad 100644
@@ -73,7 +73,7 @@ EXPORT_PER_CPU_SYMBOL(x86_cpu_to_apicid);
 
 u8 apicid_2_node[MAX_APICID];
 
-static void map_cpu_to_logical_apicid(void);
+void map_cpu_to_logical_apicid(void);
 
 /* State of each CPU. */
 DEFINE_PER_CPU(int, cpu_state) = { 0 };
@@ -353,7 +353,7 @@ static inline void unmap_cpu_to_node(int cpu)
 
 u8 cpu_2_logical_apicid[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = BAD_APICID };
 
-static void map_cpu_to_logical_apicid(void)
+void map_cpu_to_logical_apicid(void)
 {
 	int cpu = smp_processor_id();
 	int apicid = logical_smp_processor_id();
Signature · 1 line
1.5.0.6
#52 lore raw

PATCH 52/52 merge smp_callin

smp_callin() looks like the same between i386 and x86_64, and it is merged in a common file

---
 arch/x86/kernel/smpboot.c    |  110 ++++++++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/smpboot_32.c |   89 ----------------------------------
 arch/x86/kernel/smpboot_64.c |  102 +--------------------------------------
 include/asm-x86/smp.h        |    3 +
 4 files changed, 114 insertions(+), 190 deletions(-)
arch/x86/kernel/smpboot.c +110 -0
index b13b9d5..e0830bb 100644
@@ -11,6 +11,11 @@
 #include <asm/cpu.h>
 #include <asm/numa.h>
 
+#ifdef CONFIG_X86_32
+#include <mach_apic.h>
+#include <mach_wakecpu.h>
+#endif
+
 /* Number of siblings per CPU package */
 int smp_num_siblings = 1;
 EXPORT_SYMBOL(smp_num_siblings);
@@ -151,6 +156,111 @@ void __init smp_alloc_memory(void)
 }
 #endif
 
+#ifdef CONFIG_X86_64
+static inline void wait_for_init_deassert(atomic_t *deassert)
+{
+	while (!atomic_read(deassert))
+		cpu_relax();
+	return;
+}
+#define smp_callin_clear_local_apic() do {} while (0)
+#define map_cpu_to_logical_apicid() do {} while (0)
+#else
+extern void map_cpu_to_logical_apicid(void);
+#endif
+
+atomic_t init_deasserted __cpuinitdata;
+extern void smp_store_cpu_info(int cpuid);
+
+/*
+ * Report back to the Boot Processor.
+ * Running on AP.
+ */
+void __cpuinit smp_callin(void)
+{
+	int cpuid, phys_id;
+	unsigned long timeout;
+
+	/*
+	 * If waken up by an INIT in an 82489DX configuration
+	 * we may get here before an INIT-deassert IPI reaches
+	 * our local APIC.  We have to wait for the IPI or we'll
+	 * lock up on an APIC access.
+	 */
+	wait_for_init_deassert(&init_deasserted);
+
+	/*
+	 * (This works even if the APIC is not enabled.)
+	 */
+	phys_id = GET_APIC_ID(apic_read(APIC_ID));
+	cpuid = smp_processor_id();
+	if (cpu_isset(cpuid, cpu_callin_map)) {
+		panic("smp_callin: phys CPU#%d, CPU#%d already present??\n",
+					phys_id, cpuid);
+	}
+	Dprintk("CPU#%d (phys ID: %d) waiting for CALLOUT\n", cpuid, phys_id);
+
+	/*
+	 * STARTUP IPIs are fragile beasts as they might sometimes
+	 * trigger some glue motherboard logic. Complete APIC bus
+	 * silence for 1 second, this overestimates the time the
+	 * boot CPU is spending to send the up to 2 STARTUP IPIs
+	 * by a factor of two. This should be enough.
+	 */
+
+	/*
+	 * Waiting 2s total for startup (udelay is not yet working)
+	 */
+	timeout = jiffies + 2*HZ;
+	while (time_before(jiffies, timeout)) {
+		/*
+		 * Has the boot CPU finished it's STARTUP sequence?
+		 */
+		if (cpu_isset(cpuid, cpu_callout_map))
+			break;
+		cpu_relax();
+	}
+
+	if (!time_before(jiffies, timeout)) {
+		panic("%s: CPU%d started up but did not get a callout!\n",
+		      __func__, cpuid);
+	}
+
+	/*
+	 * the boot CPU has finished the init stage and is spinning
+	 * on callin_map until we finish. We are free to set up this
+	 * CPU, first the APIC. (this is probably redundant on most
+	 * boards)
+	 */
+
+	Dprintk("CALLIN, before setup_local_APIC().\n");
+	smp_callin_clear_local_apic();
+	setup_local_APIC();
+	end_local_APIC_setup();
+	map_cpu_to_logical_apicid();
+
+	/*
+	 * Get our bogomips.
+	 *
+	 * Need to enable IRQs because it can take longer and then
+	 * the NMI watchdog might kill us.
+	 */
+	local_irq_enable();
+	calibrate_delay();
+	local_irq_disable();
+	Dprintk("Stack at about %p\n", &cpuid);
+
+	/*
+	 * Save our processor parameters
+	 */
+	smp_store_cpu_info(cpuid);
+
+	/*
+	 * Allow the master to continue.
+	 */
+	cpu_set(cpuid, cpu_callin_map);
+}
+
 #ifdef CONFIG_HOTPLUG_CPU
 void remove_siblinginfo(int cpu)
 {
arch/x86/kernel/smpboot_32.c +0 -89

95 lines not on this page · raw message

arch/x86/kernel/smpboot_64.c +1 -101

114 lines not on this page · raw message

include/asm-x86/smp.h +3 -0
index 513c857..821716c 100644
@@ -3,11 +3,13 @@
 #ifndef __ASSEMBLY__
 #include <linux/cpumask.h>
 #include <linux/init.h>
+#include <asm/atomic.h>
 
 extern cpumask_t cpu_callout_map;
 
 extern int smp_num_siblings;
 extern unsigned int num_processors;
+extern atomic_t init_deasserted;
 
 /*
  * Trampoline 80x86 program as an array.
@@ -99,6 +101,7 @@ extern void cpu_uninit(void);
 extern void remove_siblinginfo(int cpu);
 #endif
 
+extern void smp_callin(void);
 extern void smp_alloc_memory(void);
 extern void lock_ipi_call_lock(void);
 extern void unlock_ipi_call_lock(void);
Signature · 1 line
1.5.0.6
#53 lore raw
In reply to Glauber Costa
Quoted 16 lines · Glauber Costa

Hi,

This series of patches does a first attempt at smp integration (I call it first, although I don't believe it's too far away from a real one). The series comprises 52 patches, and the full diffstat says in the end:

	 34 files changed, 1858 insertions(+), 2344 deletions(-)

smp_32.c and smp_64.c are completely gone. smp.h and smpboot_{32,64}.c are not, although substantially reduced. I know that ideally, no leftovers are wanted, but the series were already big enough (I tried to split the patches as much as I could), so I considered this a good cutting point. If this is all agreed upon and merged, I'll start looking at the other bits that are left.

Quoted 3 lines

All patches are tested is various random x86 subarchitectures, and all of them works. The result also boots fine in mine x86_64 and i386 boxes.

wow, really nice work and the result looks awesome! I'll put this into x86.git and see how it goes.

Ingo

#54 lore raw
Quoted 19 lines · Ingo Molnar
Quoted 16 lines · Glauber Costa

Hi,

This series of patches does a first attempt at smp integration (I call it first, although I don't believe it's too far away from a real one). The series comprises 52 patches, and the full diffstat says in the end:

       34 files changed, 1858 insertions(+), 2344 deletions(-)

smp_32.c and smp_64.c are completely gone. smp.h and smpboot_{32,64}.c are not, although substantially reduced. I know that ideally, no leftovers are wanted, but the series were already big enough (I tried to split the patches as much as I could), so I considered this a good cutting point. If this is all agreed upon and merged, I'll start looking at the other bits that are left.

Quoted 9 lines
Quoted 3 lines

All patches are tested is various random x86 subarchitectures, and all of them works. The result also boots fine in mine x86_64 and i386 boxes.

wow, really nice work and the result looks awesome! I'll put this into x86.git and see how it goes.

Ingo

Thanks ingo. I'll hook up to the next part as soon as I can.

Signature · 5 lines
Glauber  Costa.
"Free as in Freedom"
http://glommer.net

"The less confident you are, the more serious you have to act."
#55 lore raw
In reply to Glauber Costa
Quoted 2 lines · Glauber Costa

Comments are welcome.

The main difference between i386 and x86-64 smp boot up (among a lot of quirks and workarounds in i386 that x86-64 doesn't have/need and some trivialities) is that x86-64 follows the standard hotplug state machine and i386 doesn't.

I would suggest that if you want to unify you convert i386 over to the new state machine first because that is the key difference. Everything else after that is relatively simple. You can probably pattern that after the original changeset who did this for x86-64.

The reason I never attempted this myself is that i was too worried about regressions on old machines for i386 (this code is partly very fragile) You'll likely encounter that problem. Just make sure to keep a stable email address for some years to handle the fallout.

-Andi

#56 lore raw
Quoted 14 lines · Andi Kleen
Quoted 2 lines · Glauber Costa

Comments are welcome.

The main difference between i386 and x86-64 smp boot up (among a lot of quirks and workarounds in i386 that x86-64 doesn't have/need and some trivialities) is that x86-64 follows the standard hotplug state machine and i386 doesn't.

I would suggest that if you want to unify you convert i386 over to the new state machine first because that is the key difference. Everything else after that is relatively simple. You can probably pattern that after the original changeset who did this for x86-64.

Quoted 4 lines

The reason I never attempted this myself is that i was too worried about regressions on old machines for i386 (this code is partly very fragile) You'll likely encounter that problem. Just make sure to keep a stable email address for some years to handle the fallout.

Thanks Andi, all very helpful.
I'll try to handle the problems in my configuration, but I'm too very sure they'll appear, and other people testing it will surely add up.

As for the e-mail address, I can list my personal address in the top of the file, or make sure red hat won't fire me. Maybe I can do both.

Signature · 5 lines
Glauber  Costa.
"Free as in Freedom"
http://glommer.net

"The less confident you are, the more serious you have to act."