Skip to contentSkip to conversation

xentrace updates

PATCH New George Dunlap 1 participant 4 messages Apr 13, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xentrace updates

Some minor updates to xentrace.

#1 lore raw

PATCH 1/1 xentrace: Skip to low cpu when throwing away portions of the circular buffer

Skip to the next "low" cpu when throwing away portions of the circular memory buffer. This makes subsequent analysis easier.

tools/xentrace/xentrace.c +15 -0
diff -r 859a372efa66 -r 16ef34de0129 tools/xentrace/xentrace.c
@@ -149,6 +149,7 @@
 {
     struct cpu_change_record *rec;
     long need_to_consume, free, freed;
+    int last_cpu = -1;
 
     if ( membuf.pending_size > 0 )
     {
@@ -193,11 +194,25 @@
 
         if ( need_to_consume > 0 )
         {
+            last_cpu = rec->data.cpu;
             MEMBUF_CONS_INCREMENT(freed);
             need_to_consume -= freed;
         }
     } while( need_to_consume > 0 );
 
+    /* For good tsc consistency, we need to start at a low-cpu buffer.  Keep
+     * skipping until the cpu goes down or stays the same. */
+    rec = (struct cpu_change_record *)MEMBUF_POINTER(membuf.cons);
+    while ( rec->data.cpu > last_cpu )
+    {
+        last_cpu = rec->data.cpu; 
+
+        freed = sizeof(*rec) + rec->data.window_size;
+        
+        MEMBUF_CONS_INCREMENT(freed);
+        rec = (struct cpu_change_record *)MEMBUF_POINTER(membuf.cons);
+    }
+
 start_window:
     /*
      * Start writing "pending" data.  Update prod once all this data is
#2 lore raw

PATCH 1/1 xentrace: Add an option not to enable tracing

In reply to George Dunlap

Add an option that will set up the buffers and listen for updates, but will not enable tracing. This is useful if you have hacks in Xen to enable tracing at key points (for example, debugging a shadow bug).

tools/xentrace/xentrace.c +16 -2
diff -r 16ef34de0129 -r ce0812566a4d tools/xentrace/xentrace.c
@@ -58,7 +58,8 @@
     unsigned long timeout;
     unsigned long memory_buffer;
     uint8_t discard:1,
-        disable_tracing:1;
+        disable_tracing:1,
+        start_disabled:1;
 } settings_t;
 
 struct t_struct {
@@ -659,6 +660,10 @@
 
     /* setup access to trace buffers */
     get_tbufs(&tbufs_mfn, &tinfo_size);
+
+    if ( opts.start_disabled )
+        disable_tbufs();
+    
     tbufs = map_tbufs(tbufs_mfn, num, tinfo_size);
 
     size = tbufs->t_info->tbuf_size * XC_PAGE_SIZE;
@@ -791,6 +796,9 @@
 "                          it exits. Selecting this option will tell it to\n" \
 "                          keep tracing on.  Traces will be collected in\n" \
 "                          Xen's trace buffers until they become full.\n" \
+"  -X  --start-disabled    Setup trace buffers and listen, but don't enable\n" \
+"                          tracing. (Useful if tracing will be enabled by\n" \
+"                          else.)\n" \
 "  -T  --time-interval=s   Run xentrace for s seconds and quit.\n" \
 "  -?, --help              Show this message\n" \
 "  -V, --version           Print program version\n" \
@@ -914,12 +922,13 @@
         { "memory-buffer",  required_argument, 0, 'M' },
         { "discard-buffers", no_argument,      0, 'D' },
         { "dont-disable-tracing", no_argument, 0, 'x' },
+        { "start-disabled", no_argument,       0, 'X' },
         { "help",           no_argument,       0, '?' },
         { "version",        no_argument,       0, 'V' },
         { 0, 0, 0, 0 }
     };
 
-    while ( (option = getopt_long(argc, argv, "t:s:c:e:S:r:T:M:Dx?V",
+    while ( (option = getopt_long(argc, argv, "t:s:c:e:S:r:T:M:DxX?V",
                     long_options, NULL)) != -1) 
     {
         switch ( option )
@@ -957,6 +966,10 @@
             opts.disable_tracing = 0;
             break;
 
+        case 'X': /* Start disabled */
+            opts.start_disabled = 1;
+            break;
+
         case 'T':
             opts.timeout = argtol(optarg, 0);
             break;
@@ -993,6 +1006,7 @@
     opts.cpu_mask = 0;
     opts.disk_rsvd = 0;
     opts.disable_tracing = 1;
+    opts.start_disabled = 0;
     opts.timeout = 0;
 
     parse_args(argc, argv);
#3 lore raw

PATCH 1/1 xentrace: Add missing help option

In reply to George Dunlap

Describe the --reserve-disk-space option in the xentrace help.

tools/xentrace/xentrace.c +3 -0
diff -r ce0812566a4d -r a0d521070853 tools/xentrace/xentrace.c
@@ -804,6 +804,9 @@
 "  -V, --version           Print program version\n" \
 "  -M, --memory-buffer=b   Copy trace records to a circular memory buffer.\n" \
 "                          Dump to file on exit.\n" \
+"  -r  --reserve-disk-space=n Before writing trace records to disk, check to see\n" \
+"                          that after the write there will be at least n space\n" \
+"                          left on the disk.\n" \
 "\n" \
 "This tool is used to capture trace buffer data from Xen. The\n" \
 "data is output in a binary format, in the following order:\n" \