From: Arun Sharma <arun.sharma@intel.com>
To: Ian Pratt <Ian.Pratt@cl.cam.ac.uk>,
Keir Fraser <Keir.Fraser@cl.cam.ac.uk>
Cc: xen-devel@lists.xensource.com
Subject: [PATCH][VT][13/15] Implement event filtering command line options for xentrace.
Date: Thu, 11 Aug 2005 12:25:19 -0700 [thread overview]
Message-ID: <20050811192519.GA15358@intel.com> (raw)
Implement event filtering command line options for xentrace.
Signed-off-by: Edwin Zhai <edwin.zhai@intel.com>
Signed-off-by: Arun Sharma <arun.sharma@intel.com>
diff -r 455dff354413 -r bbb21d688c7f tools/xentrace/xentrace.c
--- a/tools/xentrace/xentrace.c Tue Aug 9 19:12:44 2005
+++ b/tools/xentrace/xentrace.c Tue Aug 9 19:12:48 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 455dff354413 -r bbb21d688c7f xen/include/public/trace.h
--- a/xen/include/public/trace.h Tue Aug 9 19:12:44 2005
+++ b/xen/include/public/trace.h Tue Aug 9 19:12:48 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 455dff354413 -r bbb21d688c7f xen/include/xen/trace.h
--- a/xen/include/xen/trace.h Tue Aug 9 19:12:44 2005
+++ b/xen/include/xen/trace.h Tue Aug 9 19:12:48 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;
reply other threads:[~2005-08-11 19:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050811192519.GA15358@intel.com \
--to=arun.sharma@intel.com \
--cc=Ian.Pratt@cl.cam.ac.uk \
--cc=Keir.Fraser@cl.cam.ac.uk \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.