x86/i386: Put aligned stack-canary in percpu shared_aligned section
authorJeremy Fitzhardinge <jeremy@goop.org>
Thu, 3 Sep 2009 21:31:44 +0000 (14:31 -0700)
committerIngo Molnar <mingo@elte.hu>
Fri, 4 Sep 2009 05:10:31 +0000 (07:10 +0200)
Pack aligned things together into a special section to minimize
padding holes.

Suggested-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: Tejun Heo <tj@kernel.org>
LKML-Reference: <4AA035C0.9070202@goop.org>
[ queued up in tip:x86/asm because it depends on this commit:
  x86/i386: Make sure stack-protector segment base is cache aligned ]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/include/asm/processor.h
arch/x86/kernel/cpu/common.c
include/asm-generic/percpu.h
include/linux/percpu-defs.h

index e597ecc8753cc5e0724ae83d2d6eee094e15f4c8..ac7e79654f3af5b898c023c78ea35ef123594cf5 100644 (file)
@@ -413,7 +413,7 @@ struct stack_canary {
        char __pad[20];         /* canary at %gs:20 */
        unsigned long canary;
 };
-DECLARE_PER_CPU(struct stack_canary, stack_canary) ____cacheline_aligned;
+DECLARE_PER_CPU_ALIGNED(struct stack_canary, stack_canary);
 #endif
 #endif /* X86_64 */
 
index 7d84bc4c11884d817c8d955a2ec9b1821c718b2e..f23e236391a3d1da746cd495cc7afdd170c3fc86 100644 (file)
@@ -1043,7 +1043,7 @@ DEFINE_PER_CPU(struct orig_ist, orig_ist);
 #else  /* CONFIG_X86_64 */
 
 #ifdef CONFIG_CC_STACKPROTECTOR
-DEFINE_PER_CPU(struct stack_canary, stack_canary) ____cacheline_aligned;
+DEFINE_PER_CPU_ALIGNED(struct stack_canary, stack_canary);
 #endif
 
 /* Make sure %fs and %gs are initialized properly in idle threads */
index aa00800adaccdfbb751e6d85786474d1775006ce..90079c373f1c462d2957b98b64f5f15b8ea7ac19 100644 (file)
@@ -81,14 +81,17 @@ extern void setup_per_cpu_areas(void);
 
 #ifdef MODULE
 #define PER_CPU_SHARED_ALIGNED_SECTION ""
+#define PER_CPU_ALIGNED_SECTION ""
 #else
 #define PER_CPU_SHARED_ALIGNED_SECTION ".shared_aligned"
+#define PER_CPU_ALIGNED_SECTION ".shared_aligned"
 #endif
 #define PER_CPU_FIRST_SECTION ".first"
 
 #else
 
 #define PER_CPU_SHARED_ALIGNED_SECTION ""
+#define PER_CPU_ALIGNED_SECTION ".shared_aligned"
 #define PER_CPU_FIRST_SECTION ""
 
 #endif
index 68438e18fff4fde80a80af87a00748a3a69b44b7..3058cf9dd3d43a94d7e0a027df734a55d93e0c5d 100644 (file)
        DEFINE_PER_CPU_SECTION(type, name, PER_CPU_SHARED_ALIGNED_SECTION) \
        ____cacheline_aligned_in_smp
 
+#define DECLARE_PER_CPU_ALIGNED(type, name)                            \
+       DECLARE_PER_CPU_SECTION(type, name, PER_CPU_ALIGNED_SECTION)    \
+       ____cacheline_aligned
+
+#define DEFINE_PER_CPU_ALIGNED(type, name)                             \
+       DEFINE_PER_CPU_SECTION(type, name, PER_CPU_ALIGNED_SECTION)     \
+       ____cacheline_aligned
+
 /*
  * Declaration/definition used for per-CPU variables that must be page aligned.
  */