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

[Xen-changelog] [xen-unstable] [XEN] Make tracing structures and buffers explicitly PER_CPU.



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID aa25666d464332f52302f8f0d0768da9729befa6
# Parent  5fc926b5860901cac5dd4b3084e8a23e0c366066
[XEN] Make tracing structures and buffers explicitly PER_CPU.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 xen/arch/x86/hvm/vmx/vmx.c |   14 +++++++-------
 xen/common/trace.c         |   17 +++++++++--------
 2 files changed, 16 insertions(+), 15 deletions(-)

diff -r 5fc926b58609 -r aa25666d4643 xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c        Tue Aug 08 14:48:43 2006 +0100
+++ b/xen/arch/x86/hvm/vmx/vmx.c        Tue Aug 08 14:56:22 2006 +0100
@@ -49,8 +49,8 @@
 #include <asm/hvm/vpic.h>
 #include <asm/hvm/vlapic.h>
 
-static unsigned long trace_values[NR_CPUS][5];
-#define TRACE_VMEXIT(index,value) trace_values[smp_processor_id()][index]=value
+static DEFINE_PER_CPU(unsigned long, trace_values[5]);
+#define TRACE_VMEXIT(index,value) this_cpu(trace_values)[index]=value
 
 static void vmx_ctxt_switch_from(struct vcpu *v);
 static void vmx_ctxt_switch_to(struct vcpu *v);
@@ -2400,11 +2400,11 @@ asmlinkage void vmx_trace_vmentry (void)
 asmlinkage void vmx_trace_vmentry (void)
 {
     TRACE_5D(TRC_VMX_VMENTRY,
-             trace_values[smp_processor_id()][0],
-             trace_values[smp_processor_id()][1],
-             trace_values[smp_processor_id()][2],
-             trace_values[smp_processor_id()][3],
-             trace_values[smp_processor_id()][4]);
+             this_cpu(trace_values)[0],
+             this_cpu(trace_values)[1],
+             this_cpu(trace_values)[2],
+             this_cpu(trace_values)[3],
+             this_cpu(trace_values)[4]);
     TRACE_VMEXIT(0,9);
     TRACE_VMEXIT(1,9);
     TRACE_VMEXIT(2,9);
diff -r 5fc926b58609 -r aa25666d4643 xen/common/trace.c
--- a/xen/common/trace.c        Tue Aug 08 14:48:43 2006 +0100
+++ b/xen/common/trace.c        Tue Aug 08 14:56:22 2006 +0100
@@ -39,8 +39,8 @@ integer_param("tbuf_size", opt_tbuf_size
 integer_param("tbuf_size", opt_tbuf_size);
 
 /* Pointers to the meta-data objects for all system trace buffers */
-static struct t_buf *t_bufs[NR_CPUS];
-static struct t_rec *t_recs[NR_CPUS];
+static DEFINE_PER_CPU(struct t_buf *, t_bufs);
+static DEFINE_PER_CPU(struct t_rec *, t_recs);
 static int nr_recs;
 
 /* High water mark for trace buffers; */
@@ -105,9 +105,10 @@ static int alloc_trace_bufs(void)
 
     for_each_online_cpu ( i )
     {
-        buf = t_bufs[i] = (struct t_buf *)&rawbuf[i*opt_tbuf_size*PAGE_SIZE];
+        buf = per_cpu(t_bufs, i) = (struct t_buf *)
+            &rawbuf[i*opt_tbuf_size*PAGE_SIZE];
         buf->cons = buf->prod = 0;
-        t_recs[i] = (struct t_rec *)(buf + 1);
+        per_cpu(t_recs, i) = (struct t_rec *)(buf + 1);
     }
 
     t_buf_highwater = nr_recs >> 1; /* 50% high water */
@@ -186,7 +187,7 @@ int tb_control(dom0_tbufcontrol_t *tbc)
     case DOM0_TBUF_GET_INFO:
         tbc->cpu_mask   = tb_cpu_mask;
         tbc->evt_mask   = tb_event_mask;
-        tbc->buffer_mfn = opt_tbuf_size ? virt_to_mfn(t_bufs[0]) : 0UL;
+        tbc->buffer_mfn = opt_tbuf_size ? virt_to_mfn(per_cpu(t_bufs, 0)) : 0;
         tbc->size       = opt_tbuf_size * PAGE_SIZE;
         break;
     case DOM0_TBUF_SET_CPU_MASK:
@@ -258,7 +259,7 @@ void trace(u32 event, unsigned long d1, 
     /* Read tb_init_done /before/ t_bufs. */
     rmb();
 
-    buf = t_bufs[smp_processor_id()];
+    buf = this_cpu(t_bufs);
 
     local_irq_save(flags);
 
@@ -272,7 +273,7 @@ void trace(u32 event, unsigned long d1, 
 
     if ( unlikely(this_cpu(lost_records) != 0) )
     {
-        rec = &t_recs[smp_processor_id()][buf->prod % nr_recs];
+        rec = &this_cpu(t_recs)[buf->prod % nr_recs];
         memset(rec, 0, sizeof(*rec));
         rec->cycles  = (u64)get_cycles();
         rec->event   = TRC_LOST_RECORDS;
@@ -283,7 +284,7 @@ void trace(u32 event, unsigned long d1, 
         buf->prod++;
     }
 
-    rec = &t_recs[smp_processor_id()][buf->prod % nr_recs];
+    rec = &this_cpu(t_recs)[buf->prod % nr_recs];
     rec->cycles  = (u64)get_cycles();
     rec->event   = event;
     rec->data[0] = d1;

_______________________________________________
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®.