direct-io.hg

changeset 10984:aa25666d4643

[XEN] Make tracing structures and buffers explicitly PER_CPU.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Aug 08 14:56:22 2006 +0100 (2006-08-08)
parents 5fc926b58609
children 6b821e310597
files xen/arch/x86/hvm/vmx/vmx.c xen/common/trace.c
line diff
     1.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Tue Aug 08 14:48:43 2006 +0100
     1.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Tue Aug 08 14:56:22 2006 +0100
     1.3 @@ -49,8 +49,8 @@
     1.4  #include <asm/hvm/vpic.h>
     1.5  #include <asm/hvm/vlapic.h>
     1.6  
     1.7 -static unsigned long trace_values[NR_CPUS][5];
     1.8 -#define TRACE_VMEXIT(index,value) trace_values[smp_processor_id()][index]=value
     1.9 +static DEFINE_PER_CPU(unsigned long, trace_values[5]);
    1.10 +#define TRACE_VMEXIT(index,value) this_cpu(trace_values)[index]=value
    1.11  
    1.12  static void vmx_ctxt_switch_from(struct vcpu *v);
    1.13  static void vmx_ctxt_switch_to(struct vcpu *v);
    1.14 @@ -2400,11 +2400,11 @@ asmlinkage void vmx_load_cr2(void)
    1.15  asmlinkage void vmx_trace_vmentry (void)
    1.16  {
    1.17      TRACE_5D(TRC_VMX_VMENTRY,
    1.18 -             trace_values[smp_processor_id()][0],
    1.19 -             trace_values[smp_processor_id()][1],
    1.20 -             trace_values[smp_processor_id()][2],
    1.21 -             trace_values[smp_processor_id()][3],
    1.22 -             trace_values[smp_processor_id()][4]);
    1.23 +             this_cpu(trace_values)[0],
    1.24 +             this_cpu(trace_values)[1],
    1.25 +             this_cpu(trace_values)[2],
    1.26 +             this_cpu(trace_values)[3],
    1.27 +             this_cpu(trace_values)[4]);
    1.28      TRACE_VMEXIT(0,9);
    1.29      TRACE_VMEXIT(1,9);
    1.30      TRACE_VMEXIT(2,9);
     2.1 --- a/xen/common/trace.c	Tue Aug 08 14:48:43 2006 +0100
     2.2 +++ b/xen/common/trace.c	Tue Aug 08 14:56:22 2006 +0100
     2.3 @@ -39,8 +39,8 @@ static unsigned int opt_tbuf_size = 0;
     2.4  integer_param("tbuf_size", opt_tbuf_size);
     2.5  
     2.6  /* Pointers to the meta-data objects for all system trace buffers */
     2.7 -static struct t_buf *t_bufs[NR_CPUS];
     2.8 -static struct t_rec *t_recs[NR_CPUS];
     2.9 +static DEFINE_PER_CPU(struct t_buf *, t_bufs);
    2.10 +static DEFINE_PER_CPU(struct t_rec *, t_recs);
    2.11  static int nr_recs;
    2.12  
    2.13  /* High water mark for trace buffers; */
    2.14 @@ -105,9 +105,10 @@ static int alloc_trace_bufs(void)
    2.15  
    2.16      for_each_online_cpu ( i )
    2.17      {
    2.18 -        buf = t_bufs[i] = (struct t_buf *)&rawbuf[i*opt_tbuf_size*PAGE_SIZE];
    2.19 +        buf = per_cpu(t_bufs, i) = (struct t_buf *)
    2.20 +            &rawbuf[i*opt_tbuf_size*PAGE_SIZE];
    2.21          buf->cons = buf->prod = 0;
    2.22 -        t_recs[i] = (struct t_rec *)(buf + 1);
    2.23 +        per_cpu(t_recs, i) = (struct t_rec *)(buf + 1);
    2.24      }
    2.25  
    2.26      t_buf_highwater = nr_recs >> 1; /* 50% high water */
    2.27 @@ -186,7 +187,7 @@ int tb_control(dom0_tbufcontrol_t *tbc)
    2.28      case DOM0_TBUF_GET_INFO:
    2.29          tbc->cpu_mask   = tb_cpu_mask;
    2.30          tbc->evt_mask   = tb_event_mask;
    2.31 -        tbc->buffer_mfn = opt_tbuf_size ? virt_to_mfn(t_bufs[0]) : 0UL;
    2.32 +        tbc->buffer_mfn = opt_tbuf_size ? virt_to_mfn(per_cpu(t_bufs, 0)) : 0;
    2.33          tbc->size       = opt_tbuf_size * PAGE_SIZE;
    2.34          break;
    2.35      case DOM0_TBUF_SET_CPU_MASK:
    2.36 @@ -258,7 +259,7 @@ void trace(u32 event, unsigned long d1, 
    2.37      /* Read tb_init_done /before/ t_bufs. */
    2.38      rmb();
    2.39  
    2.40 -    buf = t_bufs[smp_processor_id()];
    2.41 +    buf = this_cpu(t_bufs);
    2.42  
    2.43      local_irq_save(flags);
    2.44  
    2.45 @@ -272,7 +273,7 @@ void trace(u32 event, unsigned long d1, 
    2.46  
    2.47      if ( unlikely(this_cpu(lost_records) != 0) )
    2.48      {
    2.49 -        rec = &t_recs[smp_processor_id()][buf->prod % nr_recs];
    2.50 +        rec = &this_cpu(t_recs)[buf->prod % nr_recs];
    2.51          memset(rec, 0, sizeof(*rec));
    2.52          rec->cycles  = (u64)get_cycles();
    2.53          rec->event   = TRC_LOST_RECORDS;
    2.54 @@ -283,7 +284,7 @@ void trace(u32 event, unsigned long d1, 
    2.55          buf->prod++;
    2.56      }
    2.57  
    2.58 -    rec = &t_recs[smp_processor_id()][buf->prod % nr_recs];
    2.59 +    rec = &this_cpu(t_recs)[buf->prod % nr_recs];
    2.60      rec->cycles  = (u64)get_cycles();
    2.61      rec->event   = event;
    2.62      rec->data[0] = d1;