* [PATCH] x86: loadsegment() optimization
@ 2009-11-25 19:18 Brian Gerst
2009-11-26 9:55 ` [tip:x86/asm] x86: Optimize loadsegment() tip-bot for Brian Gerst
2009-11-26 9:56 ` [tip:x86/asm] x86: Clean up the loadsegment() macro tip-bot for Ingo Molnar
0 siblings, 2 replies; 3+ messages in thread
From: Brian Gerst @ 2009-11-25 19:18 UTC (permalink / raw)
To: Ingo Molnar; +Cc: x86, linux-kernel
Zero the input register in the exception handler instead of using
an extra register to pass in a zero value.
Signed-off-by: Brian Gerst <brgerst@gmail.com>
---
arch/x86/include/asm/system.h | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/arch/x86/include/asm/system.h b/arch/x86/include/asm/system.h
index f08f973..18ac1ec 100644
--- a/arch/x86/include/asm/system.h
+++ b/arch/x86/include/asm/system.h
@@ -158,18 +158,19 @@ extern void native_load_gs_index(unsigned);
* segment if something goes wrong..
*/
#define loadsegment(seg, value) \
+do { \
+ unsigned short __val = value; \
asm volatile("\n" \
"1:\t" \
"movl %k0,%%" #seg "\n" \
- "2:\n" \
".section .fixup,\"ax\"\n" \
- "3:\t" \
- "movl %k1, %%" #seg "\n\t" \
- "jmp 2b\n" \
+ "2:\t" \
+ "xorl %k0,%k0\n\t" \
+ "jmp 1b\n" \
".previous\n" \
- _ASM_EXTABLE(1b,3b) \
- : :"r" (value), "r" (0) : "memory")
-
+ _ASM_EXTABLE(1b,2b) \
+ : "+r" (__val) : : "memory"); \
+} while (0)
/*
* Save a segment register away
--
1.6.5.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [tip:x86/asm] x86: Optimize loadsegment()
2009-11-25 19:18 [PATCH] x86: loadsegment() optimization Brian Gerst
@ 2009-11-26 9:55 ` tip-bot for Brian Gerst
2009-11-26 9:56 ` [tip:x86/asm] x86: Clean up the loadsegment() macro tip-bot for Ingo Molnar
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Brian Gerst @ 2009-11-26 9:55 UTC (permalink / raw)
To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, brgerst, tglx, mingo
Commit-ID: 79b0379cee09b00ef309384aff652e328e438c79
Gitweb: http://git.kernel.org/tip/79b0379cee09b00ef309384aff652e328e438c79
Author: Brian Gerst <brgerst@gmail.com>
AuthorDate: Wed, 25 Nov 2009 14:18:26 -0500
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 26 Nov 2009 10:33:58 +0100
x86: Optimize loadsegment()
Zero the input register in the exception handler instead of
using an extra register to pass in a zero value.
Signed-off-by: Brian Gerst <brgerst@gmail.com>
LKML-Reference: <1259176706-5908-1-git-send-email-brgerst@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86/include/asm/system.h | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/arch/x86/include/asm/system.h b/arch/x86/include/asm/system.h
index 1a953e2..537395a 100644
--- a/arch/x86/include/asm/system.h
+++ b/arch/x86/include/asm/system.h
@@ -156,18 +156,19 @@ extern void native_load_gs_index(unsigned);
* segment if something goes wrong..
*/
#define loadsegment(seg, value) \
+do { \
+ unsigned short __val = value; \
asm volatile("\n" \
"1:\t" \
"movl %k0,%%" #seg "\n" \
- "2:\n" \
".section .fixup,\"ax\"\n" \
- "3:\t" \
- "movl %k1, %%" #seg "\n\t" \
- "jmp 2b\n" \
+ "2:\t" \
+ "xorl %k0,%k0\n\t" \
+ "jmp 1b\n" \
".previous\n" \
- _ASM_EXTABLE(1b,3b) \
- : :"r" (value), "r" (0) : "memory")
-
+ _ASM_EXTABLE(1b, 2b) \
+ : "+r" (__val) : : "memory"); \
+} while (0)
/*
* Save a segment register away
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [tip:x86/asm] x86: Clean up the loadsegment() macro
2009-11-25 19:18 [PATCH] x86: loadsegment() optimization Brian Gerst
2009-11-26 9:55 ` [tip:x86/asm] x86: Optimize loadsegment() tip-bot for Brian Gerst
@ 2009-11-26 9:56 ` tip-bot for Ingo Molnar
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Ingo Molnar @ 2009-11-26 9:56 UTC (permalink / raw)
To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, brgerst, tglx, mingo
Commit-ID: 64b028b22616946a05bf9580f7f7f7ee2ac070b4
Gitweb: http://git.kernel.org/tip/64b028b22616946a05bf9580f7f7f7ee2ac070b4
Author: Ingo Molnar <mingo@elte.hu>
AuthorDate: Thu, 26 Nov 2009 10:37:55 +0100
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 26 Nov 2009 10:38:52 +0100
x86: Clean up the loadsegment() macro
Make it readable in the source too, not just in the assembly output.
No change in functionality.
Cc: Brian Gerst <brgerst@gmail.com>
LKML-Reference: <1259176706-5908-1-git-send-email-brgerst@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
arch/x86/include/asm/system.h | 28 +++++++++++++++-------------
1 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/arch/x86/include/asm/system.h b/arch/x86/include/asm/system.h
index 537395a..022a843 100644
--- a/arch/x86/include/asm/system.h
+++ b/arch/x86/include/asm/system.h
@@ -155,19 +155,21 @@ extern void native_load_gs_index(unsigned);
* Load a segment. Fall back on loading the zero
* segment if something goes wrong..
*/
-#define loadsegment(seg, value) \
-do { \
- unsigned short __val = value; \
- asm volatile("\n" \
- "1:\t" \
- "movl %k0,%%" #seg "\n" \
- ".section .fixup,\"ax\"\n" \
- "2:\t" \
- "xorl %k0,%k0\n\t" \
- "jmp 1b\n" \
- ".previous\n" \
- _ASM_EXTABLE(1b, 2b) \
- : "+r" (__val) : : "memory"); \
+#define loadsegment(seg, value) \
+do { \
+ unsigned short __val = (value); \
+ \
+ asm volatile(" \n" \
+ "1: movl %k0,%%" #seg " \n" \
+ \
+ ".section .fixup,\"ax\" \n" \
+ "2: xorl %k0,%k0 \n" \
+ " jmp 1b \n" \
+ ".previous \n" \
+ \
+ _ASM_EXTABLE(1b, 2b) \
+ \
+ : "+r" (__val) : : "memory"); \
} while (0)
/*
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-11-26 9:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-25 19:18 [PATCH] x86: loadsegment() optimization Brian Gerst
2009-11-26 9:55 ` [tip:x86/asm] x86: Optimize loadsegment() tip-bot for Brian Gerst
2009-11-26 9:56 ` [tip:x86/asm] x86: Clean up the loadsegment() macro tip-bot for Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox