WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] x86: optimize this_cpu()

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] x86: optimize this_cpu()
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 13 Jul 2010 10:25:35 -0700
Delivery-date: Tue, 13 Jul 2010 10:27:55 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1279041448 -3600
# Node ID d867eb643fe4d9e5ee95fac945df5971dadd345c
# Parent  f72879804eb083dec369f450d35ba8a16a1ad020
x86: optimize this_cpu()

Besides the .text space savings of over 2.5k on x86-64 (1.5k for
x86-32) this removes a load (plus a lea on x86-64) from various
frequently executed code paths, and finally provides a reason (other
than legibility) to prefer this_cpu() over per_cpu() in all places
where smp_processor_id() isn't being called anyway.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
---
 xen/include/asm-x86/current.h |   13 ++++++++++---
 xen/include/asm-x86/percpu.h  |    2 +-
 2 files changed, 11 insertions(+), 4 deletions(-)

diff -r f72879804eb0 -r d867eb643fe4 xen/include/asm-x86/current.h
--- a/xen/include/asm-x86/current.h     Tue Jul 13 18:13:33 2010 +0100
+++ b/xen/include/asm-x86/current.h     Tue Jul 13 18:17:28 2010 +0100
@@ -16,8 +16,12 @@ struct vcpu;
 
 struct cpu_info {
     struct cpu_user_regs guest_cpu_user_regs;
-    unsigned int         processor_id;
-    struct vcpu         *current_vcpu;
+    unsigned int processor_id;
+    struct vcpu *current_vcpu;
+    unsigned long per_cpu_offset;
+#ifdef __x86_64__ /* get_stack_bottom() must be 16-byte aligned */
+    unsigned long __pad_for_stack_bottom;
+#endif
 };
 
 static inline struct cpu_info *get_cpu_info(void)
@@ -35,7 +39,10 @@ static inline struct cpu_info *get_cpu_i
 #define current               (get_current())
 
 #define get_processor_id()    (get_cpu_info()->processor_id)
-#define set_processor_id(id)  (get_cpu_info()->processor_id = (id))
+#define set_processor_id(id)  do {                                      \
+    struct cpu_info *ci__ = get_cpu_info();                             \
+    ci__->per_cpu_offset = __per_cpu_offset[ci__->processor_id = (id)]; \
+} while (0)
 
 #define guest_cpu_user_regs() (&get_cpu_info()->guest_cpu_user_regs)
 
diff -r f72879804eb0 -r d867eb643fe4 xen/include/asm-x86/percpu.h
--- a/xen/include/asm-x86/percpu.h      Tue Jul 13 18:13:33 2010 +0100
+++ b/xen/include/asm-x86/percpu.h      Tue Jul 13 18:17:28 2010 +0100
@@ -16,7 +16,7 @@ void percpu_init_areas(void);
 #define per_cpu(var, cpu)  \
     (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu]))
 #define __get_cpu_var(var) \
-    (per_cpu(var, smp_processor_id()))
+    (*RELOC_HIDE(&per_cpu__##var, get_cpu_info()->per_cpu_offset))
 
 #define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] x86: optimize this_cpu(), Xen patchbot-unstable <=