From: Shaohua Li <shaohua.li@intel.com>
To: lkml <linux-kernel@vger.kernel.org>
Cc: "hpa@zytor.com" <hpa@zytor.com>,
Andrew Morton <akpm@linux-foundation.org>,
sam@ravnborg.org, eric.dumazet@gmail.com
Subject: [patch 2/3] add new macros to make percpu readmostly section correctly align
Date: Thu, 02 Dec 2010 10:02:27 +0800 [thread overview]
Message-ID: <1291255347.12777.116.camel@sli10-conroe> (raw)
percpu readmostly section should start and end at address cachline aligned.
Idealy we should change PERCPU_VADDR/PERCPU, but I can't change all arch code, so
I add new macros for x86.
Signed-off-by: Shaohua Li <shaohua.li@intel.com>
---
include/asm-generic/vmlinux.lds.h | 66 ++++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+)
Index: linux/include/asm-generic/vmlinux.lds.h
===================================================================
--- linux.orig/include/asm-generic/vmlinux.lds.h 2010-12-02 09:22:32.000000000 +0800
+++ linux/include/asm-generic/vmlinux.lds.h 2010-12-02 09:32:42.000000000 +0800
@@ -726,6 +726,72 @@
VMLINUX_SYMBOL(__per_cpu_end) = .; \
}
+/**
+ * PERCPU_VADDR_CACHEALIGNED - define output section for percpu area
+ * @vaddr: explicit base address (optional)
+ * @phdr: destination PHDR (optional)
+ * @cacheline: cachline size required by readmostly percpu data
+ *
+ * Macro which expands to output section for percpu area. If @vaddr
+ * is not blank, it specifies explicit base address and all percpu
+ * symbols will be offset from the given address. If blank, @vaddr
+ * always equals @laddr + LOAD_OFFSET.
+ *
+ * @phdr defines the output PHDR to use if not blank. Be warned that
+ * output PHDR is sticky. If @phdr is specified, the next output
+ * section in the linker script will go there too. @phdr should have
+ * a leading colon.
+ *
+ * Note that this macros defines __per_cpu_load as an absolute symbol.
+ * If there is no need to put the percpu section at a predetermined
+ * address, use PERCPU_CACHEALIGNED().
+ */
+#define PERCPU_VADDR_CACHEALIGNED(vaddr, phdr, cacheline) \
+ VMLINUX_SYMBOL(__per_cpu_load) = .; \
+ .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
+ - LOAD_OFFSET) { \
+ VMLINUX_SYMBOL(__per_cpu_start) = .; \
+ *(.data..percpu..first) \
+ . = ALIGN(PAGE_SIZE); \
+ *(.data..percpu..page_aligned) \
+ . = ALIGN(cacheline); \
+ *(.data..percpu..readmostly) \
+ . = ALIGN(cacheline); \
+ *(.data..percpu) \
+ *(.data..percpu..shared_aligned) \
+ VMLINUX_SYMBOL(__per_cpu_end) = .; \
+ } phdr \
+ . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
+
+/**
+ * PERCPU_CACHEALIGNED - define output section for percpu area, simple version
+ * @align: required alignment
+ * @cacheline: cachline size required by readmostly percpu data
+ *
+ * Align to @align and outputs output section for percpu area. This
+ * macro doesn't maniuplate @vaddr or @phdr and __per_cpu_load and
+ * __per_cpu_start will be identical.
+ *
+ * This macro is equivalent to ALIGN(align); PERCPU_VADDR_CACHEALIGNED( , ) except
+ * that __per_cpu_load is defined as a relative symbol against
+ * .data..percpu which is required for relocatable x86_32
+ * configuration.
+ */
+#define PERCPU_CACHEALIGNED(align, cacheline) \
+ . = ALIGN(align); \
+ .data..percpu : AT(ADDR(.data..percpu) - LOAD_OFFSET) { \
+ VMLINUX_SYMBOL(__per_cpu_load) = .; \
+ VMLINUX_SYMBOL(__per_cpu_start) = .; \
+ *(.data..percpu..first) \
+ . = ALIGN(PAGE_SIZE); \
+ *(.data..percpu..page_aligned) \
+ . = ALIGN(cacheline); \
+ *(.data..percpu..readmostly) \
+ . = ALIGN(cacheline); \
+ *(.data..percpu) \
+ *(.data..percpu..shared_aligned) \
+ VMLINUX_SYMBOL(__per_cpu_end) = .; \
+ }
/*
* Definition of the high level *_SECTION macros
next reply other threads:[~2010-12-02 2:03 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-02 2:02 Shaohua Li [this message]
2010-12-10 15:14 ` [patch 2/3] add new macros to make percpu readmostly section correctly align Tejun Heo
2010-12-13 0:41 ` Shaohua Li
2010-12-13 9:47 ` Tejun Heo
2010-12-14 1:08 ` Shaohua Li
2010-12-14 9:58 ` Tejun Heo
2010-12-15 1:57 ` Shaohua Li
2010-12-15 14:08 ` Tejun Heo
2010-12-15 14:49 ` Tejun Heo
2010-12-16 0:55 ` Shaohua Li
2010-12-16 0:53 ` Shaohua Li
2010-12-16 5:46 ` Sam Ravnborg
2010-12-16 5:56 ` Shaohua Li
2010-12-16 9:50 ` Tejun Heo
2010-12-20 1:28 ` Shaohua Li
2010-12-20 15:55 ` Tejun Heo
2010-12-23 2:38 ` Shaohua Li
2010-12-27 12:14 ` Tejun Heo
2010-12-28 0:26 ` Shaohua Li
2010-12-28 11:13 ` Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1291255347.12777.116.camel@sli10-conroe \
--to=shaohua.li@intel.com \
--cc=akpm@linux-foundation.org \
--cc=eric.dumazet@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sam@ravnborg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox