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

[Xen-changelog] Implement event filtering command line options for xentrace.



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID ca873c2f5ca27e3985e37dea9966608d85675d90
# Parent  3f1f7cf07369ffdcbc2c884f3db58c926549bffc
Implement event filtering command line options for xentrace.

Signed-off-by: Edwin Zhai <edwin.zhai@xxxxxxxxx>
Signed-off-by: Arun Sharma <arun.sharma@xxxxxxxxx>

diff -r 3f1f7cf07369 -r ca873c2f5ca2 tools/xentrace/xentrace.c
--- a/tools/xentrace/xentrace.c Thu Aug 11 21:06:15 2005
+++ b/tools/xentrace/xentrace.c Thu Aug 11 21:06:35 2005
@@ -45,6 +45,8 @@
     char *outfile;
     struct timespec poll_sleep;
     unsigned long new_data_thresh;
+    u32 evt_mask;
+    u32 cpu_mask;
 } settings_t;
 
 settings_t opts;
@@ -160,6 +162,41 @@
     return tbufs_mapped;
 }
 
+/**
+ * set_mask - set the cpu/event mask in HV
+ * @mask:           the new mask 
+ * @type:           the new mask type,0-event mask, 1-cpu mask
+ *
+ */
+void set_mask(u32 mask, int type)
+{
+    int ret;
+    dom0_op_t op;                        /* dom0 op we'll build             */
+    int xc_handle = xc_interface_open(); /* for accessing control interface */
+
+    op.cmd = DOM0_TBUFCONTROL;
+    op.interface_version = DOM0_INTERFACE_VERSION;
+    if (type == 1) { /* cpu mask */
+        op.u.tbufcontrol.op  = DOM0_TBUF_SET_CPU_MASK;
+        op.u.tbufcontrol.cpu_mask = mask;
+        fprintf(stderr, "change cpumask to 0x%x\n", mask);
+    }else if (type == 0) { /* event mask */
+        op.u.tbufcontrol.op  = DOM0_TBUF_SET_EVT_MASK;
+        op.u.tbufcontrol.evt_mask = mask;
+        fprintf(stderr, "change evtmask to 0x%x\n", mask);
+    }
+
+    ret = do_dom0_op(xc_handle, &op);
+
+    xc_interface_close(xc_handle);
+
+    if ( ret != 0 )
+    {
+        PERROR("Failure to get trace buffer pointer from Xen and set the new 
mask");
+        exit(EXIT_FAILURE);
+    }
+
+}
 
 /**
  * init_bufs_ptrs - initialises an array of pointers to the trace buffers
@@ -341,6 +378,31 @@
  * Various declarations / definitions GNU argp needs to do its work
  *****************************************************************************/
 
+int parse_evtmask(char *arg, struct argp_state *state)
+{
+    settings_t *setup = (settings_t *)state->input;
+    char *inval;
+
+    /* search filtering class */
+    if (strcmp(arg, "gen") == 0){ 
+        setup->evt_mask |= TRC_GEN;
+    } else if(strcmp(arg, "sched") == 0){ 
+        setup->evt_mask |= TRC_SCHED;
+    } else if(strcmp(arg, "dom0op") == 0){ 
+        setup->evt_mask |= TRC_DOM0OP;
+    } else if(strcmp(arg, "vmx") == 0){ 
+        setup->evt_mask |= TRC_VMX;
+    } else if(strcmp(arg, "all") == 0){ 
+        setup->evt_mask |= TRC_ALL;
+    } else {
+        setup->evt_mask = strtol(arg, &inval, 0);
+        if ( inval == arg )
+            argp_usage(state);
+    }
+
+    return 0;
+
+}
 
 /* command parser for GNU argp - see GNU docs for more info */
 error_t cmd_parser(int key, char *arg, struct argp_state *state)
@@ -366,6 +428,21 @@
             argp_usage(state);
     }
     break;
+
+    case 'c': /* set new cpu mask for filtering*/
+    {
+        char *inval;
+        setup->cpu_mask = strtol(arg, &inval, 0);
+        if ( inval == arg )
+            argp_usage(state);
+    }
+    break;
+    
+    case 'e': /* set new event mask for filtering*/
+    {
+        parse_evtmask(arg, state);
+    }
+    break;
     
     case ARGP_KEY_ARG:
     {
@@ -397,6 +474,14 @@
       .doc = 
       "Set sleep time, p, in milliseconds between polling the trace buffer "
       "for new data (default " xstr(POLL_SLEEP_MILLIS) ")." },
