ia64/xen-unstable

changeset 17016:c68ce89542c7

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@cl.cam.ac.uk>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Feb 11 09:47:19 2008 +0000 (2008-02-11)
parents 7a415bce11c9
children 96b418cf047e
files xen/arch/x86/trace.c xen/include/asm-x86/hvm/trace.h xen/include/asm-x86/trace.h xen/include/xen/trace.h
line diff
     1.1 --- a/xen/arch/x86/trace.c	Mon Feb 11 09:46:53 2008 +0000
     1.2 +++ b/xen/arch/x86/trace.c	Mon Feb 11 09:47:19 2008 +0000
     1.3 @@ -15,9 +15,6 @@ asmlinkage void trace_hypercall(void)
     1.4  {
     1.5      struct cpu_user_regs *regs = guest_cpu_user_regs();
     1.6  
     1.7 -    if ( !tb_init_done )
     1.8 -        return;
     1.9 -
    1.10  #ifdef __x86_64__
    1.11      if ( is_pv_32on64_vcpu(current) )
    1.12      {
    1.13 @@ -52,9 +49,6 @@ asmlinkage void trace_hypercall(void)
    1.14  void __trace_pv_trap(int trapnr, unsigned long eip,
    1.15                       int use_error_code, unsigned error_code)
    1.16  {
    1.17 -    if ( !tb_init_done )
    1.18 -        return;
    1.19 -
    1.20  #ifdef __x86_64__
    1.21      if ( is_pv_32on64_vcpu(current) )
    1.22      {
    1.23 @@ -99,9 +93,6 @@ void __trace_pv_page_fault(unsigned long
    1.24  {
    1.25      unsigned long eip = guest_cpu_user_regs()->eip;
    1.26  
    1.27 -    if ( !tb_init_done )
    1.28 -        return;
    1.29 -
    1.30  #ifdef __x86_64__
    1.31      if ( is_pv_32on64_vcpu(current) )
    1.32      {
    1.33 @@ -135,9 +126,6 @@ void __trace_pv_page_fault(unsigned long
    1.34  
    1.35  void __trace_trap_one_addr(unsigned event, unsigned long va)
    1.36  {
    1.37 -    if ( !tb_init_done )
    1.38 -        return;
    1.39 -
    1.40  #ifdef __x86_64__
    1.41      if ( is_pv_32on64_vcpu(current) )
    1.42      {
    1.43 @@ -155,9 +143,6 @@ void __trace_trap_one_addr(unsigned even
    1.44  void __trace_trap_two_addr(unsigned event, unsigned long va1,
    1.45                             unsigned long va2)
    1.46  {
    1.47 -    if ( !tb_init_done )
    1.48 -        return;
    1.49 -
    1.50  #ifdef __x86_64__
    1.51      if ( is_pv_32on64_vcpu(current) )
    1.52      {
    1.53 @@ -185,9 +170,6 @@ void __trace_ptwr_emulation(unsigned lon
    1.54  {
    1.55      unsigned long eip = guest_cpu_user_regs()->eip;
    1.56  
    1.57 -    if ( !tb_init_done )
    1.58 -        return;
    1.59 -
    1.60      /* We have a couple of different modes to worry about:
    1.61       * - 32-on-32: 32-bit pte, 32-bit virtual addresses
    1.62       * - pae-on-pae, pae-on-64: 64-bit pte, 32-bit virtual addresses
     2.1 --- a/xen/include/asm-x86/hvm/trace.h	Mon Feb 11 09:46:53 2008 +0000
     2.2 +++ b/xen/include/asm-x86/hvm/trace.h	Mon Feb 11 09:47:19 2008 +0000
     2.3 @@ -37,6 +37,9 @@ static inline void hvmtrace_vmexit(struc
     2.4                                     unsigned long rip,
     2.5                                     unsigned long exit_reason)
     2.6  {
     2.7 +    if ( likely(!tb_init_done) )
     2.8 +        return;
     2.9 +
    2.10  #ifdef __x86_64__
    2.11      if(hvm_long_mode_enabled(v))
    2.12      {
    2.13 @@ -50,7 +53,7 @@ static inline void hvmtrace_vmexit(struc
    2.14          d.vid = v->vcpu_id;
    2.15          d.exit_reason = exit_reason;
    2.16          d.rip = rip;
    2.17 -        trace_var(TRC_HVM_VMEXIT64, 1/*cycles*/, sizeof(d), (unsigned char *)&d);
    2.18 +        __trace_var(TRC_HVM_VMEXIT64, 1/*cycles*/, sizeof(d), (unsigned char *)&d);
    2.19      } else {
    2.20  #endif
    2.21          struct {
    2.22 @@ -63,7 +66,7 @@ static inline void hvmtrace_vmexit(struc
    2.23          d.vid = v->vcpu_id;
    2.24          d.exit_reason = exit_reason;
    2.25          d.eip = rip;
    2.26 -        trace_var(TRC_HVM_VMEXIT, 1/*cycles*/, sizeof(d), (unsigned char *)&d);
    2.27 +        __trace_var(TRC_HVM_VMEXIT, 1/*cycles*/, sizeof(d), (unsigned char *)&d);
    2.28  #ifdef __x86_64__
    2.29      }
    2.30  #endif
    2.31 @@ -75,9 +78,13 @@ static inline void hvmtrace_vmentry(stru
    2.32      struct {
    2.33          unsigned did:16, vid:16;
    2.34      } d;
    2.35 +
    2.36 +    if ( likely(!tb_init_done) )
    2.37 +        return;
    2.38 +
    2.39      d.did = v->domain->domain_id;
    2.40      d.vid = v->vcpu_id;
    2.41 -    trace_var(TRC_HVM_VMENTRY, 1/*cycles*/, sizeof(d), (unsigned char *)&d);
    2.42 +    __trace_var(TRC_HVM_VMENTRY, 1/*cycles*/, sizeof(d), (unsigned char *)&d);
    2.43  }
    2.44  
    2.45  static inline void hvmtrace_msr_read(struct vcpu *v, u32 ecx, u64 msr_content)
    2.46 @@ -87,11 +94,15 @@ static inline void hvmtrace_msr_read(str
    2.47          u32 ecx;
    2.48          u64 msr_content;
    2.49      } d;
    2.50 +
    2.51 +    if ( likely(!tb_init_done) )
    2.52 +        return;
    2.53 +
    2.54      d.did = v->domain->domain_id;
    2.55      d.vid = v->vcpu_id;
    2.56      d.ecx = ecx;
    2.57      d.msr_content = msr_content;
    2.58 -    trace_var(TRC_HVM_MSR_READ, 0/*!cycles*/, sizeof(d), (unsigned char *)&d);
    2.59 +    __trace_var(TRC_HVM_MSR_READ, 0/*!cycles*/, sizeof(d), (unsigned char *)&d);
    2.60  }
    2.61  
    2.62  static inline void hvmtrace_msr_write(struct vcpu *v, u32 ecx, u64 msr_content)
    2.63 @@ -101,16 +112,23 @@ static inline void hvmtrace_msr_write(st
    2.64          u32 ecx;
    2.65          u64 msr_content;
    2.66      } d;
    2.67 +
    2.68 +    if ( likely(!tb_init_done) )
    2.69 +        return;
    2.70 +
    2.71      d.did = v->domain->domain_id;
    2.72      d.vid = v->vcpu_id;
    2.73      d.ecx = ecx;
    2.74      d.msr_content = msr_content;
    2.75 -    trace_var(TRC_HVM_MSR_WRITE, 0/*!cycles*/,sizeof(d), (unsigned char *)&d);
    2.76 +    __trace_var(TRC_HVM_MSR_WRITE, 0/*!cycles*/,sizeof(d), (unsigned char *)&d);
    2.77  }
    2.78  
    2.79  static inline void hvmtrace_pf_xen(struct vcpu *v, unsigned long va,
    2.80                                     u32 error_code)
    2.81  {
    2.82 +    if ( likely(!tb_init_done) )
    2.83 +        return;
    2.84 +
    2.85  #ifdef __x86_64__
    2.86      if(hvm_long_mode_enabled(v))
    2.87      {
    2.88 @@ -123,8 +141,8 @@ static inline void hvmtrace_pf_xen(struc
    2.89          d.vid = v->vcpu_id;
    2.90          d.error_code = error_code;
    2.91          d.va = va;
    2.92 -        trace_var(TRC_HVM_PF_XEN64, 0/*!cycles*/,sizeof(d),
    2.93 -                  (unsigned char *)&d);
    2.94 +        __trace_var(TRC_HVM_PF_XEN64, 0/*!cycles*/,sizeof(d),
    2.95 +                    (unsigned char *)&d);
    2.96      } else {
    2.97  #endif
    2.98          struct {
    2.99 @@ -136,7 +154,8 @@ static inline void hvmtrace_pf_xen(struc
   2.100          d.vid = v->vcpu_id;
   2.101          d.error_code = error_code;
   2.102          d.va = va;
   2.103 -        trace_var(TRC_HVM_PF_XEN, 0/*!cycles*/,sizeof(d), (unsigned char *)&d);
   2.104 +        __trace_var(TRC_HVM_PF_XEN, 0/*!cycles*/,sizeof(d),
   2.105 +                    (unsigned char *)&d);
   2.106  #ifdef __x86_64__
   2.107      }
   2.108  #endif
   2.109 @@ -144,7 +163,7 @@ static inline void hvmtrace_pf_xen(struc
   2.110  
   2.111  #define HVMTRACE_ND(evt, vcpu, count, d1, d2, d3, d4)                   \
   2.112      do {                                                                \
   2.113 -        if (DO_TRC_HVM_ ## evt)                                         \
   2.114 +        if ( unlikely(tb_init_done) && DO_TRC_HVM_ ## evt )             \
   2.115          {                                                               \
   2.116              struct {                                                    \
   2.117                  unsigned did:16, vid:16;                                \
   2.118 @@ -156,8 +175,8 @@ static inline void hvmtrace_pf_xen(struc
   2.119              _d.d[1]=(d2);                                               \
   2.120              _d.d[2]=(d3);                                               \
   2.121              _d.d[3]=(d4);                                               \
   2.122 -            trace_var(TRC_HVM_ ## evt, 0/*!cycles*/,                    \
   2.123 -                      sizeof(u32)*count+1, (unsigned char *)&_d);       \
   2.124 +            __trace_var(TRC_HVM_ ## evt, 0/*!cycles*/,                  \
   2.125 +                        sizeof(u32)*count+1, (unsigned char *)&_d);     \
   2.126          }                                                               \
   2.127      } while(0)
   2.128  
     3.1 --- a/xen/include/asm-x86/trace.h	Mon Feb 11 09:46:53 2008 +0000
     3.2 +++ b/xen/include/asm-x86/trace.h	Mon Feb 11 09:47:19 2008 +0000
     3.3 @@ -8,7 +8,7 @@ void __trace_pv_trap(int trapnr, unsigne
     3.4  static inline void trace_pv_trap(int trapnr, unsigned long eip,
     3.5                                   int use_error_code, unsigned error_code)
     3.6  {
     3.7 -    if ( tb_init_done )
     3.8 +    if ( unlikely(tb_init_done) )
     3.9          __trace_pv_trap(trapnr, eip, use_error_code, error_code);
    3.10  }
    3.11  
    3.12 @@ -16,14 +16,14 @@ void __trace_pv_page_fault(unsigned long
    3.13  static inline void trace_pv_page_fault(unsigned long addr,
    3.14                                         unsigned error_code)
    3.15  {
    3.16 -    if ( tb_init_done )
    3.17 +    if ( unlikely(tb_init_done) )
    3.18          __trace_pv_page_fault(addr, error_code);
    3.19  }
    3.20  
    3.21  void __trace_trap_one_addr(unsigned event, unsigned long va);
    3.22  static inline void trace_trap_one_addr(unsigned event, unsigned long va)
    3.23  {
    3.24 -    if ( tb_init_done )
    3.25 +    if ( unlikely(tb_init_done) )
    3.26          __trace_trap_one_addr(event, va);
    3.27  }
    3.28  
    3.29 @@ -32,14 +32,14 @@ void __trace_trap_two_addr(unsigned even
    3.30  static inline void trace_trap_two_addr(unsigned event, unsigned long va1,
    3.31                                         unsigned long va2)
    3.32  {
    3.33 -    if ( tb_init_done )
    3.34 +    if ( unlikely(tb_init_done) )
    3.35          __trace_trap_two_addr(event, va1, va2);
    3.36  }
    3.37  
    3.38  void __trace_ptwr_emulation(unsigned long addr, l1_pgentry_t npte);
    3.39  static inline void trace_ptwr_emulation(unsigned long addr, l1_pgentry_t npte)
    3.40  {
    3.41 -    if ( tb_init_done )
    3.42 +    if ( unlikely(tb_init_done) )
    3.43          __trace_ptwr_emulation(addr, npte);
    3.44  }
    3.45  
     4.1 --- a/xen/include/xen/trace.h	Mon Feb 11 09:46:53 2008 +0000
     4.2 +++ b/xen/include/xen/trace.h	Mon Feb 11 09:47:19 2008 +0000
     4.3 @@ -39,7 +39,7 @@ void __trace_var(u32 event, int cycles, 
     4.4  static inline void trace_var(u32 event, int cycles, int extra,
     4.5                                 unsigned char *extra_data)
     4.6  {
     4.7 -    if( unlikely(tb_init_done) )
     4.8 +    if ( unlikely(tb_init_done) )
     4.9          __trace_var(event, cycles, extra, extra_data);
    4.10  }
    4.11  
    4.12 @@ -49,49 +49,64 @@ static inline void trace_var(u32 event, 
    4.13          trace_var(_e, 1, 0, NULL);              \
    4.14      } while ( 0 )
    4.15    
    4.16 -#define TRACE_1D(_e,_d)                                         \
    4.17 +#define TRACE_1D(_e,d1)                                         \
    4.18      do {                                                        \
    4.19 -        u32 _d1;                                                \
    4.20 -        _d1 = _d;                                               \
    4.21 -        trace_var(_e, 1, sizeof(_d1), (unsigned char *)&_d1);	\
    4.22 +        if ( unlikely(tb_init_done) )                           \
    4.23 +        {                                                       \
    4.24 +            u32 _d[1];                                          \
    4.25 +            _d[0] = d1;                                         \
    4.26 +            __trace_var(_e, 1, sizeof(*_d), (unsigned char *)_d); \
    4.27 +        }                                                       \
    4.28      } while ( 0 )
    4.29   
    4.30  #define TRACE_2D(_e,d1,d2)                                      \
    4.31 -    do {							\
    4.32 -        u32 _d[2];						\
    4.33 -        _d[0]=d1;						\
    4.34 -        _d[1]=d2;						\
    4.35 -        trace_var(_e, 1, sizeof(*_d)*2, (unsigned char *)_d);	\
    4.36 +    do {                                                        \
    4.37 +        if ( unlikely(tb_init_done) )                           \
    4.38 +        {                                                       \
    4.39 +            u32 _d[2];                                          \
    4.40 +            _d[0] = d1;                                         \
    4.41 +            _d[1] = d2;                                         \
    4.42 +            __trace_var(_e, 1, sizeof(*_d)*2, (unsigned char *)_d); \
    4.43 +        }                                                       \
    4.44      } while ( 0 )
    4.45   
    4.46  #define TRACE_3D(_e,d1,d2,d3)                                   \
    4.47      do {                                                        \
    4.48 -        u32 _d[3];                                              \
    4.49 -        _d[0]=d1;                                               \
    4.50 -        _d[1]=d2;                                               \
    4.51 -        _d[2]=d3;                                               \
    4.52 -        trace_var(_e, 1, sizeof(*_d)*3, (unsigned char *)_d);	\
    4.53 +        if ( unlikely(tb_init_done) )                           \
    4.54 +        {                                                       \
    4.55 +            u32 _d[3];                                          \
    4.56 +            _d[0] = d1;                                         \
    4.57 +            _d[1] = d2;                                         \
    4.58 +            _d[2] = d3;                                         \
    4.59 +            __trace_var(_e, 1, sizeof(*_d)*3, (unsigned char *)_d); \
    4.60 +        }                                                       \
    4.61      } while ( 0 )
    4.62   
    4.63  #define TRACE_4D(_e,d1,d2,d3,d4)                                \
    4.64      do {                                                        \
    4.65 -        u32 _d[4];                                              \
    4.66 -        _d[0]=d1;                                               \
    4.67 -        _d[1]=d2;                                               \
    4.68 -        _d[2]=d3;                                               \
    4.69 -        _d[3]=d4;                                               \
    4.70 -        trace_var(_e, 1, sizeof(*_d)*4, (unsigned char *)_d);	\
    4.71 +        if ( unlikely(tb_init_done) )                           \
    4.72 +        {                                                       \
    4.73 +            u32 _d[4];                                          \
    4.74 +            _d[0] = d1;                                         \
    4.75 +            _d[1] = d2;                                         \
    4.76 +            _d[2] = d3;                                         \
    4.77 +            _d[3] = d4;                                         \
    4.78 +            __trace_var(_e, 1, sizeof(*_d)*4, (unsigned char *)_d); \
    4.79 +        }                                                       \
    4.80      } while ( 0 )
    4.81   
    4.82  #define TRACE_5D(_e,d1,d2,d3,d4,d5)                             \
    4.83 -    do {							\
    4.84 -        u32 _d[5];						\
    4.85 -        _d[0]=d1;						\
    4.86 -        _d[1]=d2;						\
    4.87 -        _d[2]=d3;						\
    4.88 -        _d[3]=d4;						\
    4.89 -        _d[4]=d5;						\
    4.90 -        trace_var(_e, 1, sizeof(*_d)*5, (unsigned char *)_d);	\
    4.91 +    do {                                                        \
    4.92 +        if ( unlikely(tb_init_done) )                           \
    4.93 +        {                                                       \
    4.94 +            u32 _d[5];                                          \
    4.95 +            _d[0] = d1;                                         \
    4.96 +            _d[1] = d2;                                         \
    4.97 +            _d[2] = d3;                                         \
    4.98 +            _d[3] = d4;                                         \
    4.99 +            _d[4] = d5;                                         \
   4.100 +            __trace_var(_e, 1, sizeof(*_d)*5, (unsigned char *)_d); \
   4.101 +        }                                                       \
   4.102      } while ( 0 )
   4.103  
   4.104  #endif /* __XEN_TRACE_H__ */