aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2005-10-30 22:31:45 +0100
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2005-10-30 22:31:45 +0100
commitf6556b0d174a6a9d3d855f4ec92c7bf246e1b34c (patch)
tree46e0d9c15164b2c808fc6a0322b8543c0092892f /tools
parent07237aa4f333c3feeb9e11e172213d2d440af4dd (diff)
downloadxen-f6556b0d174a6a9d3d855f4ec92c7bf246e1b34c.tar.gz
xen-f6556b0d174a6a9d3d855f4ec92c7bf246e1b34c.tar.bz2
xen-f6556b0d174a6a9d3d855f4ec92c7bf246e1b34c.zip
This is a set of changes which allow the tracebuffer functionality to
be enabled and disabled dynamically while the system is running. The existing DOM0_TBUFCONTROL hypercall is used, and three new operations have been added: enable, disable, and set_size. This is to address concerns that use of the trace buffers impacts system performance. The initial value of opt_tbuf_size is set to zero, so that trace buffers remain disabled by default. They can be enabled as they used to be, by adding tbuf_size= to the xen command line at boot time. They can also be turned on and off any time when the system is running. The size of the trace buffer allocation can also be changed dynamically while the system is running. The trace buffers may be completely deallocated by setting the size to zero. No change in buffer size can be done while tracing is enabled; Other Changes made: - Update the constants in tools/xentrace/formats to match those in public/trace.h - libxc functions for enable/disable, get/set size Still left to do: - remove all ifdef's for trace buffers and the 'trace' build option - xm command to do enable/disable trace buffers and get/set size Signed-off-by: Rob Gardner <rob.gardner@hp.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/libxc/Makefile1
-rw-r--r--tools/libxc/xc_tbuf.c51
-rw-r--r--tools/libxc/xenctrl.h43
-rw-r--r--tools/xentrace/Makefile2
-rw-r--r--tools/xentrace/formats26
-rw-r--r--tools/xentrace/setsize.c36
-rw-r--r--tools/xentrace/tbctl.c26
7 files changed, 170 insertions, 15 deletions
diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile
index 9c4b705641..b1d91d157d 100644
--- a/tools/libxc/Makefile
+++ b/tools/libxc/Makefile
@@ -23,6 +23,7 @@ SRCS += xc_misc.c
SRCS += xc_physdev.c
SRCS += xc_private.c
SRCS += xc_sedf.c
+SRCS += xc_tbuf.c
BUILD_SRCS += xc_linux_build.c
BUILD_SRCS += xc_load_bin.c
BUILD_SRCS += xc_load_elf.c
diff --git a/tools/libxc/xc_tbuf.c b/tools/libxc/xc_tbuf.c
new file mode 100644
index 0000000000..b47cde2867
--- /dev/null
+++ b/tools/libxc/xc_tbuf.c
@@ -0,0 +1,51 @@
+/******************************************************************************
+ * xc_tbuf.c
+ *
+ * API for manipulating and accessing trace buffer parameters
+ *
+ * Copyright (c) 2005, Rob Gardner
+ */
+
+#include "xc_private.h"
+
+int xc_tbuf_enable(int xc_handle, int enable)
+{
+ dom0_op_t op;
+
+ op.cmd = DOM0_TBUFCONTROL;
+ op.interface_version = DOM0_INTERFACE_VERSION;
+ if (enable)
+ op.u.tbufcontrol.op = DOM0_TBUF_ENABLE;
+ else
+ op.u.tbufcontrol.op = DOM0_TBUF_DISABLE;
+
+ return xc_dom0_op(xc_handle, &op);
+}
+
+int xc_tbuf_set_size(int xc_handle, uint32_t size)
+{
+ dom0_op_t op;
+
+ op.cmd = DOM0_TBUFCONTROL;
+ op.interface_version = DOM0_INTERFACE_VERSION;
+ op.u.tbufcontrol.op = DOM0_TBUF_SET_SIZE;
+ op.u.tbufcontrol.size = size;
+
+ return xc_dom0_op(xc_handle, &op);
+}
+
+int xc_tbuf_get_size(int xc_handle, uint32_t *size)
+{
+ int rc;
+ dom0_op_t op;
+
+ op.cmd = DOM0_TBUFCONTROL;
+ op.interface_version = DOM0_INTERFACE_VERSION;
+ op.u.tbufcontrol.op = DOM0_TBUF_GET_INFO;
+
+ rc = xc_dom0_op(xc_handle, &op);
+ if (rc == 0)
+ *size = op.u.tbufcontrol.size;
+ return rc;
+}
+
diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h
index ffbe4fdfff..42ce3097be 100644
--- a/tools/libxc/xenctrl.h
+++ b/tools/libxc/xenctrl.h
@@ -149,7 +149,7 @@ int xc_domain_dumpcore(int xc_handle,
const char *corename);
/*
- * This function sets the maximum number vcpus that a domian may create.
+ * This function sets the maximum number of vcpus that a domain may create.
*
* @parm xc_handle a handle to an open hypervisor interface.
* @parm domid the domain id in which vcpus are to be created.
@@ -490,6 +490,47 @@ int xc_gnttab_dump_table(int xc_handle,
/* Get current total pages allocated to a domain. */
long xc_get_tot_pages(int xc_handle, uint32_t domid);
+
+/*
+ * Trace Buffer Operations
+ */
+
+/**
+ * This function enables or disables tracing. Trace buffer memory must
+ * be already allocated by setting the size to a non-zero value, otherwise
+ * tracing cannot be enabled.
+ *
+ * @parm xc_handle a handle to an open hypervisor interface
+ * @parm enable the desired action, 1 for enable, 0 for disable
+ * @return 0 on success, -1 on failure.
+ */
+int xc_tbuf_enable(int xc_handle, int enable);
+
+/**
+ * This function sets the size of the trace buffers. Setting it to zero
+ * deallocates the memory used for trace buffers, and setting it to a
+ * non-zero value specifies the number of pages per cpu to allocate.
+ * To change the size of an existing allocation, you must first deallocate
+ * it then reallocate it. No change in size is allowed when tracing is
+ * enabled; A disable call must be made first.
+ *
+ * @parm xc_handle a handle to an open hypervisor interface
+ * @parm size the size in pages per cpu for the trace buffers
+ * @return 0 on success, -1 on failure.
+ */
+int xc_tbuf_set_size(int xc_handle, uint32_t size);
+
+/**
+ * This function retrieves the current size of the trace buffers.
+ * Note that the size returned is in terms of bytes, not pages.
+
+ * @parm xc_handle a handle to an open hypervisor interface
+ * @parm size will contain the size in bytes for the trace buffers
+ * @return 0 on success, -1 on failure.
+ */
+int xc_tbuf_get_size(int xc_handle, uint32_t *size);
+
+
/* Execute a privileged dom0 operation. */
int xc_dom0_op(int xc_handle, dom0_op_t *op);
diff --git a/tools/xentrace/Makefile b/tools/xentrace/Makefile
index b6ae508d85..5c3a77be83 100644
--- a/tools/xentrace/Makefile
+++ b/tools/xentrace/Makefile
@@ -14,7 +14,7 @@ CFLAGS += -I $(XEN_LIBXC)
HDRS = $(wildcard *.h)
OBJS = $(patsubst %.c,%.o,$(wildcard *.c))
-BIN = xentrace
+BIN = xentrace tbctl setsize
SCRIPTS = xentrace_format
MAN1 = $(wildcard *.1)
MAN8 = $(wildcard *.8)
diff --git a/tools/xentrace/formats b/tools/xentrace/formats
index 78954b9543..818eef1c60 100644
--- a/tools/xentrace/formats
+++ b/tools/xentrace/formats
@@ -1,16 +1,16 @@
-0x00020001 CPU%(cpu)d %(tsc)d sched_add_domain [ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
-0x00020002 CPU%(cpu)d %(tsc)d sched_rem_domain [ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
-0x00020003 CPU%(cpu)d %(tsc)d domain_sleep [ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
-0x00020004 CPU%(cpu)d %(tsc)d domain_wake [ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
-0x00020005 CPU%(cpu)d %(tsc)d do_yield [ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
-0x00020006 CPU%(cpu)d %(tsc)d do_block [ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
-0x00020007 CPU%(cpu)d %(tsc)d domain_shutdown [ domid = 0x%(1)08x, edomid = 0x%(2)08x, reason = 0x%(3)08x ]
-0x00020008 CPU%(cpu)d %(tsc)d sched_ctl
-0x00020009 CPU%(cpu)d %(tsc)d sched_adjdom [ domid = 0x%(1)08x ]
-0x0002000a CPU%(cpu)d %(tsc)d __enter_scheduler [ prev<domid:edomid> = 0x%(1)08x : 0x%(2)08x, next<domid:edomid> = 0x%(3)08x : 0x%(4)08x ]
-0x0002000B CPU%(cpu)d %(tsc)d s_timer_fn
-0x0002000c CPU%(cpu)d %(tsc)d t_timer_fn
-0x0002000d CPU%(cpu)d %(tsc)d dom_timer_fn
+0x0002f001 CPU%(cpu)d %(tsc)d sched_add_domain [ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
+0x0002f002 CPU%(cpu)d %(tsc)d sched_rem_domain [ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
+0x0002f003 CPU%(cpu)d %(tsc)d domain_sleep [ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
+0x0002f004 CPU%(cpu)d %(tsc)d domain_wake [ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
+0x0002f005 CPU%(cpu)d %(tsc)d do_yield [ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
+0x0002f006 CPU%(cpu)d %(tsc)d do_block [ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
+0x0002f007 CPU%(cpu)d %(tsc)d domain_shutdown [ domid = 0x%(1)08x, edomid = 0x%(2)08x, reason = 0x%(3)08x ]
+0x0002f008 CPU%(cpu)d %(tsc)d sched_ctl
+0x0002f009 CPU%(cpu)d %(tsc)d sched_adjdom [ domid = 0x%(1)08x ]
+0x0002f00a CPU%(cpu)d %(tsc)d __enter_scheduler [ prev<domid:edomid> = 0x%(1)08x : 0x%(2)08x, next<domid:edomid> = 0x%(3)08x : 0x%(4)08x ]
+0x0002f00B CPU%(cpu)d %(tsc)d s_timer_fn
+0x0002f00c CPU%(cpu)d %(tsc)d t_timer_fn
+0x0002f00d CPU%(cpu)d %(tsc)d dom_timer_fn
0x00080001 CPU%(cpu)d %(tsc)d VMX_VMEXIT [ domid = 0x%(1)08x, eip = 0x%(2)08x, reason = 0x%(3)08x ]
0x00080002 CPU%(cpu)d %(tsc)d VMX_VECTOR [ domid = 0x%(1)08x, eip = 0x%(2)08x, vector = 0x%(3)08x ]
diff --git a/tools/xentrace/setsize.c b/tools/xentrace/setsize.c
new file mode 100644
index 0000000000..0b5311ea57
--- /dev/null
+++ b/tools/xentrace/setsize.c
@@ -0,0 +1,36 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <xenctrl.h>
+
+int main(int argc, char * argv[])
+{
+ unsigned int size;
+ int xc_handle = xc_interface_open();
+
+ if (xc_tbuf_get_size(xc_handle, &size) != 0) {
+ perror("Failure to get tbuf info from Xen. Guess size is 0.");
+ printf("This may mean that tracing is not compiled into xen.\n");
+ exit(1);
+ }
+ else
+ printf("Current tbuf size: 0x%x\n", size);
+
+ if (argc < 2)
+ exit(0);
+
+ size = atoi(argv[1]);
+
+ if (xc_tbuf_set_size(xc_handle, size) != 0) {
+ perror("set_size Hypercall failure");
+ exit(1);
+ }
+
+ if (xc_tbuf_get_size(xc_handle, &size) != 0)
+ perror("Failure to get tbuf info from Xen. Guess size is 0.");
+ else
+ printf("New tbuf size: 0x%x\n", size);
+
+ xc_interface_close(xc_handle);
+ return 0;
+}
diff --git a/tools/xentrace/tbctl.c b/tools/xentrace/tbctl.c
new file mode 100644
index 0000000000..fd9dc3a9c8
--- /dev/null
+++ b/tools/xentrace/tbctl.c
@@ -0,0 +1,26 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <xenctrl.h>
+
+int main(int argc, char * argv[])
+{
+ int enable;
+ int xc_handle = xc_interface_open();
+
+ if (argc < 2) {
+ printf("usage: %s [0|1]\n", argv[0]);
+ exit(1);
+ }
+ enable = atoi(argv[1]);
+
+ if (xc_tbuf_enable(xc_handle, enable) != 0) {
+ perror("Enable/Disable Hypercall failure");
+ exit(1);
+ }
+ else
+ printf("Tracing now %s\n", (enable ? "enabled" : "disabled"));
+
+ xc_interface_close(xc_handle);
+ return 0;
+}