[PATCH 3/6] x86-64: Put vsyscall_gtod_data at a fixed virtual address

From: Andy Lutomirski
Date: Mon Mar 28 2011 - 11:12:39 EST


This generates slightly better code because vclock_gettime doesn't
need to load the address.

Signed-off-by: Andy Lutomirski <luto@xxxxxxx>
---
arch/x86/kernel/vmlinux.lds.S | 13 +++++++------
arch/x86/vdso/vextern.h | 9 ++++++++-
2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index bf47007..1f545ff 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -174,12 +174,6 @@ SECTIONS
*(.vsyscall_fn)
}

- . = ALIGN(L1_CACHE_BYTES);
- .vsyscall_gtod_data : AT(VLOAD(.vsyscall_gtod_data)) {
- *(.vsyscall_gtod_data)
- }
-
- vsyscall_gtod_data = VVIRT(.vsyscall_gtod_data);
.vsyscall_clock : AT(VLOAD(.vsyscall_clock)) {
*(.vsyscall_clock)
}
@@ -208,6 +202,13 @@ SECTIONS
*(.vsyscall_3)
}

+ /* This address must be kept in sync with arch/x86/vdso/vextern.h */
+ .vsyscall_gtod_data ADDR(.vsyscall_0) + 3072 + 256:
+ AT(VLOAD(.vsyscall_gtod_data)) {
+ *(.vsyscall_gtod_data)
+ }
+ vsyscall_gtod_data = VVIRT(.vsyscall_gtod_data);
+
. = __vsyscall_0 + PAGE_SIZE;

#undef VSYSCALL_ADDR
diff --git a/arch/x86/vdso/vextern.h b/arch/x86/vdso/vextern.h
index 1683ba2..5bfa77c 100644
--- a/arch/x86/vdso/vextern.h
+++ b/arch/x86/vdso/vextern.h
@@ -2,6 +2,11 @@
#include <asm/vsyscall.h>
#define VEXTERN(x) \
extern typeof(x) *vdso_ ## x __attribute__((visibility("hidden")));
+#define VEXTERN_FIXED(x, offset) \
+ static typeof(x) * const vdso_ ## x = \
+ (void *)(VSYSCALL_START + (offset));
+#else
+#define VEXTERN_FIXED(x, offset)
#endif

#define VMAGIC 0xfeedbabeabcdefabUL
@@ -13,4 +18,6 @@

VEXTERN(jiffies)
VEXTERN(vgetcpu_mode)
-VEXTERN(vsyscall_gtod_data)
+VEXTERN_FIXED(vsyscall_gtod_data, 3072 + 256) /* Hard-coded in linker script */
+
+#undef VEXTERN_FIXED
--
1.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/