aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-12-10 15:10:24 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-10 15:10:24 -0500
commitb6444bd0a18eb47343e16749ce80a6ebd521f124 (patch)
tree989881a237552dbe3fb36df45b4eda6dbd5fc09f /arch/x86/include
parent9d0cf6f56454c8a71e0aa2c3b9c6cbe470eb2788 (diff)
parent97b67ae559947f1e208439a1bf6a734da3087006 (diff)
Merge branch 'x86-boot-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 boot and percpu updates from Ingo Molnar: "This tree contains a bootable images documentation update plus three slightly misplaced x86/asm percpu changes/optimizations" * 'x86-boot-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86-64: Use RIP-relative addressing for most per-CPU accesses x86-64: Handle PC-relative relocations on per-CPU data x86: Convert a few more per-CPU items to read-mostly ones x86, boot: Document intermediates more clearly
Diffstat (limited to 'arch/x86/include')
-rw-r--r--arch/x86/include/asm/percpu.h61
-rw-r--r--arch/x86/include/asm/processor.h4
2 files changed, 47 insertions, 18 deletions
diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index fd472181a1d0..e0ba66ca68c6 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -64,7 +64,7 @@
64#define __percpu_prefix "" 64#define __percpu_prefix ""
65#endif 65#endif
66 66
67#define __percpu_arg(x) __percpu_prefix "%P" #x 67#define __percpu_arg(x) __percpu_prefix "%" #x
68 68
69/* 69/*
70 * Initialized pointers to per-cpu variables needed for the boot 70 * Initialized pointers to per-cpu variables needed for the boot
@@ -179,29 +179,58 @@ do { \
179 } \ 179 } \
180} while (0) 180} while (0)
181 181
182#define percpu_from_op(op, var, constraint) \ 182#define percpu_from_op(op, var) \
183({ \ 183({ \
184 typeof(var) pfo_ret__; \ 184 typeof(var) pfo_ret__; \
185 switch (sizeof(var)) { \ 185 switch (sizeof(var)) { \
186 case 1: \ 186 case 1: \
187 asm(op "b "__percpu_arg(1)",%0" \ 187 asm(op "b "__percpu_arg(1)",%0" \
188 : "=q" (pfo_ret__) \ 188 : "=q" (pfo_ret__) \
189 : constraint); \ 189 : "m" (var)); \
190 break; \ 190 break; \
191 case 2: \ 191 case 2: \
192 asm(op "w "__percpu_arg(1)",%0" \ 192 asm(op "w "__percpu_arg(1)",%0" \
193 : "=r" (pfo_ret__) \ 193 : "=r" (pfo_ret__) \
194 : constraint); \ 194 : "m" (var)); \
195 break; \ 195 break; \
196 case 4: \ 196 case 4: \
197 asm(op "l "__percpu_arg(1)",%0" \ 197 asm(op "l "__percpu_arg(1)",%0" \
198 : "=r" (pfo_ret__) \ 198 : "=r" (pfo_ret__) \
199 : constraint); \ 199 : "m" (var)); \
200 break; \ 200 break; \
201 case 8: \ 201 case 8: \
202 asm(op "q "__percpu_arg(1)",%0" \ 202 asm(op "q "__percpu_arg(1)",%0" \
203 : "=r" (pfo_ret__) \ 203 : "=r" (pfo_ret__) \
204 : constraint); \ 204 : "m" (var)); \
205 break; \
206 default: __bad_percpu_size(); \
207 } \
208 pfo_ret__; \
209})
210
211#define percpu_stable_op(op, var) \
212({ \
213 typeof(var) pfo_ret__; \
214 switch (sizeof(var)) { \
215 case 1: \
216 asm(op "b "__percpu_arg(P1)",%0" \
217 : "=q" (pfo_ret__) \
218 : "p" (&(var))); \
219 break; \
220 case 2: \
221 asm(op "w "__percpu_arg(P1)",%0" \
222 : "=r" (pfo_ret__) \
223 : "p" (&(var))); \
224 break; \
225 case 4: \
226 asm(op "l "__percpu_arg(P1)",%0" \
227 : "=r" (pfo_ret__) \
228 : "p" (&(var))); \
229 break; \
230 case 8: \
231 asm(op "q "__percpu_arg(P1)",%0" \
232 : "=r" (pfo_ret__) \
233 : "p" (&(var))); \
205 break; \ 234 break; \
206 default: __bad_percpu_size(); \ 235 default: __bad_percpu_size(); \
207 } \ 236 } \
@@ -359,11 +388,11 @@ do { \
359 * per-thread variables implemented as per-cpu variables and thus 388 * per-thread variables implemented as per-cpu variables and thus
360 * stable for the duration of the respective task. 389 * stable for the duration of the respective task.
361 */ 390 */
362#define this_cpu_read_stable(var) percpu_from_op("mov", var, "p" (&(var))) 391#define this_cpu_read_stable(var) percpu_stable_op("mov", var)
363 392
364#define raw_cpu_read_1(pcp) percpu_from_op("mov", (pcp), "m"(pcp)) 393#define raw_cpu_read_1(pcp) percpu_from_op("mov", pcp)
365#define raw_cpu_read_2(pcp) percpu_from_op("mov", (pcp), "m"(pcp)) 394#define raw_cpu_read_2(pcp) percpu_from_op("mov", pcp)
366#define raw_cpu_read_4(pcp) percpu_from_op("mov", (pcp), "m"(pcp)) 395#define raw_cpu_read_4(pcp) percpu_from_op("mov", pcp)
367 396
368#define raw_cpu_write_1(pcp, val) percpu_to_op("mov", (pcp), val) 397#define raw_cpu_write_1(pcp, val) percpu_to_op("mov", (pcp), val)
369#define raw_cpu_write_2(pcp, val) percpu_to_op("mov", (pcp), val) 398#define raw_cpu_write_2(pcp, val) percpu_to_op("mov", (pcp), val)
@@ -381,9 +410,9 @@ do { \
381#define raw_cpu_xchg_2(pcp, val) percpu_xchg_op(pcp, val) 410#define raw_cpu_xchg_2(pcp, val) percpu_xchg_op(pcp, val)
382#define raw_cpu_xchg_4(pcp, val) percpu_xchg_op(pcp, val) 411#define raw_cpu_xchg_4(pcp, val) percpu_xchg_op(pcp, val)
383 412
384#define this_cpu_read_1(pcp) percpu_from_op("mov", (pcp), "m"(pcp)) 413#define this_cpu_read_1(pcp) percpu_from_op("mov", pcp)
385#define this_cpu_read_2(pcp) percpu_from_op("mov", (pcp), "m"(pcp)) 414#define this_cpu_read_2(pcp) percpu_from_op("mov", pcp)
386#define this_cpu_read_4(pcp) percpu_from_op("mov", (pcp), "m"(pcp)) 415#define this_cpu_read_4(pcp) percpu_from_op("mov", pcp)
387#define this_cpu_write_1(pcp, val) percpu_to_op("mov", (pcp), val) 416#define this_cpu_write_1(pcp, val) percpu_to_op("mov", (pcp), val)
388#define this_cpu_write_2(pcp, val) percpu_to_op("mov", (pcp), val) 417#define this_cpu_write_2(pcp, val) percpu_to_op("mov", (pcp), val)
389#define this_cpu_write_4(pcp, val) percpu_to_op("mov", (pcp), val) 418#define this_cpu_write_4(pcp, val) percpu_to_op("mov", (pcp), val)
@@ -435,7 +464,7 @@ do { \
435 * 32 bit must fall back to generic operations. 464 * 32 bit must fall back to generic operations.
436 */ 465 */
437#ifdef CONFIG_X86_64 466#ifdef CONFIG_X86_64
438#define raw_cpu_read_8(pcp) percpu_from_op("mov", (pcp), "m"(pcp)) 467#define raw_cpu_read_8(pcp) percpu_from_op("mov", pcp)
439#define raw_cpu_write_8(pcp, val) percpu_to_op("mov", (pcp), val) 468#define raw_cpu_write_8(pcp, val) percpu_to_op("mov", (pcp), val)
440#define raw_cpu_add_8(pcp, val) percpu_add_op((pcp), val) 469#define raw_cpu_add_8(pcp, val) percpu_add_op((pcp), val)
441#define raw_cpu_and_8(pcp, val) percpu_to_op("and", (pcp), val) 470#define raw_cpu_and_8(pcp, val) percpu_to_op("and", (pcp), val)
@@ -444,7 +473,7 @@ do { \
444#define raw_cpu_xchg_8(pcp, nval) percpu_xchg_op(pcp, nval) 473#define raw_cpu_xchg_8(pcp, nval) percpu_xchg_op(pcp, nval)
445#define raw_cpu_cmpxchg_8(pcp, oval, nval) percpu_cmpxchg_op(pcp, oval, nval) 474#define raw_cpu_cmpxchg_8(pcp, oval, nval) percpu_cmpxchg_op(pcp, oval, nval)
446 475
447#define this_cpu_read_8(pcp) percpu_from_op("mov", (pcp), "m"(pcp)) 476#define this_cpu_read_8(pcp) percpu_from_op("mov", pcp)
448#define this_cpu_write_8(pcp, val) percpu_to_op("mov", (pcp), val) 477#define this_cpu_write_8(pcp, val) percpu_to_op("mov", (pcp), val)
449#define this_cpu_add_8(pcp, val) percpu_add_op((pcp), val) 478#define this_cpu_add_8(pcp, val) percpu_add_op((pcp), val)
450#define this_cpu_and_8(pcp, val) percpu_to_op("and", (pcp), val) 479#define this_cpu_and_8(pcp, val) percpu_to_op("and", (pcp), val)
@@ -522,7 +551,7 @@ static inline int x86_this_cpu_variable_test_bit(int nr,
522#include <asm-generic/percpu.h> 551#include <asm-generic/percpu.h>
523 552
524/* We can use this directly for local CPU (faster). */ 553/* We can use this directly for local CPU (faster). */
525DECLARE_PER_CPU(unsigned long, this_cpu_off); 554DECLARE_PER_CPU_READ_MOSTLY(unsigned long, this_cpu_off);
526 555
527#endif /* !__ASSEMBLY__ */ 556#endif /* !__ASSEMBLY__ */
528 557
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 9617a1716813..25b8de0f21c0 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -127,7 +127,7 @@ struct cpuinfo_x86 {
127 /* Index into per_cpu list: */ 127 /* Index into per_cpu list: */
128 u16 cpu_index; 128 u16 cpu_index;
129 u32 microcode; 129 u32 microcode;
130} __attribute__((__aligned__(SMP_CACHE_BYTES))); 130};
131 131
132#define X86_VENDOR_INTEL 0 132#define X86_VENDOR_INTEL 0
133#define X86_VENDOR_CYRIX 1 133#define X86_VENDOR_CYRIX 1
@@ -151,7 +151,7 @@ extern __u32 cpu_caps_cleared[NCAPINTS];
151extern __u32 cpu_caps_set[NCAPINTS]; 151extern __u32 cpu_caps_set[NCAPINTS];
152 152
153#ifdef CONFIG_SMP 153#ifdef CONFIG_SMP
154DECLARE_PER_CPU_SHARED_ALIGNED(struct cpuinfo_x86, cpu_info); 154DECLARE_PER_CPU_READ_MOSTLY(struct cpuinfo_x86, cpu_info);
155#define cpu_data(cpu) per_cpu(cpu_info, cpu) 155#define cpu_data(cpu) per_cpu(cpu_info, cpu)
156#else 156#else
157#define cpu_info boot_cpu_data 157#define cpu_info boot_cpu_data