+
+    { .name = "cpu-mask", .key='c', .arg="c",
+      .doc = 
+      "set cpu-mask " },
+
+    { .name = "evt-mask", .key='e', .arg="e",
+      .doc = 
+      "set evt-mask " },
 
     {0}
 };
@@ -430,8 +515,18 @@
     opts.outfile = 0;
     opts.poll_sleep = millis_to_timespec(POLL_SLEEP_MILLIS);
     opts.new_data_thresh = NEW_DATA_THRESH;
+    opts.evt_mask = 0;
+    opts.cpu_mask = 0;
 
     argp_parse(&parser_def, argc, argv, 0, 0, &opts);
+
+    if (opts.evt_mask != 0) { 
+        set_mask(opts.evt_mask, 0);
+    }
+
+    if (opts.cpu_mask != 0) {
+        set_mask(opts.evt_mask, 1);
+    }
 
     if ( opts.outfile )
         outfd = open(opts.outfile, O_WRONLY | O_CREAT);
diff -r 3f1f7cf07369 -r ca873c2f5ca2 xen/include/public/trace.h
--- a/xen/include/public/trace.h        Thu Aug 11 21:06:15 2005
+++ b/xen/include/public/trace.h        Thu Aug 11 21:06:35 2005
@@ -9,11 +9,21 @@
 #define __XEN_PUBLIC_TRACE_H__
 
 /* Trace classes */
-#define TRC_GEN     0x00010000    /* General trace            */
-#define TRC_SCHED   0x00020000    /* Xen Scheduler trace      */
-#define TRC_DOM0OP  0x00040000    /* Xen DOM0 operation trace */
-#define TRC_VMX     0x00080000    /* Xen VMX trace            */
-#define TRC_ALL     0xffff0000
+#define TRC_CLS_SHIFT 16
+#define TRC_GEN     0x0001f000    /* General trace            */
+#define TRC_SCHED   0x0002f000    /* Xen Scheduler trace      */
+#define TRC_DOM0OP  0x0004f000    /* Xen DOM0 operation trace */
+#define TRC_VMX     0x0008f000    /* Xen VMX trace            */
+#define TRC_ALL     0xfffff000
+
+/* Trace subclasses */
+#define TRC_SUBCLS_SHIFT 12
+/* trace subclasses for VMX */
+#define TRC_VMXEXIT  0x00081000   /* VMX exit trace            */
+#define TRC_VMXTIMER 0x00082000   /* VMX timer trace           */
+#define TRC_VMXINT   0x00084000   /* VMX interrupt trace       */
+#define TRC_VMXIO    0x00088000   /* VMX io emulation trace  */
+
 
 /* Trace events per class */
 
@@ -31,9 +41,13 @@
 #define TRC_SCHED_T_TIMER_FN    (TRC_SCHED + 12)
 #define TRC_SCHED_DOM_TIMER_FN  (TRC_SCHED + 13)
 
-#define TRC_VMX_VMEXIT          (TRC_VMX + 1)
-#define TRC_VMX_VECTOR          (TRC_VMX + 2)
-#define TRC_VMX_INT             (TRC_VMX + 3)
+/* trace events per subclass */
+#define TRC_VMX_VMEXIT          (TRC_VMXEXIT + 1)
+#define TRC_VMX_VECTOR          (TRC_VMXEXIT + 2)
+
+#define TRC_VMX_TIMER_INTR      (TRC_VMXTIMER + 1)
+
+#define TRC_VMX_INT             (TRC_VMXINT + 1)
 
 /* This structure represents a single trace buffer record. */
 struct t_rec {
diff -r 3f1f7cf07369 -r ca873c2f5ca2 xen/include/xen/trace.h
--- a/xen/include/xen/trace.h   Thu Aug 11 21:06:15 2005
+++ b/xen/include/xen/trace.h   Thu Aug 11 21:06:35 2005
@@ -67,6 +67,15 @@
     if ( (tb_event_mask & event) == 0 )
         return 0;
 
+    /* match class */
+    if ( ((tb_event_mask >> TRC_CLS_SHIFT) & (event >> TRC_CLS_SHIFT)) == 0 )
+        return 0;
+
+    /* then match subclass */
+    if ( (((tb_event_mask >> TRC_SUBCLS_SHIFT) & 0xf )
+                & ((event >> TRC_SUBCLS_SHIFT) & 0xf )) == 0 )
+        return 0;
+
     if ( (tb_cpu_mask & (1UL << smp_processor_id())) == 0 )
         return 0;
 

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