ia64/xen-unstable

changeset 7579:f33f18fbf2cb

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>
author kaf24@firebug.cl.cam.ac.uk
date Sun Oct 30 22:31:45 2005 +0100 (2005-10-30)
parents 43676a509982
children a663683fe8cb
files tools/libxc/Makefile tools/libxc/xc_tbuf.c tools/libxc/xenctrl.h tools/xentrace/Makefile tools/xentrace/formats tools/xentrace/setsize.c tools/xentrace/tbctl.c xen/Rules.mk xen/common/trace.c xen/include/public/dom0_ops.h
line diff
     1.1 --- a/tools/libxc/Makefile	Sun Oct 30 19:23:36 2005 +0100
     1.2 +++ b/tools/libxc/Makefile	Sun Oct 30 22:31:45 2005 +0100
     1.3 @@ -23,6 +23,7 @@ SRCS       += xc_misc.c
     1.4  SRCS       += xc_physdev.c
     1.5  SRCS       += xc_private.c
     1.6  SRCS       += xc_sedf.c
     1.7 +SRCS       += xc_tbuf.c
     1.8  BUILD_SRCS += xc_linux_build.c
     1.9  BUILD_SRCS += xc_load_bin.c
    1.10  BUILD_SRCS += xc_load_elf.c
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/tools/libxc/xc_tbuf.c	Sun Oct 30 22:31:45 2005 +0100
     2.3 @@ -0,0 +1,51 @@
     2.4 +/******************************************************************************
     2.5 + * xc_tbuf.c
     2.6 + * 
     2.7 + * API for manipulating and accessing trace buffer parameters
     2.8 + * 
     2.9 + * Copyright (c) 2005, Rob Gardner
    2.10 + */
    2.11 +
    2.12 +#include "xc_private.h"
    2.13 +
    2.14 +int xc_tbuf_enable(int xc_handle, int enable)
    2.15 +{
    2.16 +  dom0_op_t op;
    2.17 +
    2.18 +  op.cmd = DOM0_TBUFCONTROL;
    2.19 +  op.interface_version = DOM0_INTERFACE_VERSION;
    2.20 +  if (enable)
    2.21 +    op.u.tbufcontrol.op  = DOM0_TBUF_ENABLE;
    2.22 +  else
    2.23 +    op.u.tbufcontrol.op  = DOM0_TBUF_DISABLE;
    2.24 +  
    2.25 +  return xc_dom0_op(xc_handle, &op);
    2.26 +}
    2.27 +
    2.28 +int xc_tbuf_set_size(int xc_handle, uint32_t size)
    2.29 +{
    2.30 +  dom0_op_t op;
    2.31 +
    2.32 +  op.cmd = DOM0_TBUFCONTROL;
    2.33 +  op.interface_version = DOM0_INTERFACE_VERSION;
    2.34 +  op.u.tbufcontrol.op  = DOM0_TBUF_SET_SIZE;
    2.35 +  op.u.tbufcontrol.size = size;
    2.36 +  
    2.37 +  return xc_dom0_op(xc_handle, &op);
    2.38 +}
    2.39 +  
    2.40 +int xc_tbuf_get_size(int xc_handle, uint32_t *size)
    2.41 +{
    2.42 +  int rc;
    2.43 +  dom0_op_t op;
    2.44 +
    2.45 +  op.cmd = DOM0_TBUFCONTROL;
    2.46 +  op.interface_version = DOM0_INTERFACE_VERSION;
    2.47 +  op.u.tbufcontrol.op  = DOM0_TBUF_GET_INFO;
    2.48 +
    2.49 +  rc = xc_dom0_op(xc_handle, &op);
    2.50 +  if (rc == 0)
    2.51 +    *size = op.u.tbufcontrol.size;
    2.52 +  return rc;
    2.53 +}
    2.54 +
     3.1 --- a/tools/libxc/xenctrl.h	Sun Oct 30 19:23:36 2005 +0100
     3.2 +++ b/tools/libxc/xenctrl.h	Sun Oct 30 22:31:45 2005 +0100
     3.3 @@ -149,7 +149,7 @@ int xc_domain_dumpcore(int xc_handle,
     3.4                         const char *corename);
     3.5  
     3.6  /*
     3.7 - * This function sets the maximum number vcpus that a domian may create.
     3.8 + * This function sets the maximum number of vcpus that a domain may create.
     3.9   *
    3.10   * @parm xc_handle a handle to an open hypervisor interface.
    3.11   * @parm domid the domain id in which vcpus are to be created.
    3.12 @@ -490,6 +490,47 @@ int xc_gnttab_dump_table(int        xc_h
    3.13  /* Get current total pages allocated to a domain. */
    3.14  long xc_get_tot_pages(int xc_handle, uint32_t domid);
    3.15  
    3.16 +
    3.17 +/*
    3.18 + * Trace Buffer Operations
    3.19 + */
    3.20 +
    3.21 +/**
    3.22 + * This function enables or disables tracing. Trace buffer memory must
    3.23 + * be already allocated by setting the size to a non-zero value, otherwise
    3.24 + * tracing cannot be enabled.
    3.25 + *
    3.26 + * @parm xc_handle a handle to an open hypervisor interface
    3.27 + * @parm enable the desired action, 1 for enable, 0 for disable
    3.28 + * @return 0 on success, -1 on failure.
    3.29 + */
    3.30 +int xc_tbuf_enable(int xc_handle, int enable);
    3.31 +
    3.32 +/**
    3.33 + * This function sets the size of the trace buffers. Setting it to zero
    3.34 + * deallocates the memory used for trace buffers, and setting it to a
    3.35 + * non-zero value specifies the number of pages per cpu to allocate.
    3.36 + * To change the size of an existing allocation, you must first deallocate
    3.37 + * it then reallocate it. No change in size is allowed when tracing is
    3.38 + * enabled; A disable call must be made first.
    3.39 + *
    3.40 + * @parm xc_handle a handle to an open hypervisor interface
    3.41 + * @parm size the size in pages per cpu for the trace buffers
    3.42 + * @return 0 on success, -1 on failure.
    3.43 + */
    3.44 +int xc_tbuf_set_size(int xc_handle, uint32_t size);
    3.45 +
    3.46 +/**
    3.47 + * This function retrieves the current size of the trace buffers. 
    3.48 + * Note that the size returned is in terms of bytes, not pages.
    3.49 +
    3.50 + * @parm xc_handle a handle to an open hypervisor interface
    3.51 + * @parm size will contain the size in bytes for the trace buffers
    3.52 + * @return 0 on success, -1 on failure.
    3.53 + */
    3.54 +int xc_tbuf_get_size(int xc_handle, uint32_t *size);
    3.55 +
    3.56 +
    3.57  /* Execute a privileged dom0 operation. */
    3.58  int xc_dom0_op(int xc_handle, dom0_op_t *op);
    3.59  
     4.1 --- a/tools/xentrace/Makefile	Sun Oct 30 19:23:36 2005 +0100
     4.2 +++ b/tools/xentrace/Makefile	Sun Oct 30 22:31:45 2005 +0100
     4.3 @@ -14,7 +14,7 @@ CFLAGS  += -I $(XEN_LIBXC)
     4.4  HDRS     = $(wildcard *.h)
     4.5  OBJS     = $(patsubst %.c,%.o,$(wildcard *.c))
     4.6  
     4.7 -BIN      = xentrace
     4.8 +BIN      = xentrace tbctl setsize
     4.9  SCRIPTS  = xentrace_format
    4.10  MAN1     = $(wildcard *.1)
    4.11  MAN8     = $(wildcard *.8)
     5.1 --- a/tools/xentrace/formats	Sun Oct 30 19:23:36 2005 +0100
     5.2 +++ b/tools/xentrace/formats	Sun Oct 30 22:31:45 2005 +0100
     5.3 @@ -1,16 +1,16 @@
     5.4 -0x00020001	CPU%(cpu)d	%(tsc)d		sched_add_domain	[ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
     5.5 -0x00020002	CPU%(cpu)d	%(tsc)d		sched_rem_domain	[ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
     5.6 -0x00020003	CPU%(cpu)d	%(tsc)d		domain_sleep		[ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
     5.7 -0x00020004	CPU%(cpu)d	%(tsc)d		domain_wake		[ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
     5.8 -0x00020005	CPU%(cpu)d	%(tsc)d		do_yield		[ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
     5.9 -0x00020006	CPU%(cpu)d	%(tsc)d		do_block		[ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
    5.10 -0x00020007	CPU%(cpu)d	%(tsc)d		domain_shutdown		[ domid = 0x%(1)08x, edomid = 0x%(2)08x, reason = 0x%(3)08x ]
    5.11 -0x00020008	CPU%(cpu)d	%(tsc)d		sched_ctl
    5.12 -0x00020009	CPU%(cpu)d	%(tsc)d		sched_adjdom		[ domid = 0x%(1)08x ]
    5.13 -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 ]
    5.14 -0x0002000B	CPU%(cpu)d	%(tsc)d		s_timer_fn
    5.15 -0x0002000c	CPU%(cpu)d	%(tsc)d		t_timer_fn
    5.16 -0x0002000d	CPU%(cpu)d	%(tsc)d		dom_timer_fn
    5.17 +0x0002f001	CPU%(cpu)d	%(tsc)d		sched_add_domain	[ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
    5.18 +0x0002f002	CPU%(cpu)d	%(tsc)d		sched_rem_domain	[ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
    5.19 +0x0002f003	CPU%(cpu)d	%(tsc)d		domain_sleep		[ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
    5.20 +0x0002f004	CPU%(cpu)d	%(tsc)d		domain_wake		[ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
    5.21 +0x0002f005	CPU%(cpu)d	%(tsc)d		do_yield		[ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
    5.22 +0x0002f006	CPU%(cpu)d	%(tsc)d		do_block		[ domid = 0x%(1)08x, edomid = 0x%(2)08x ]
    5.23 +0x0002f007	CPU%(cpu)d	%(tsc)d		domain_shutdown		[ domid = 0x%(1)08x, edomid = 0x%(2)08x, reason = 0x%(3)08x ]
    5.24 +0x0002f008	CPU%(cpu)d	%(tsc)d		sched_ctl
    5.25 +0x0002f009	CPU%(cpu)d	%(tsc)d		sched_adjdom		[ domid = 0x%(1)08x ]
    5.26 +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 ]
    5.27 +0x0002f00B	CPU%(cpu)d	%(tsc)d		s_timer_fn
    5.28 +0x0002f00c	CPU%(cpu)d	%(tsc)d		t_timer_fn
    5.29 +0x0002f00d	CPU%(cpu)d	%(tsc)d		dom_timer_fn
    5.30  
    5.31  0x00080001	CPU%(cpu)d      %(tsc)d		VMX_VMEXIT		[ domid = 0x%(1)08x, eip = 0x%(2)08x, reason = 0x%(3)08x ]
    5.32  0x00080002	CPU%(cpu)d      %(tsc)d		VMX_VECTOR		[ domid = 0x%(1)08x, eip = 0x%(2)08x, vector = 0x%(3)08x ]
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/tools/xentrace/setsize.c	Sun Oct 30 22:31:45 2005 +0100
     6.3 @@ -0,0 +1,36 @@
     6.4 +#include <stdlib.h>
     6.5 +#include <stdio.h>
     6.6 +#include <errno.h>
     6.7 +#include <xenctrl.h>
     6.8 +
     6.9 +int main(int argc, char * argv[])
    6.10 +{
    6.11 +  unsigned int size;
    6.12 +  int xc_handle = xc_interface_open();
    6.13 +  
    6.14 +  if (xc_tbuf_get_size(xc_handle, &size) != 0) {
    6.15 +    perror("Failure to get tbuf info from Xen. Guess size is 0.");
    6.16 +    printf("This may mean that tracing is not compiled into xen.\n");
    6.17 +    exit(1);
    6.18 +  }
    6.19 +  else
    6.20 +    printf("Current tbuf size: 0x%x\n", size);
    6.21 +  
    6.22 +  if (argc < 2)
    6.23 +    exit(0);
    6.24 +
    6.25 +  size = atoi(argv[1]);
    6.26 +
    6.27 +  if (xc_tbuf_set_size(xc_handle, size) != 0) {
    6.28 +    perror("set_size Hypercall failure");
    6.29 +    exit(1);
    6.30 +  }
    6.31 +  
    6.32 +  if (xc_tbuf_get_size(xc_handle, &size) != 0)
    6.33 +    perror("Failure to get tbuf info from Xen. Guess size is 0.");
    6.34 +  else
    6.35 +    printf("New tbuf size: 0x%x\n", size);
    6.36 +  
    6.37 +  xc_interface_close(xc_handle);
    6.38 +  return 0;
    6.39 +}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/tools/xentrace/tbctl.c	Sun Oct 30 22:31:45 2005 +0100
     7.3 @@ -0,0 +1,26 @@
     7.4 +#include <stdlib.h>
     7.5 +#include <stdio.h>
     7.6 +#include <errno.h>
     7.7 +#include <xenctrl.h>
     7.8 +
     7.9 +int main(int argc, char * argv[])
    7.10 +{
    7.11 +    int enable;
    7.12 +    int xc_handle = xc_interface_open();
    7.13 +    
    7.14 +    if (argc < 2) {
    7.15 +      printf("usage: %s [0|1]\n", argv[0]);
    7.16 +      exit(1);
    7.17 +    }
    7.18 +    enable = atoi(argv[1]);
    7.19 +
    7.20 +    if (xc_tbuf_enable(xc_handle, enable) != 0) {
    7.21 +        perror("Enable/Disable Hypercall failure");
    7.22 +        exit(1);
    7.23 +    }
    7.24 +    else
    7.25 +      printf("Tracing now %s\n", (enable ? "enabled" : "disabled"));
    7.26 +
    7.27 +    xc_interface_close(xc_handle);
    7.28 +    return 0;
    7.29 +}
     8.1 --- a/xen/Rules.mk	Sun Oct 30 19:23:36 2005 +0100
     8.2 +++ b/xen/Rules.mk	Sun Oct 30 22:31:45 2005 +0100
     8.3 @@ -6,7 +6,7 @@ verbose     ?= n
     8.4  debug       ?= n
     8.5  perfc       ?= n
     8.6  perfc_arrays?= n
     8.7 -trace       ?= n
     8.8 +trace       ?= y
     8.9  domu_debug  ?= n
    8.10  crash_debug ?= n
    8.11  
     9.1 --- a/xen/common/trace.c	Sun Oct 30 19:23:36 2005 +0100
     9.2 +++ b/xen/common/trace.c	Sun Oct 30 22:31:45 2005 +0100
     9.3 @@ -5,8 +5,9 @@
     9.4   *
     9.5   * Copyright (C) 2004 by Intel Research Cambridge
     9.6   *
     9.7 - * Author: Mark Williamson, mark.a.williamson@intel.com
     9.8 - * Date:   January 2004
     9.9 + * Authors: Mark Williamson, mark.a.williamson@intel.com
    9.10 + *          Rob Gardner, rob.gardner@hp.com
    9.11 + * Date:    October 2005
    9.12   *
    9.13   * Copyright (C) 2005 Bin Ren
    9.14   *
    9.15 @@ -31,13 +32,14 @@
    9.16  #include <public/dom0_ops.h>
    9.17  
    9.18  /* opt_tbuf_size: trace buffer size (in pages) */
    9.19 -static unsigned int opt_tbuf_size = 10;
    9.20 +static unsigned int opt_tbuf_size = 0;
    9.21  integer_param("tbuf_size", opt_tbuf_size);
    9.22  
    9.23  /* Pointers to the meta-data objects for all system trace buffers */
    9.24  struct t_buf *t_bufs[NR_CPUS];
    9.25  
    9.26 -/* a flag recording whether initialisation has been done */
    9.27 +/* a flag recording whether initialization has been done */
    9.28 +/* or more properly, if the tbuf subsystem is enabled right now */
    9.29  int tb_init_done = 0;
    9.30  
    9.31  /* which CPUs tracing is enabled on */
    9.32 @@ -45,19 +47,17 @@ unsigned long tb_cpu_mask = (~0UL);
    9.33  
    9.34  /* which tracing events are enabled */
    9.35  u32 tb_event_mask = TRC_ALL;
    9.36 +
    9.37  /**
    9.38 - * init_trace_bufs - performs initialisation of the per-cpu trace buffers.
    9.39 + * init_trace_bufs - performs initialization of the per-cpu trace buffers.
    9.40   *
    9.41 - * This function is called at start of day in order to initialise the per-cpu
    9.42 + * This function is called at start of day in order to initialize the per-cpu
    9.43   * trace buffers.  The trace buffers are then available for debugging use, via
    9.44   * the %TRACE_xD macros exported in <xen/trace.h>.
    9.45   */
    9.46  void init_trace_bufs(void)
    9.47  {
    9.48 -    int           i, order;
    9.49 -    unsigned long nr_pages;
    9.50 -    char         *rawbuf;
    9.51 -    struct t_buf *buf;
    9.52 +    extern int alloc_trace_bufs(void);
    9.53      
    9.54      if ( opt_tbuf_size == 0 )
    9.55      {
    9.56 @@ -65,13 +65,40 @@ void init_trace_bufs(void)
    9.57          return;
    9.58      }
    9.59  
    9.60 +    if (alloc_trace_bufs() == 0) {
    9.61 +        printk("Xen trace buffers: initialised\n");
    9.62 +        wmb(); /* above must be visible before tb_init_done flag set */
    9.63 +        tb_init_done = 1;
    9.64 +    }
    9.65 +}
    9.66 +
    9.67 +/**
    9.68 + * alloc_trace_bufs - performs initialization of the per-cpu trace buffers.
    9.69 + *
    9.70 + * This function is called at start of day in order to initialize the per-cpu
    9.71 + * trace buffers.  The trace buffers are then available for debugging use, via
    9.72 + * the %TRACE_xD macros exported in <xen/trace.h>.
    9.73 + *
    9.74 + * This function may also be called later when enabling trace buffers 
    9.75 + * via the SET_SIZE hypercall.
    9.76 + */
    9.77 +int alloc_trace_bufs(void)
    9.78 +{
    9.79 +    int           i, order;
    9.80 +    unsigned long nr_pages;
    9.81 +    char         *rawbuf;
    9.82 +    struct t_buf *buf;
    9.83 +
    9.84 +    if ( opt_tbuf_size == 0 )
    9.85 +        return -EINVAL;
    9.86 +
    9.87      nr_pages = num_online_cpus() * opt_tbuf_size;
    9.88      order    = get_order_from_pages(nr_pages);
    9.89      
    9.90      if ( (rawbuf = alloc_xenheap_pages(order)) == NULL )
    9.91      {
    9.92          printk("Xen trace buffers: memory allocation failed\n");
    9.93 -        return;
    9.94 +        return -EINVAL;
    9.95      }
    9.96  
    9.97      /* Share pages so that xentrace can map them. */
    9.98 @@ -88,13 +115,50 @@ void init_trace_bufs(void)
    9.99          buf->rec      = (struct t_rec *)(buf + 1);
   9.100          buf->rec_addr = __pa(buf->rec);
   9.101      }
   9.102 +    return 0;
   9.103 +}
   9.104  
   9.105 -    printk("Xen trace buffers: initialised\n");
   9.106 +
   9.107 +/**
   9.108 + * tb_set_size - handle the logic involved with dynamically
   9.109 + * allocating and deallocating tbufs
   9.110 + *
   9.111 + * This function is called when the SET_SIZE hypercall is done.
   9.112 + */
   9.113 +int tb_set_size(int size)
   9.114 +{
   9.115 +    // There are three cases to handle:
   9.116 +    //  1. Changing from 0 to non-zero ==> simple allocate
   9.117 +    //  2. Changing from non-zero to 0 ==> simple deallocate
   9.118 +    //  3. Changing size ==> deallocate and reallocate? Or disallow?
   9.119 +    //     User can just do a change to 0, then a change to the new size.
   9.120 +    //
   9.121 +    // Tracing must be disabled (tb_init_done==0) before calling this
   9.122      
   9.123 -    wmb(); /* above must be visible before tb_init_done flag set */
   9.124 +    if (opt_tbuf_size == 0 && size > 0) {
   9.125 +        // What if size is too big? alloc_xenheap will complain.
   9.126 +        opt_tbuf_size = size;
   9.127 +        if (alloc_trace_bufs() != 0)
   9.128 +            return -EINVAL;
   9.129 +        wmb();
   9.130 +        printk("Xen trace buffers: initialized\n");
   9.131 +        return 0;
   9.132 +    }
   9.133 +    else if (opt_tbuf_size > 0 && size == 0) {
   9.134 +        int order = get_order_from_pages(num_online_cpus() * opt_tbuf_size);
   9.135 +        // is there a way to undo SHARE_PFN_WITH_DOMAIN?
   9.136 +        free_xenheap_pages(t_bufs[0], order);
   9.137 +        opt_tbuf_size = 0;
   9.138 +        printk("Xen trace buffers: uninitialized\n");
   9.139 +        return 0;
   9.140 +    }
   9.141 +    else {
   9.142 +        printk("tb_set_size from %d to %d not implemented\n", opt_tbuf_size, size);
   9.143 +        printk("change size from %d to 0, and then to %d\n",  opt_tbuf_size, size);
   9.144 +        return -EINVAL;
   9.145 +    }
   9.146 +}
   9.147  
   9.148 -    tb_init_done = 1;
   9.149 -}
   9.150  
   9.151  /**
   9.152   * tb_control - DOM0 operations on trace buffers.
   9.153 @@ -105,8 +169,10 @@ int tb_control(dom0_tbufcontrol_t *tbc)
   9.154      static spinlock_t lock = SPIN_LOCK_UNLOCKED;
   9.155      int rc = 0;
   9.156  
   9.157 -    if ( !tb_init_done )
   9.158 -        return -EINVAL;
   9.159 +    // Commenting this out since we have to allow some of these operations
   9.160 +    // in order to enable dynamic control of the trace buffers.
   9.161 +    //    if ( !tb_init_done )
   9.162 +    //        return -EINVAL;
   9.163  
   9.164      spin_lock(&lock);
   9.165  
   9.166 @@ -124,6 +190,30 @@ int tb_control(dom0_tbufcontrol_t *tbc)
   9.167      case DOM0_TBUF_SET_EVT_MASK:
   9.168          tb_event_mask = tbc->evt_mask;
   9.169          break;
   9.170 +    case DOM0_TBUF_SET_SIZE:
   9.171 +        // Change trace buffer allocation.
   9.172 +        // Trace buffers must be disabled to do this.
   9.173 +        if (tb_init_done) {
   9.174 +            printk("attempt to change size with tbufs enabled\n");
   9.175 +            rc = -EINVAL;
   9.176 +        }
   9.177 +        else
   9.178 +            rc = tb_set_size(tbc->size);
   9.179 +        break;
   9.180 +    case DOM0_TBUF_ENABLE:
   9.181 +        // Enable trace buffers. Size must be non-zero, ie, buffers
   9.182 +        // must already be allocated. 
   9.183 +        if (opt_tbuf_size == 0) 
   9.184 +            rc = -EINVAL;
   9.185 +        else
   9.186 +            tb_init_done = 1;
   9.187 +        break;
   9.188 +    case DOM0_TBUF_DISABLE:
   9.189 +        // Disable trace buffers. Just stops new records from being written,
   9.190 +        // does not deallocate any memory.
   9.191 +        tb_init_done = 0;
   9.192 +        printk("Xen trace buffers: disabled\n");
   9.193 +        break;
   9.194      default:
   9.195          rc = -EINVAL;
   9.196      }
    10.1 --- a/xen/include/public/dom0_ops.h	Sun Oct 30 19:23:36 2005 +0100
    10.2 +++ b/xen/include/public/dom0_ops.h	Sun Oct 30 22:31:45 2005 +0100
    10.3 @@ -193,6 +193,9 @@ typedef struct {
    10.4  #define DOM0_TBUF_GET_INFO     0
    10.5  #define DOM0_TBUF_SET_CPU_MASK 1
    10.6  #define DOM0_TBUF_SET_EVT_MASK 2
    10.7 +#define DOM0_TBUF_SET_SIZE     3
    10.8 +#define DOM0_TBUF_ENABLE       4
    10.9 +#define DOM0_TBUF_DISABLE      5
   10.10      uint8_t op;
   10.11      /* IN/OUT variables */
   10.12      unsigned long cpu_mask;