Skip to contentSkip to conversation

integrate smp.h

PATCH Applied Glauber Costa 2 participants 11 messages Mar 27, 2008 – Mar 28, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover integrate smp.h

Hi,

here's the last series I was owing.

After that, smp_32.h and smp_64.h are gone, merged into smp.h

as usual, compiled tested in ~ 8 randconfigs for each architecture, and boot tested in all my hardware.

enjoy

full diffstat:

a/include/asm-x86/smp_32.h | 12 -----

 a/include/asm-x86/smp_64.h |   12 -----
 b/arch/x86/xen/smp.c       |    7 +--
 b/include/asm-x86/smp.h    |   27 ++++++++++++
 b/include/asm-x86/smp_32.h |   27 ------------
 b/include/asm-x86/smp_64.h |    7 ++-
 include/asm-x86/smp.h      |   57 ++++++++++++++++++++++---
 include/asm-x86/smp_32.h   |   34 ---------------
 include/asm-x86/smp_64.h   |  100 ++++++++-------------------------------------
 9 files changed, 104 insertions(+), 179 deletions(-)
#1 lore raw

PATCH 1/9 x86: surround hard_smp_processor_id in APIC_DEFINITION

APIC_DEFINITION is not defined in x86_64, so in practice, we keep our old code here. But as a nice side effect, the code is now equal to smp_32.h.

---
 include/asm-x86/smp_64.h |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
include/asm-x86/smp_64.h +5 -1
index c53a011..2520633 100644
@@ -52,12 +52,16 @@ static inline int logical_smp_processor_id(void)
 	return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
 }
 
-#include <mach_apicdef.h>
+# ifdef APIC_DEFINITION
+extern int hard_smp_processor_id(void);
+# else
+#  include <mach_apicdef.h>
 static inline int hard_smp_processor_id(void)
 {
 	/* we don't want to mark this access volatile - bad code generation */
 	return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID));
 }
+# endif /* APIC_DEFINITION */
 
 #endif
 
Signature · 1 line
1.5.0.6
#2 lore raw

PATCH 2/9 x86: provide bogus hard_smp_processor_id

In reply to Glauber Costa

We provide a bogus macro for x86_64 in case CONFIG_X86_LOCAL_APIC is not set. It will always be set for x86_64, so the effect is just to make the code equal to i386.

---
 include/asm-x86/smp_64.h |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
include/asm-x86/smp_64.h +10 -0
index 2520633..c46585e 100644
@@ -46,6 +46,8 @@ static inline int num_booting_cpus(void)
 
 #define safe_smp_processor_id()		smp_processor_id()
 
+#ifdef CONFIG_X86_LOCAL_APIC
+
 static inline int logical_smp_processor_id(void)
 {
 	/* we don't want to mark this access volatile - bad code generation */
@@ -63,5 +65,13 @@ static inline int hard_smp_processor_id(void)
 }
 # endif /* APIC_DEFINITION */
 
+#else /* CONFIG_X86_LOCAL_APIC */
+
+# ifndef CONFIG_SMP
+#  define hard_smp_processor_id()	0
+# endif
+
+#endif /* CONFIG_X86_LOCAL_APIC */
+
 #endif
 
Signature · 1 line
1.5.0.6
#3 lore raw

PATCH 3/9 x86: merge hard/logical_smp_processor_id

In reply to Glauber Costa

The code is now the same between i386 and x86_64. We already know what happens when it reaches this point: They go away from the arch-specific headers, and suddenly appears in the common header.

---
 include/asm-x86/smp.h    |   27 +++++++++++++++++++++++++++
 include/asm-x86/smp_32.h |   27 ---------------------------
 include/asm-x86/smp_64.h |   27 ---------------------------
 3 files changed, 27 insertions(+), 54 deletions(-)
include/asm-x86/smp.h +27 -0
index 664f9c0..eb05804 100644
@@ -128,6 +128,33 @@ void smp_store_cpu_info(int id);
 # include "smp_64.h"
 #endif
 
