debuggers.hg

view xen/include/asm-x86/smp.h @ 19965:2dbabefe62dc

Move cpu_{sibling,core}_map into per-CPU space

These cpu maps get read from all CPUs, so apart from addressing the
square(nr_cpus) growth of these objects, they also get moved into the
previously introduced read-mostly sub-section of the per-CPU section,
in order to not need to waste a full cacheline in order to align (and
properly pad) them, which would be undue overhead on systems with low
NR_CPUS.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Jul 13 11:45:31 2009 +0100 (2009-07-13)
parents 822ea2bf0c54
children d33e9aae74c6
line source
1 #ifndef __ASM_SMP_H
2 #define __ASM_SMP_H
4 /*
5 * We need the APIC definitions automatically as part of 'smp.h'
6 */
7 #ifndef __ASSEMBLY__
8 #include <xen/config.h>
9 #include <xen/kernel.h>
10 #include <xen/cpumask.h>
11 #include <asm/current.h>
12 #endif
14 #ifdef CONFIG_X86_LOCAL_APIC
15 #ifndef __ASSEMBLY__
16 #include <asm/bitops.h>
17 #include <asm/mpspec.h>
18 #ifdef CONFIG_X86_IO_APIC
19 #include <asm/io_apic.h>
20 #endif
21 #include <asm/apic.h>
22 #endif
23 #endif
25 #define BAD_APICID -1U
26 #ifdef CONFIG_SMP
27 #ifndef __ASSEMBLY__
29 /*
30 * Private routines/data
31 */
33 extern void smp_alloc_memory(void);
34 extern int pic_mode;
35 DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
36 DECLARE_PER_CPU(cpumask_t, cpu_core_map);
38 void smp_send_nmi_allbutself(void);
40 extern void (*mtrr_hook) (void);
42 #ifdef CONFIG_X86_64
43 extern void zap_low_mappings(void);
44 #else
45 extern void zap_low_mappings(l2_pgentry_t *base);
46 #endif
48 #define MAX_APICID 256
49 extern u32 x86_cpu_to_apicid[];
51 #define cpu_physical_id(cpu) x86_cpu_to_apicid[cpu]
53 /* State of each CPU. */
54 #define CPU_ONLINE 0x0002 /* CPU is up */
55 #define CPU_DEAD 0x0004 /* CPU is dead */
56 DECLARE_PER_CPU(int, cpu_state);
58 #ifdef CONFIG_HOTPLUG_CPU
59 #define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
60 extern int cpu_down(unsigned int cpu);
61 extern int cpu_up(unsigned int cpu);
62 extern void cpu_exit_clear(void);
63 extern void cpu_uninit(void);
64 extern void disable_nonboot_cpus(void);
65 extern void enable_nonboot_cpus(void);
66 #else
67 static inline int cpu_is_offline(int cpu) {return 0;}
68 static inline void disable_nonboot_cpus(void) {}
69 static inline void enable_nonboot_cpus(void) {}
70 #endif
72 /*
73 * This function is needed by all SMP systems. It must _always_ be valid
74 * from the initial startup. We map APIC_BASE very early in page_setup(),
75 * so this is correct in the x86 case.
76 */
77 #define raw_smp_processor_id() (get_processor_id())
79 extern cpumask_t cpu_callout_map;
80 extern cpumask_t cpu_callin_map;
81 extern cpumask_t cpu_possible_map;
83 /* We don't mark CPUs online until __cpu_up(), so we need another measure */
84 static inline int num_booting_cpus(void)
85 {
86 return cpus_weight(cpu_callout_map);
87 }
89 #ifdef CONFIG_X86_LOCAL_APIC
91 static inline int hard_smp_processor_id(void)
92 {
93 /* we don't want to mark this access volatile - bad code generation */
94 return get_apic_id();
95 }
97 static __inline int logical_smp_processor_id(void)
98 {
99 /* we don't want to mark this access volatile - bad code generation */
100 return get_logical_apic_id();
101 }
103 #endif
105 extern int __cpu_disable(void);
106 extern void __cpu_die(unsigned int cpu);
107 #endif /* !__ASSEMBLY__ */
109 #else /* CONFIG_SMP */
111 #define cpu_physical_id(cpu) boot_cpu_physical_apicid
113 #define NO_PROC_ID 0xFF /* No processor magic marker */
115 #endif
116 #endif