[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] xentrace: Remove redundant tb_done_init checks, and add missing ones.



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1202723239 0
# Node ID c68ce89542c7fbba9d00fd3a7d4e190476554e55
# Parent  7a415bce11c9c12a5af36b3504d8ab43bdef8aab
xentrace: Remove redundant tb_done_init checks, and add missing ones.
Hand inspection of gcc -02 output confirms significantly shorter
codepaths for inactive (i.e. normal case) tracing.

Signed-off-by: Michael A Fetterman <Michael.Fetterman@xxxxxxxxxxxx>
---
 xen/arch/x86/trace.c            |   18 ---------
 xen/include/asm-x86/hvm/trace.h |   41 ++++++++++++++++------
 xen/include/asm-x86/trace.h     |   10 ++---
 xen/include/xen/trace.h         |   73 ++++++++++++++++++++++++----------------
 4 files changed, 79 insertions(+), 63 deletions(-)

diff -r 7a415bce11c9 -r c68ce89542c7 xen/arch/x86/trace.c
--- a/xen/arch/x86/trace.c      Mon Feb 11 09:46:53 2008 +0000
+++ b/xen/arch/x86/trace.c      Mon Feb 11 09:47:19 2008 +0000
@@ -15,9 +15,6 @@ asmlinkage void trace_hypercall(void)
 {
     struct cpu_user_regs *regs = guest_cpu_user_regs();
 
-    if ( !tb_init_done )
-        return;
-
 #ifdef __x86_64__
     if ( is_pv_32on64_vcpu(current) )
     {
@@ -52,9 +49,6 @@ void __trace_pv_trap(int trapnr, unsigne
 void __trace_pv_trap(int trapnr, unsigned long eip,
                      int use_error_code, unsigned error_code)
 {
-    if ( !tb_init_done )
-        return;
-
 #ifdef __x86_64__
     if ( is_pv_32on64_vcpu(current) )
     {
@@ -99,9 +93,6 @@ void __trace_pv_page_fault(unsigned long
 {
     unsigned long eip = guest_cpu_user_regs()->eip;
 
-    if ( !tb_init_done )
-        return;
-
 #ifdef __x86_64__
     if ( is_pv_32on64_vcpu(current) )
     {
@@ -135,9 +126,6 @@ void __trace_pv_page_fault(unsigned long
 
 void __trace_trap_one_addr(unsigned event, unsigned long va)
 {
-    if ( !tb_init_done )
-        return;
-
 #ifdef __x86_64__
     if ( is_pv_32on64_vcpu(current) )
     {
@@ -155,9 +143,6 @@ void __trace_trap_two_addr(unsigned even
 void __trace_trap_two_addr(unsigned event, unsigned long va1,
                            unsigned long va2)
 {
-    if ( !tb_init_done )
-        return;
-
 #ifdef __x86_64__
     if ( is_pv_32on64_vcpu(current) )
     {
@@ -184,9 +169,6 @@ void __trace_ptwr_emulation(unsigned lon
 void __trace_ptwr_emulation(unsigned long addr, l1_pgentry_t npte)
 {
     unsigned long eip = guest_cpu_user_regs()->eip;
-
-    if ( !tb_init_done )
-        return;
 
     /* We have a couple of different modes to worry about:
      * - 32-on-32: 32-bit pte, 32-bit virtual addresses
diff -r 7a415bce11c9 -r c68ce89542c7 xen/include/asm-x86/hvm/trace.h
--- a/xen/include/asm-x86/hvm/trace.h   Mon Feb 11 09:46:53 2008 +0000
+++ b/xen/include/asm-x86/hvm/trace.h   Mon Feb 11 09:47:19 2008 +0000
@@ -37,6 +37,9 @@ static inline void hvmtrace_vmexit(struc
                                    unsigned long rip,
                                    unsigned long exit_reason)
 {
+    if ( likely(!tb_init_done) )
+        return;
+
 #ifdef __x86_64__
     if(hvm_long_mode_enabled(v))
     {
@@ -50,7 +53,7 @@ static inline void hvmtrace_vmexit(struc
         d.vid = v->vcpu_id;
         d.exit_reason = exit_reason;
         d.rip = rip;
-        trace_var(TRC_HVM_VMEXIT64, 1/*cycles*/, sizeof(d), (unsigned char 
*)&d);
+        __trace_var(TRC_HVM_VMEXIT64, 1/*cycles*/, sizeof(d), (unsigned char 
*)&d);
     } else {
 #endif
         struct {
@@ -63,7 +66,7 @@ static inline void hvmtrace_vmexit(struc
         d.vid = v->vcpu_id;
         d.exit_reason = exit_reason;
         d.eip = rip;
-        trace_var(TRC_HVM_VMEXIT, 1/*cycles*/, sizeof(d), (unsigned char *)&d);
+        __trace_var(TRC_HVM_VMEXIT, 1/*cycles*/, sizeof(d), (unsigned char 
*)&d);
 #ifdef __x86_64__
     }
 #endif
@@ -75,9 +78,13 @@ static inline void hvmtrace_vmentry(stru
     struct {
         unsigned did:16, vid:16;
     } d;
+
+    if ( likely(!tb_init_done) )
+        return;
+
     d.did = v->domain->domain_id;
     d.vid = v->vcpu_id;
-    trace_var(TRC_HVM_VMENTRY, 1/*cycles*/, sizeof(d), (unsigned char *)&d);
+    __trace_var(TRC_HVM_VMENTRY, 1/*cycles*/, sizeof(d), (unsigned char *)&d);
 }
 
 static inline void hvmtrace_msr_read(struct vcpu *v, u32 ecx, u64 msr_content)
@@ -87,11 +94,15 @@ static inline void hvmtrace_msr_read(str
         u32 ecx;
         u64 msr_content;
     } d;
+
+    if ( likely(!tb_init_done) )
+        return;
+
     d.did = v->domain->domain_id;
     d.vid = v->vcpu_id;
     d.ecx = ecx;
     d.msr_content = msr_content;
-    trace_var(TRC_HVM_MSR_READ, 0/*!cycles*/, sizeof(d), (unsigned char *)&d);
+    __trace_var(TRC_HVM_MSR_READ, 0/*!cycles*/, sizeof(d), (unsigned char 
*)&d);
 }
 
 static inline void hvmtrace_msr_write(struct vcpu *v, u32 ecx, u64 msr_content)
@@ -101,16 +112,23 @@ static inline void hvmtrace_msr_write(st
         u32 ecx;
         u64 msr_content;
     } d;
+
+    if ( likely(!tb_init_done) )
+        return;
+
     d.did = v->domain->domain_id;
     d.vid = v->vcpu_id;
     d.ecx = ecx;
     d.msr_content = msr_content;
-    trace_var(TRC_HVM_MSR_WRITE, 0/*!cycles*/,sizeof(d), (unsigned char *)&d);
+    __trace_var(TRC_HVM_MSR_WRITE, 0/*!cycles*/,sizeof(d), (unsigned char 
*)&d);
 }
 
 static inline void hvmtrace_pf_xen(struct vcpu *v, unsigned long va,
                                    u32 error_code)
 {
+    if ( likely(!tb_init_done) )
+        return;
+
 #ifdef __x86_64__
     if(hvm_long_mode_enabled(v))
     {
@@ -123,8 +141,8 @@ static inline void hvmtrace_pf_xen(struc
         d.vid = v->vcpu_id;
         d.error_code = error_code;
         d.va = va;
-        trace_var(TRC_HVM_PF_XEN64, 0/*!cycles*/,sizeof(d),
-                  (unsigned char *)&d);
+        __trace_var(TRC_HVM_PF_XEN64, 0/*!cycles*/,sizeof(d),
+                    (unsigned char *)&d);
     } else {
 #endif
         struct {
@@ -136,7 +154,8 @@ static inline void hvmtrace_pf_xen(struc
         d.vid = v->vcpu_id;
         d.error_code = error_code;
         d.va = va;
-        trace_var(TRC_HVM_PF_XEN, 0/*!cycles*/,sizeof(d), (unsigned char *)&d);
+        __trace_var(TRC_HVM_PF_XEN, 0/*!cycles*/,sizeof(d),
+                    (unsigned char *)&d);
 #ifdef __x86_64__
     }
 #endif
@@ -144,7 +163,7 @@ static inline void hvmtrace_pf_xen(struc
 
 #define HVMTRACE_ND(evt, vcpu, count, d1, d2, d3, d4)                   \
     do {                                                                \
-        if (DO_TRC_HVM_ ## evt)                                         \
+        if ( unlikely(tb_init_done) && DO_TRC_HVM_ ## evt )             \
         {                                                               \
             struct {                                                    \
                 unsigned did:16, vid:16;                                \
@@ -156,8 +175,8 @@ static inline void hvmtrace_pf_xen(struc
             _d.d[1]=(d2);                                               \
             _d.d[2]=(d3);                                               \
             _d.d[3]=(d4);                                               \
-            trace_var(TRC_HVM_ ## evt, 0/*!cycles*/,                    \
-                      sizeof(u32)*count+1, (unsigned char *)&_d);       \
+            __trace_var(TRC_HVM_ ## evt, 0/*!cycles*/,                  \
+                        sizeof(u32)*count+1, (unsigned char *)&_d);     \
         }                                                               \
     } while(0)
 
diff -r 7a415bce11c9 -r c68ce89542c7 xen/include/asm-x86/trace.h
--- a/xen/include/asm-x86/trace.h       Mon Feb 11 09:46:53 2008 +0000
+++ b/xen/include/asm-x86/trace.h       Mon Feb 11 09:47:19 2008 +0000
@@ -8,7 +8,7 @@ static inline void trace_pv_trap(int tra
 static inline void trace_pv_trap(int trapnr, unsigned long eip,
                                  int use_error_code, unsigned error_code)
 {
-    if ( tb_init_done )
+    if ( unlikely(tb_init_done) )
         __trace_pv_trap(trapnr, eip, use_error_code, error_code);
 }
 
@@ -16,14 +16,14 @@ static inline void trace_pv_page_fault(u
 static inline void trace_pv_page_fault(unsigned long addr,
                                        unsigned error_code)
 {
-    if ( tb_init_done )
+    if ( unlikely(tb_init_done) )
         __trace_pv_page_fault(addr, error_code);
 }
 
 void __trace_trap_one_addr(unsigned event, unsigned long va);
 static inline void trace_trap_one_addr(unsigned event, unsigned long va)
 {
-    if ( tb_init_done )
+    if ( unlikely(tb_init_done) )
         __trace_trap_one_addr(event, va);
 }
 
@@ -32,14 +32,14 @@ static inline void trace_trap_two_addr(u
 static inline void trace_trap_two_addr(unsigned event, unsigned long va1,
                                        unsigned long va2)
 {
-    if ( tb_init_done )
+    if ( unlikely(tb_init_done) )
         __trace_trap_two_addr(event, va1, va2);
 }
 
 void __trace_ptwr_emulation(unsigned long addr, l1_pgentry_t npte);
 static inline void trace_ptwr_emulation(unsigned long addr, l1_pgentry_t npte)
 {
-    if ( tb_init_done )
+    if ( unlikely(tb_init_done) )
         __trace_ptwr_emulation(addr, npte);
 }
 
diff -r 7a415bce11c9 -r c68ce89542c7 xen/include/xen/trace.h
--- a/xen/include/xen/trace.h   Mon Feb 11 09:46:53 2008 +0000
+++ b/xen/include/xen/trace.h   Mon Feb 11 09:47:19 2008 +0000
@@ -39,7 +39,7 @@ static inline void trace_var(u32 event, 
 static inline void trace_var(u32 event, int cycles, int extra,
                                unsigned char *extra_data)
 {
-    if( unlikely(tb_init_done) )
+    if ( unlikely(tb_init_done) )
         __trace_var(event, cycles, extra, extra_data);
 }
 
@@ -49,49 +49,64 @@ static inline void trace_var(u32 event, 
         trace_var(_e, 1, 0, NULL);              \
     } while ( 0 )
   
-#define TRACE_1D(_e,_d)                                         \
+#define TRACE_1D(_e,d1)                                         \
     do {                                                        \
-        u32 _d1;                                                \
-        _d1 = _d;                                               \
-        trace_var(_e, 1, sizeof(_d1), (unsigned char *)&_d1);  \
+        if ( unlikely(tb_init_done) )                           \
+        {                                                       \
+            u32 _d[1];                                          \
+            _d[0] = d1;                                         \
+            __trace_var(_e, 1, sizeof(*_d), (unsigned char *)_d); \
+        }                                                       \
     } while ( 0 )
  
 #define TRACE_2D(_e,d1,d2)                                      \
-    do {                                                       \
-        u32 _d[2];                                             \
-        _d[0]=d1;                                              \
-        _d[1]=d2;                                              \
-        trace_var(_e, 1, sizeof(*_d)*2, (unsigned char *)_d);  \
+    do {                                                        \
+        if ( unlikely(tb_init_done) )                           \
+        {                                                       \
+            u32 _d[2];                                          \
+            _d[0] = d1;                                         \
+            _d[1] = d2;                                         \
+            __trace_var(_e, 1, sizeof(*_d)*2, (unsigned char *)_d); \
+        }                                                       \
     } while ( 0 )
  
 #define TRACE_3D(_e,d1,d2,d3)                                   \
     do {                                                        \
-        u32 _d[3];                                              \
-        _d[0]=d1;                                               \
-        _d[1]=d2;                                               \
-        _d[2]=d3;                                               \
-        trace_var(_e, 1, sizeof(*_d)*3, (unsigned char *)_d);  \
+        if ( unlikely(tb_init_done) )                           \
+        {                                                       \
+            u32 _d[3];                                          \
+            _d[0] = d1;                                         \
+            _d[1] = d2;                                         \
+            _d[2] = d3;                                         \
+            __trace_var(_e, 1, sizeof(*_d)*3, (unsigned char *)_d); \
+        }                                                       \
     } while ( 0 )
  
 #define TRACE_4D(_e,d1,d2,d3,d4)                                \
     do {                                                        \
-        u32 _d[4];                                              \
-        _d[0]=d1;                                               \
-        _d[1]=d2;                                               \
-        _d[2]=d3;                                               \
-        _d[3]=d4;                                               \
-        trace_var(_e, 1, sizeof(*_d)*4, (unsigned char *)_d);  \
+        if ( unlikely(tb_init_done) )                           \
+        {                                                       \
+            u32 _d[4];                                          \
+            _d[0] = d1;                                         \
+            _d[1] = d2;                                         \
+            _d[2] = d3;                                         \
+            _d[3] = d4;                                         \
+            __trace_var(_e, 1, sizeof(*_d)*4, (unsigned char *)_d); \
+        }                                                       \
     } while ( 0 )
  
 #define TRACE_5D(_e,d1,d2,d3,d4,d5)                             \
-    do {                                                       \
-        u32 _d[5];                                             \
-        _d[0]=d1;                                              \
-        _d[1]=d2;                                              \
-        _d[2]=d3;                                              \
-        _d[3]=d4;                                              \
-        _d[4]=d5;                                              \
-        trace_var(_e, 1, sizeof(*_d)*5, (unsigned char *)_d);  \
+    do {                                                        \
+        if ( unlikely(tb_init_done) )                           \
+        {                                                       \
+            u32 _d[5];                                          \
+            _d[0] = d1;                                         \
+            _d[1] = d2;                                         \
+            _d[2] = d3;                                         \
+            _d[3] = d4;                                         \
+            _d[4] = d5;                                         \
+            __trace_var(_e, 1, sizeof(*_d)*5, (unsigned char *)_d); \
+        }                                                       \
     } while ( 0 )
 
 #endif /* __XEN_TRACE_H__ */

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.