+#ifdef CONFIG_X86_LOCAL_APIC
+
+static inline int logical_smp_processor_id(void)
+{
+	/* we don't want to mark this access volatile - bad code generation */
+	return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
+}
+
+# ifdef APIC_DEFINITION
+extern int hard_smp_processor_id(void);
+# else
+#  include <mach_apicdef.h>
+static inline int hard_smp_processor_id(void)
+{
+	/* we don't want to mark this access volatile - bad code generation */
+	return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID));
+}
+# endif /* APIC_DEFINITION */
+
+#else /* CONFIG_X86_LOCAL_APIC */
+
+# ifndef CONFIG_SMP
+#  define hard_smp_processor_id()	0
+# endif
+
+#endif /* CONFIG_X86_LOCAL_APIC */
+
 #ifdef CONFIG_HOTPLUG_CPU
 extern void cpu_exit_clear(void);
 extern void cpu_uninit(void);
include/asm-x86/smp_32.h +0 -27
index cb3ada2..53432db 100644
@@ -42,32 +42,5 @@ static inline int num_booting_cpus(void)
 #define safe_smp_processor_id()		0
 #endif /* !CONFIG_SMP */
 
-#ifdef CONFIG_X86_LOCAL_APIC
-
-static inline int logical_smp_processor_id(void)
-{
-	/* we don't want to mark this access volatile - bad code generation */
-	return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
-}
-
-# ifdef APIC_DEFINITION
-extern int hard_smp_processor_id(void);
-# else
-#  include <mach_apicdef.h>
-static inline int hard_smp_processor_id(void)
-{
-	/* we don't want to mark this access volatile - bad code generation */
-	return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID));
-}
-# endif /* APIC_DEFINITION */
-
-#else /* CONFIG_X86_LOCAL_APIC */
-
-# ifndef CONFIG_SMP
-#  define hard_smp_processor_id()	0
-# endif
-
-#endif /* CONFIG_X86_LOCAL_APIC */
-
 #endif /* !ASSEMBLY */
 #endif
include/asm-x86/smp_64.h +0 -27
index c46585e..015d36e 100644
@@ -46,32 +46,5 @@ static inline int num_booting_cpus(void)
 
 #define safe_smp_processor_id()		smp_processor_id()
 
-#ifdef CONFIG_X86_LOCAL_APIC
-
-static inline int logical_smp_processor_id(void)
-{
-	/* we don't want to mark this access volatile - bad code generation */
-	return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
-}
-
-# ifdef APIC_DEFINITION
-extern int hard_smp_processor_id(void);
-# else
-#  include <mach_apicdef.h>
-static inline int hard_smp_processor_id(void)
-{
-	/* we don't want to mark this access volatile - bad code generation */
-	return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID));
-}
-# endif /* APIC_DEFINITION */
-
-#else /* CONFIG_X86_LOCAL_APIC */
-
-# ifndef CONFIG_SMP
-#  define hard_smp_processor_id()	0
-# endif
-
-#endif /* CONFIG_X86_LOCAL_APIC */
-
 #endif
 
Signature · 1 line
1.5.0.6
#4 lore raw

PATCH 4/9 x86: surround apic headers in apic definitions

In reply to Glauber Costa

Although those constants are always defined in x86_64, and will have the effect of just including the headers in the very way we did before, I'm doing this in a separate patch to be conservative and avoid surprises.

---
 include/asm-x86/smp_64.h |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
include/asm-x86/smp_64.h +7 -3
index 015d36e..b83151d 100644
@@ -7,9 +7,13 @@
 /*
  * We need the APIC definitions automatically as part of 'smp.h'
  */
-#include <asm/apic.h>
-#include <asm/io_apic.h>
-#include <asm/mpspec.h>
+#ifdef CONFIG_X86_LOCAL_APIC
+#  include <asm/mpspec.h>
+#  include <asm/apic.h>
+#  ifdef CONFIG_X86_IO_APIC
+#   include <asm/io_apic.h>
+#  endif
+#endif
 #include <asm/pda.h>
 #include <asm/thread_info.h>
 
Signature · 1 line
1.5.0.6
#5 lore raw

PATCH 5/9 x86: merge includes in smp.h

In reply to Glauber Costa

move all include directives from smp_{32,64}.h to smp.h.

---
 include/asm-x86/smp.h    |   13 +++++++++++++
 include/asm-x86/smp_32.h |   13 -------------
 include/asm-x86/smp_64.h |   16 ----------------
 3 files changed, 13 insertions(+), 29 deletions(-)
include/asm-x86/smp.h +13 -0
index eb05804..1cd434d 100644
@@ -5,6 +5,19 @@
 #include <linux/init.h>
 #include <asm/percpu.h>
 
+/*
+ * We need the APIC definitions automatically as part of 'smp.h'
+ */
+#ifdef CONFIG_X86_LOCAL_APIC
+# include <asm/mpspec.h>
+# include <asm/apic.h>
+# ifdef CONFIG_X86_IO_APIC
+#  include <asm/io_apic.h>
+# endif
+#endif
+#include <asm/pda.h>
+#include <asm/thread_info.h>
+
 extern cpumask_t cpu_callout_map;
 
 extern int smp_num_siblings;
include/asm-x86/smp_32.h +0 -13
index 53432db..694d324 100644
@@ -2,19 +2,6 @@
 #define __ASM_SMP_H
 
 #ifndef __ASSEMBLY__
-#include <linux/cpumask.h>
-#include <linux/init.h>
-
-/*
- * We need the APIC definitions automatically as part of 'smp.h'
- */
-#ifdef CONFIG_X86_LOCAL_APIC
-# include <asm/mpspec.h>
-# include <asm/apic.h>
-# ifdef CONFIG_X86_IO_APIC
-#  include <asm/io_apic.h>
-# endif
-#endif
 
 extern cpumask_t cpu_callin_map;
 
include/asm-x86/smp_64.h +0 -16
index b83151d..eead92e 100644
@@ -1,22 +1,6 @@
 #ifndef __ASM_SMP_H
 #define __ASM_SMP_H
 
-#include <linux/cpumask.h>
-#include <linux/init.h>
-
-/*
- * We need the APIC definitions automatically as part of 'smp.h'
- */
-#ifdef CONFIG_X86_LOCAL_APIC
-#  include <asm/mpspec.h>
-#  include <asm/apic.h>
-#  ifdef CONFIG_X86_IO_APIC
-#   include <asm/io_apic.h>
-#  endif
-#endif
-#include <asm/pda.h>
-#include <asm/thread_info.h>
-
 extern cpumask_t cpu_initialized;
 extern cpumask_t cpu_callin_map;
 
Signature · 1 line
1.5.0.6
#6 lore raw

PATCH 6/9 x86: split safe_smp_processor_id

In reply to Glauber Costa

This implementation in x86_64 is clean and consistent, but we sacrifice it for the sake of being equal to i386 (since the other way around would be harder).

---
 include/asm-x86/smp_64.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
include/asm-x86/smp_64.h +2 -2
index eead92e..8ea4952 100644
@@ -27,12 +27,12 @@ static inline int num_booting_cpus(void)
 	return cpus_weight(cpu_callout_map);
 }
 
+#define safe_smp_processor_id()		smp_processor_id()
 #else /* CONFIG_SMP */
 #define stack_smp_processor_id() 0
-
+#define safe_smp_processor_id() 0
 #endif /* !CONFIG_SMP */
 
-#define safe_smp_processor_id()		smp_processor_id()
 
 #endif
 
Signature · 1 line
1.5.0.6
#7 lore raw

PATCH 7/9 x86: merge SMP definitions of smp.h

In reply to Glauber Costa

we merge everything that is inside CONFIG_SMP to smp.h. They differ a little bit, so we use CONFIG_X86_32_SMP and CONFIG_X86_64_SMP as markers.

---
 include/asm-x86/smp.h    |   33 ++++++++++++++++++++++++++++++++-
 include/asm-x86/smp_32.h |   21 ---------------------
 include/asm-x86/smp_64.h |   27 ---------------------------
 3 files changed, 32 insertions(+), 49 deletions(-)
