From: Christoph Lameter <clameter@sgi.com>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: Andi Kleen <ak@suse.de>, Jeremy Fitzhardinge <jeremy@goop.org>
Cc: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Subject: [patch 3/3] x86_64: Make the x86_32 percpu operations usable on x86_64
Date: Thu, 29 Nov 2007 22:43:08 -0800 [thread overview]
Message-ID: <20071130064400.054191278@sgi.com> (raw)
In-Reply-To: 20071130064305.459255715@sgi.com
[-- Attachment #1: x86_64_rebase_compat --]
[-- Type: text/plain, Size: 3798 bytes --]
Relocate the x86_64 percpu variables to begin at zero. Then
we can directly use the x86_32 percpu operations. x86_32
offsets %fs by __per_cpu_start. x86_64 has %gs pointing
directly to the pda and the per cpu area if they start at zero.
Access to the pda with the x86_64 pda operations is still
possible in addition to access to the per cpu variables
using x86_32 percpu operations.
Hopefully this is helpful for arch integration.
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
arch/x86/Kconfig | 5 +++++
arch/x86/kernel/setup64.c | 4 ++--
arch/x86/kernel/vmlinux_64.lds.S | 1 +
include/asm-x86/percpu.h | 12 +++++++++++-
4 files changed, 19 insertions(+), 3 deletions(-)
Index: linux-2.6.24-rc3-mm2/include/asm-x86/percpu.h
===================================================================
--- linux-2.6.24-rc3-mm2.orig/include/asm-x86/percpu.h 2007-11-29 22:13:54.806575787 -0800
+++ linux-2.6.24-rc3-mm2/include/asm-x86/percpu.h 2007-11-29 22:21:42.383571603 -0800
@@ -17,6 +17,12 @@
#define per_cpu_offset(x) (__per_cpu_offset(x))
+#define __percpu_seg "%%gs:"
+
+#else
+
+#define __percpu_seg ""
+
#endif
#include <asm-generic/percpu.h>
@@ -81,6 +87,11 @@ DECLARE_PER_CPU(struct x8664_pda, pda);
/* We can use this directly for local CPU (faster). */
DECLARE_PER_CPU(unsigned long, this_cpu_off);
+#endif /* __ASSEMBLY__ */
+#endif /* !CONFIG_X86_64 */
+
+#ifndef __ASSEMBLY__
+
/* For arch-specific code, we can use direct single-insn ops (they
* don't give an lvalue though). */
extern void __bad_percpu_size(void);
@@ -138,5 +149,4 @@ extern void __bad_percpu_size(void);
#define x86_sub_percpu(var,val) percpu_to_op("sub", per_cpu__##var, val)
#define x86_or_percpu(var,val) percpu_to_op("or", per_cpu__##var, val)
#endif /* !__ASSEMBLY__ */
-#endif /* !CONFIG_X86_64 */
#endif /* _ASM_X86_PERCPU_H_ */
Index: linux-2.6.24-rc3-mm2/arch/x86/Kconfig
===================================================================
--- linux-2.6.24-rc3-mm2.orig/arch/x86/Kconfig 2007-11-29 22:05:39.003576212 -0800
+++ linux-2.6.24-rc3-mm2/arch/x86/Kconfig 2007-11-29 22:12:53.942575452 -0800
@@ -123,6 +123,11 @@ config GENERIC_TIME_VSYSCALL
config ARCH_SETS_UP_PER_CPU_AREA
def_bool X86_64
+config PERCPU_ZERO_BASED
+ bool
+ depends on X86_64 && SMP
+ default y
+
config ZONE_DMA32
bool
default X86_64
Index: linux-2.6.24-rc3-mm2/arch/x86/kernel/setup64.c
===================================================================
--- linux-2.6.24-rc3-mm2.orig/arch/x86/kernel/setup64.c 2007-11-29 22:12:08.962826086 -0800
+++ linux-2.6.24-rc3-mm2/arch/x86/kernel/setup64.c 2007-11-29 22:12:53.942575452 -0800
@@ -111,11 +111,11 @@ void __init setup_per_cpu_areas(void)
}
if (!ptr)
panic("Cannot allocate cpu data for CPU %d\n", i);
- memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
+ memcpy(ptr, __per_cpu_load, __per_cpu_size);
/* Relocate the pda */
memcpy(ptr, cpu_pda(i), sizeof(struct x8664_pda));
cpu_pda(i) = (struct x8664_pda *)ptr;
- cpu_pda(i)->data_offset = ptr - __per_cpu_start;
+ cpu_pda(i)->data_offset = (unsigned long)ptr;
}
/* Fix up pda for this processor .... */
pda_init(0);
Index: linux-2.6.24-rc3-mm2/arch/x86/kernel/vmlinux_64.lds.S
===================================================================
--- linux-2.6.24-rc3-mm2.orig/arch/x86/kernel/vmlinux_64.lds.S 2007-11-29 22:05:38.987576338 -0800
+++ linux-2.6.24-rc3-mm2/arch/x86/kernel/vmlinux_64.lds.S 2007-11-29 22:12:53.930825752 -0800
@@ -16,6 +16,7 @@ jiffies_64 = jiffies;
_proxy_pda = 1;
PHDRS {
text PT_LOAD FLAGS(5); /* R_E */
+ percpu PT_LOAD FLAGS(4); /* R__ */
data PT_LOAD FLAGS(7); /* RWE */
user PT_LOAD FLAGS(7); /* RWE */
data.init PT_LOAD FLAGS(7); /* RWE */
--
next prev parent reply other threads:[~2007-11-30 6:45 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-30 6:43 [patch 0/3] Per cpu relocation to ZERO and x86_32 percpu ops on x86_64 Christoph Lameter
2007-11-30 6:43 ` [patch 1/3] Percpu infrastructure to rebase the per cpu area to 0UL Christoph Lameter
2007-12-02 3:04 ` Rusty Russell
2007-12-02 3:13 ` Rusty Russell
2007-11-30 6:43 ` [patch 2/3] X86_64: Declare pda as per cpu data thereby moving it into the cpu area Christoph Lameter
2007-11-30 6:43 ` Christoph Lameter [this message]
2007-11-30 20:07 ` [patch 3/3] x86_64: Make the x86_32 percpu operations usable on x86_64 Christoph Lameter
2007-11-30 11:24 ` [patch 0/3] Per cpu relocation to ZERO and x86_32 percpu ops " Ingo Molnar
2007-11-30 11:26 ` Ingo Molnar
2007-11-30 17:08 ` Christoph Lameter
2007-11-30 17:19 ` Christoph Lameter
2007-11-30 18:00 ` Ingo Molnar
2007-11-30 18:24 ` Christoph Lameter
2007-11-30 18:35 ` Ingo Molnar
2007-11-30 18:47 ` Christoph Lameter
2007-11-30 19:45 ` Ingo Molnar
2007-11-30 19:59 ` Christoph Lameter
2007-11-30 20:06 ` Ingo Molnar
2007-11-30 20:09 ` Christoph Lameter
2007-11-30 20:26 ` Ingo Molnar
2007-11-30 20:43 ` Ingo Molnar
2007-11-30 18:41 ` Ingo Molnar
2007-11-30 18:43 ` Christoph Lameter
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=20071130064400.054191278@sgi.com \
--to=clameter@sgi.com \
--cc=ak@suse.de \
--cc=jeremy@goop.org \
--cc=rusty@rustcorp.com.au \
/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