Skip to contentSkip to conversation

xentrace: new trace event to track lost trace records

PATCH In review Rob Gardner 2 participants 2 messages Jul 6, 2006 – Aug 18, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xentrace: new trace event to track lost trace records

Simple addition to trace.c to count trace records that are generated when the trace buffers are full. When there is space available again, a new record is generated that indicates how many trace records have been thrown away. I'm working on the corresponding userland code to do something useful with this information, and will send out an additional patch 'soon.'

Rob Gardner

# HG changeset patch
# User [email protected]
# Node ID 81e7d6e0f9109bf493b7c8281ffc79d10f4dd2ab # Parent 67f658b84025efeb2a570d2937ebc8f5e35056f7

New trace event is introduced to track lost trace records.

xen/common/trace.c Thu Jul 6 23:29:26 2006 renamed from xen/common/trace.c Thu Jul 6 18:08:37 2006 +17 -1
diff -r 67f658b84025 -r 81e7d6e0f910 xen/common/trace.c
@@ -234,7 +234,8 @@
    struct t_buf *buf;
    struct t_rec *rec;
    unsigned long flags;
-
+    static long lost_records = 0;
+   
    BUG_ON(!tb_init_done);
 
    if ( (tb_event_mask & event) == 0 )
@@ -261,8 +262,24 @@
 
    if ( (buf->prod - buf->cons) >= nr_recs )
    {
+        lost_records++;
        local_irq_restore(flags);
        return;
+    }
+
+    if (lost_records) {
+        rec = &t_recs[smp_processor_id()][buf->prod % nr_recs];
+        rec->cycles  = (u64)get_cycles();
+        rec->event   = TRC_LOST_RECORDS;
+        rec->data[0] = lost_records;
+        rec->data[1] = 0;
+        rec->data[2] = 0;
+        rec->data[3] = 0;
+        rec->data[4] = 0;
+       +        wmb();
+        buf->prod++;
+        lost_records = 0;
    }
 
    rec = &t_recs[smp_processor_id()][buf->prod % nr_recs];
xen/include/public/trace.h Thu Jul 6 23:29:26 2006 renamed from xen/include/public/trace.h Thu Jul 6 18:08:37 2006 +0 -0
diff -r 67f658b84025 -r 81e7d6e0f910 xen/include/public/trace.h
@@ -26,6 +26,7 @@

#define TRC_VMXIO 0x00088000 /* VMX io emulation trace */

/* Trace events per class */
+#define TRC_LOST_RECORDS (TRC_GEN + 1)

#define TRC_SCHED_DOM_ADD       (TRC_SCHED +  1)
#define TRC_SCHED_DOM_REM       (TRC_SCHED +  2)

# HG changeset patch
# User [email protected]
# Node ID 81e7d6e0f9109bf493b7c8281ffc79d10f4dd2ab # Parent 67f658b84025efeb2a570d2937ebc8f5e35056f7

New trace event is introduced to track lost trace records.

xen/common/trace.c +18 -1
diff -r 67f658b84025 -r 81e7d6e0f910 xen/common/trace.c
@@ -234,7 +234,8 @@
     struct t_buf *buf;
     struct t_rec *rec;
     unsigned long flags;
-
+    static long lost_records = 0;
+    
     BUG_ON(!tb_init_done);
 
     if ( (tb_event_mask & event) == 0 )
@@ -261,8 +262,24 @@
 
     if ( (buf->prod - buf->cons) >= nr_recs )
     {
+        lost_records++;
         local_irq_restore(flags);
         return;
+    }
+
+    if (lost_records) {
+        rec = &t_recs[smp_processor_id()][buf->prod % nr_recs];
+        rec->cycles  = (u64)get_cycles();
+        rec->event   = TRC_LOST_RECORDS;
+        rec->data[0] = lost_records;
+        rec->data[1] = 0;
+        rec->data[2] = 0;
+        rec->data[3] = 0;
+        rec->data[4] = 0;
+        
+        wmb();
+        buf->prod++;
+        lost_records = 0;
     }
 
     rec = &t_recs[smp_processor_id()][buf->prod % nr_recs];
xen/include/public/trace.h +1 -0
diff -r 67f658b84025 -r 81e7d6e0f910 xen/include/public/trace.h
@@ -26,6 +26,7 @@
 #define TRC_VMXIO    0x00088000   /* VMX io emulation trace  */
 
 /* Trace events per class */
+#define TRC_LOST_RECORDS        (TRC_GEN + 1)
 
 #define TRC_SCHED_DOM_ADD       (TRC_SCHED +  1)
 #define TRC_SCHED_DOM_REM       (TRC_SCHED +  2)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

I like this idea. Thanks for all the work you're doing on the trace buffer.

xen/common/trace.c Thu Jul 6 23:29:26 2006 line 238

Quoted 10 lines

diff -r 67f658b84025 -r 81e7d6e0f910 xen/common/trace.c

xen/common/trace.c Thu Jul 6 23:29:26 2006 renamed from xen/common/trace.c Thu Jul 6 18:08:37 2006 +2 -1
@@ -234,7 +234,8 @@
     struct t_buf *buf;
     struct t_rec *rec;
     unsigned long flags;
-
+    static long lost_records = 0;
+

Shouldn't this be a per-CPU counter? Otherwise there are going to be issues with multiple CPUs accessing it, and with not knowing which CPU lost the data.

Although I guess we're very unlikely to ever overflow this, perhaps it's also worth considering making it a saturating counter so that userland knows the count may not be accurate? Just a random thought...

xen/common/trace.c Thu Jul 6 23:29:26 2006 line 240

Quoted 2 lines
xen/common/trace.c Thu Jul 6 23:29:26 2006 renamed from xen/common/trace.c Thu Jul 6 18:08:37 2006 +2 -0
+    if (lost_records) {
+        rec = &t_recs[smp_processor_id()][buf->prod % nr_recs];

You could use &this_cpu[t_recs] here - I think the rest of the code is now converted to use this format.

Cheers,
Mark

Quoted 25 lines
xen/common/trace.c Thu Jul 6 23:29:26 2006 renamed from xen/common/trace.c Thu Jul 6 18:08:37 2006 +11 -0
+        rec->cycles  = (u64)get_cycles();
+        rec->event   = TRC_LOST_RECORDS;
+        rec->data[0] = lost_records;
+        rec->data[1] = 0;
+        rec->data[2] = 0;
+        rec->data[3] = 0;
+        rec->data[4] = 0;
+
+        wmb();
+        buf->prod++;
+        lost_records = 0;
     }
 
     rec = &t_recs[smp_processor_id()][buf->prod % nr_recs];

diff -r 67f658b84025 -r 81e7d6e0f910 xen/include/public/trace.h

xen/include/public/trace.h Thu Jul 6 23:29:26 2006 renamed from xen/include/public/trace.h Thu Jul 6 18:08:37 2006 +1 -0
@@ -26,6 +26,7 @@
 #define TRC_VMXIO    0x00088000   /* VMX io emulation trace  */
 
 /* Trace events per class */
+#define TRC_LOST_RECORDS        (TRC_GEN + 1)
 
 #define TRC_SCHED_DOM_ADD       (TRC_SCHED +  1)
 #define TRC_SCHED_DOM_REM       (TRC_SCHED +  2)
Signature · 4 lines
Dave: Just a question. What use is a unicyle with no seat?  And no pedals!
Mark: To answer a question with a question: What use is a skateboard?
Dave: Skateboards have wheels.
Mark: My wheel has a wheel!