x86: loadsegment() optimization
PATCH 1/1 x86: loadsegment() optimization
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 <[email protected]>
--- arch/x86/include/asm/system.h | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-)
arch/x86/include/asm/system.h +8 -7
@@ -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
Signature · 1 line
1.6.5.2
[tip:x86/asm] x86: Optimize loadsegment()
Commit-ID: 79b0379cee09b00ef309384aff652e328e438c79 Gitweb: http://git.kernel.org/tip/79b0379cee09b00ef309384aff652e328e438c79 Author: Brian Gerst <[email protected]> AuthorDate: Wed, 25 Nov 2009 14:18:26 -0500 Committer: Ingo Molnar <[email protected]> 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 <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by Ingo Molnar <[email protected]>
--- arch/x86/include/asm/system.h | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-)
arch/x86/include/asm/system.h +8 -7
@@ -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
[tip:x86/asm] x86: Clean up the loadsegment() macro
In reply to Brian GerstCommit-ID: 64b028b22616946a05bf9580f7f7f7ee2ac070b4 Gitweb: http://git.kernel.org/tip/64b028b22616946a05bf9580f7f7f7ee2ac070b4 Author: Ingo Molnar <[email protected]> AuthorDate: Thu, 26 Nov 2009 10:37:55 +0100 Committer: Ingo Molnar <[email protected]> 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 <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by Ingo Molnar <[email protected]>
--- arch/x86/include/asm/system.h | 28 +++++++++++++++------------- 1 files changed, 15 insertions(+), 13 deletions(-)
arch/x86/include/asm/system.h +15 -13
@@ -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)/*