integrate smp.h
Subsystems (2)
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(-)
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
@@ -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
PATCH 2/9 x86: provide bogus hard_smp_processor_id
In reply to Glauber CostaWe 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
@@ -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
PATCH 3/9 x86: merge hard/logical_smp_processor_id
In reply to Glauber CostaThe 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
@@ -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
@@ -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
@@ -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
PATCH 4/9 x86: surround apic headers in apic definitions
In reply to Glauber CostaAlthough 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
@@ -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
PATCH 5/9 x86: merge includes in smp.h
In reply to Glauber Costamove 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
@@ -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
@@ -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
@@ -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
PATCH 6/9 x86: split safe_smp_processor_id
In reply to Glauber CostaThis 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
@@ -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
PATCH 7/9 x86: merge SMP definitions of smp.h
In reply to Glauber Costawe 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
@@ -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
@@ -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
@@ -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
PATCH 8/9 x86: change naming of cpu_initialized_mask for xen
In reply to Glauber Costaxen 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.
--- arch/x86/xen/smp.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/xen/smp.c +3 -3
@@ -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
PATCH 9/9 x86: merge smp_32.h and smp_64.h into smp.h
In reply to Glauber CostaMerge 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
@@ -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
@@ -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
@@ -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
Ingo Molnar
AppliedQuoted 8 lines · Glauber Costa
Hi,
here's the last series I was owing.
After that,
smp_32.handsmp_64.hare gone, merged intosmp.has 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