Skip to contentSkip to conversation

xentrace: Clear lost records when disabling tracing

PATCH New George Dunlap 1 participant 1 message Feb 1, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xentrace: Clear lost records when disabling tracing

This patch clears the "lost records" flag on each cpu when tracing is disabled.

Without this patch, the next time tracing starts, cpus with lost records will generate lost record traces, even though buffers are empty and no tracing has recently happened.

xen/common/trace.c +15 -0
diff -r 2c5b7da4b914 xen/common/trace.c
@@ -230,11 +230,26 @@
             tb_init_done = 1;
         break;
     case XEN_SYSCTL_TBUFOP_disable:
+    {
         /*
          * Disable trace buffers. Just stops new records from being written,
          * does not deallocate any memory.
          */
+        int i;
+
         tb_init_done = 0;
+        wmb();
+        /* Clear any lost-record info so we don't get phantom lost records next time we
+         * start tracing.  Grab the lock to make sure we're not racing anyone.  After this
+         * hypercall returns, no more records should be placed into the buffers. */
+        for_each_online_cpu(i)
+        {
+            int flags;
+            spin_lock_irqsave(&per_cpu(t_lock, i), flags);
+            per_cpu(lost_records, i)=0;
+            spin_unlock_irqrestore(&per_cpu(t_lock, i), flags);
+        }
+    }
         break;
     default:
         rc = -EINVAL;

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