include/asm-x86/smp.h +32 -1
index 1cd434d..5f6ea69 100644
@@ -131,8 +131,39 @@ extern unsigned long setup_trampoline(void);
 
 void smp_store_cpu_info(int id);
 #define cpu_physical_id(cpu)	per_cpu(x86_cpu_to_apicid, cpu)
-#else
+
+/* We don't mark CPUs online until __cpu_up(), so we need another measure */
+static inline int num_booting_cpus(void)
+{
+	return cpus_weight(cpu_callout_map);
+}
+#endif /* CONFIG_SMP */
+
+#ifdef CONFIG_X86_32_SMP
+/*
+ * 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(),
+ * so this is correct in the x86 case.
+ */
+DECLARE_PER_CPU(int, cpu_number);
+#define raw_smp_processor_id() (x86_read_percpu(cpu_number))
+extern int safe_smp_processor_id(void);
+
+#elif defined(CONFIG_X86_64_SMP)
+#define raw_smp_processor_id()	read_pda(cpunumber)
+
+#define stack_smp_processor_id()					\
+({								\
+	struct thread_info *ti;						\
+	__asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK));	\
+	ti->cpu;							\
+})
+#define safe_smp_processor_id()		smp_processor_id()
+
+#else /* !CONFIG_X86_32_SMP && !CONFIG_X86_64_SMP */
 #define cpu_physical_id(cpu)		boot_cpu_physical_apicid
+#define safe_smp_processor_id()		0
+#define stack_smp_processor_id() 	0
 #endif
 
 #ifdef CONFIG_X86_32
include/asm-x86/smp_32.h +0 -21
index 694d324..d9ae5ac 100644
@@ -8,26 +8,5 @@ extern cpumask_t cpu_callin_map;
 extern void (*mtrr_hook)(void);
 extern void zap_low_mappings(void);
 
-#ifdef CONFIG_SMP
-/*
- * 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(),
- * so this is correct in the x86 case.
- */
-DECLARE_PER_CPU(int, cpu_number);
-#define raw_smp_processor_id() (x86_read_percpu(cpu_number))
-
-extern int safe_smp_processor_id(void);
-
-/* We don't mark CPUs online until __cpu_up(), so we need another measure */
-static inline int num_booting_cpus(void)
-{
-	return cpus_weight(cpu_callout_map);
-}
-
-#else /* CONFIG_SMP */
-#define safe_smp_processor_id()		0
-#endif /* !CONFIG_SMP */
-
 #endif /* !ASSEMBLY */
 #endif
include/asm-x86/smp_64.h +0 -27
index 8ea4952..058f413 100644
@@ -7,32 +7,5 @@ extern cpumask_t cpu_callin_map;
 extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *),
 				  void *info, int wait);
 
-#ifdef CONFIG_SMP
-
-#define raw_smp_processor_id()	read_pda(cpunumber)
-
-#define stack_smp_processor_id()					\
-({									\
-	struct thread_info *ti;						\
-	asm("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK));	\
-	ti->cpu;							\
-})
-
-/*
- * On x86 all CPUs are mapped 1:1 to the APIC space. This simplifies
- * scheduling and IPI sending and compresses data structures.
- */
-static inline int num_booting_cpus(void)
-{
-	return cpus_weight(cpu_callout_map);
-}
-
-#define safe_smp_processor_id()		smp_processor_id()
-#else /* CONFIG_SMP */
-#define stack_smp_processor_id() 0
-#define safe_smp_processor_id() 0
-#endif /* !CONFIG_SMP */
-
-
 #endif
 
Signature · 1 line
1.5.0.6
#8 lore raw

PATCH 8/9 x86: change naming of cpu_initialized_mask for xen

In reply to Glauber Costa

xen does not use the global cpu_initialized mask, but rather,
a specific one. So we change its name so it won't conflict with the upcoming movement of cpu_initialized_mask from smp_64.h to smp_32.h.

CC Jeremy Fitzhardinge <[email protected]>
---
 arch/x86/xen/smp.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/xen/smp.c +3 -3
index 6b3c37b..92dd3db 100644
@@ -35,7 +35,7 @@
 #include "xen-ops.h"
 #include "mmu.h"
 
-static cpumask_t cpu_initialized_map;
+static cpumask_t xen_cpu_initialized_map;
 static DEFINE_PER_CPU(int, resched_irq) = -1;
 static DEFINE_PER_CPU(int, callfunc_irq) = -1;
 static DEFINE_PER_CPU(int, debug_irq) = -1;
@@ -189,7 +189,7 @@ void __init xen_smp_prepare_cpus(unsigned int max_cpus)
 	if (xen_smp_intr_init(0))
 		BUG();
 
-	cpu_initialized_map = cpumask_of_cpu(0);
+	xen_cpu_initialized_map = cpumask_of_cpu(0);
 
 	/* Restrict the possible_map according to max_cpus. */
 	while ((num_possible_cpus() > 1) && (num_possible_cpus() > max_cpus)) {
@@ -220,7 +220,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
 	struct vcpu_guest_context *ctxt;
 	struct gdt_page *gdt = &per_cpu(gdt_page, cpu);
 
-	if (cpu_test_and_set(cpu, cpu_initialized_map))
+	if (cpu_test_and_set(cpu, xen_cpu_initialized_map))
 		return 0;
 
 	ctxt = kzalloc(sizeof(*ctxt), GFP_KERNEL);
Signature · 1 line
1.5.0.6
#9 lore raw

PATCH 9/9 x86: merge smp_32.h and smp_64.h into smp.h

In reply to Glauber Costa

Merge what's left from smp_32.h and smp_64.h into smp.h By now, they're basically extern definitions.

---
 include/asm-x86/smp.h    |   11 +++++------
 include/asm-x86/smp_32.h |   12 ------------
 include/asm-x86/smp_64.h |   11 -----------
 3 files changed, 5 insertions(+), 29 deletions(-)
 delete mode 100644 include/asm-x86/smp_32.h
 delete mode 100644 include/asm-x86/smp_64.h
include/asm-x86/smp.h +5 -6
index 5f6ea69..bd3778d 100644
@@ -19,6 +19,11 @@
 #include <asm/thread_info.h>
 
 extern cpumask_t cpu_callout_map;
+extern cpumask_t cpu_initialized;
+extern cpumask_t cpu_callin_map;
+
+extern void (*mtrr_hook)(void);
+extern void zap_low_mappings(void);
 
 extern int smp_num_siblings;
 extern unsigned int num_processors;
@@ -166,12 +171,6 @@ extern int safe_smp_processor_id(void);
 #define stack_smp_processor_id() 	0
 #endif
 
-#ifdef CONFIG_X86_32
-# include "smp_32.h"
-#else
-# include "smp_64.h"
-#endif
-
 #ifdef CONFIG_X86_LOCAL_APIC
 
 static inline int logical_smp_processor_id(void)
include/asm-x86/smp_32.h deleted +0 -12
deleted file mode 100644
index d9ae5ac..0000000
@@ -1,12 +0,0 @@
-#ifndef __ASM_SMP_H
-#define __ASM_SMP_H
-
-#ifndef __ASSEMBLY__
-
-extern cpumask_t cpu_callin_map;
-
-extern void (*mtrr_hook)(void);
-extern void zap_low_mappings(void);
-
-#endif /* !ASSEMBLY */
-#endif
include/asm-x86/smp_64.h deleted +0 -11
deleted file mode 100644
index 058f413..0000000
@@ -1,11 +0,0 @@
-#ifndef __ASM_SMP_H
-#define __ASM_SMP_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);
-
-#endif
-
Signature · 1 line
1.5.0.6
Applied
#10 lore raw
In reply to Glauber Costa
Quoted 8 lines · Glauber Costa

Hi,

here's the last series I was owing.

After that, smp_32.h and smp_64.h are gone, merged into smp.h

as usual, compiled tested in ~ 8 randconfigs for each architecture, and boot tested in all my hardware.

thanks, applied - lets see how it goes.

Quoted 1 line
 9 files changed, 104 insertions(+), 179 deletions(-)

neat!

Ingo