All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/current: Provide additional information to optimise get_cpu_info()
@ 2014-09-01 10:58 Andrew Cooper
  2014-09-01 11:24 ` Jan Beulich
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Cooper @ 2014-09-01 10:58 UTC (permalink / raw)
  To: Xen-devel; +Cc: Andrew Cooper, Jan Beulich

Exactly as with c/s d55c5eefe "x86: use compiler visible "add" instead of
inline assembly "or" in get_cpu_info()", this is achieved by providing more
information to the compiler.

With this modification, gcc replaces the older:
    mov imm, %reg
    and %rsp, %reg

with:
    mov %rsp, %reg
    and imm, %reg

which is one byte shorter.  It also considers all general purpose registers
for %reg rather than just the legacy ones (i.e. will now use %r12 etc), which
allows for better register scheduling in larger functions.

This causes a net drop of almost 4K of .text

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Jan Beulich <JBeulich@suse.com>
---
 xen/include/asm-x86/current.h |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/include/asm-x86/current.h b/xen/include/asm-x86/current.h
index 2081015..b95fd79 100644
--- a/xen/include/asm-x86/current.h
+++ b/xen/include/asm-x86/current.h
@@ -25,9 +25,9 @@ struct cpu_info {
 
 static inline struct cpu_info *get_cpu_info(void)
 {
-    unsigned long tos;
-    __asm__ ( "and %%rsp,%0" : "=r" (tos) : "0" (~(STACK_SIZE-1)) );
-    return (struct cpu_info *)(tos + STACK_SIZE) - 1;
+    register unsigned long sp asm("rsp");
+
+    return (struct cpu_info *)((sp & ~(STACK_SIZE-1)) + STACK_SIZE) - 1;
 }
 
 #define get_current()         (get_cpu_info()->current_vcpu)
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-09-15  8:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-01 10:58 [PATCH] x86/current: Provide additional information to optimise get_cpu_info() Andrew Cooper
2014-09-01 11:24 ` Jan Beulich
2014-09-01 12:18   ` Andrew Cooper
2014-09-01 12:32     ` Jan Beulich
2014-09-01 15:27       ` [PATCH v2] " Andrew Cooper
2014-09-13 16:10         ` Marcin Cieslak
2014-09-15  8:16           ` Andrew Cooper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.