ia64/xen-unstable

changeset 9640:12621916d820

Added trace buffer virtual irq to implement non-polling trace record access.

Signed-off-by: Rob Gardner <rob.gardner@hp.com>
author kaf24@firebug.cl.cam.ac.uk
date Sat Apr 08 09:05:53 2006 +0100 (2006-04-08)
parents f84a333d8aa6
children 70837ac15cad
files xen/common/trace.c xen/include/public/xen.h xen/include/xen/softirq.h
line diff
     1.1 --- a/xen/common/trace.c	Fri Apr 07 18:41:28 2006 +0100
     1.2 +++ b/xen/common/trace.c	Sat Apr 08 09:05:53 2006 +0100
     1.3 @@ -27,6 +27,8 @@
     1.4  #include <xen/smp.h>
     1.5  #include <xen/trace.h>
     1.6  #include <xen/errno.h>
     1.7 +#include <xen/event.h>
     1.8 +#include <xen/softirq.h>
     1.9  #include <xen/init.h>
    1.10  #include <asm/atomic.h>
    1.11  #include <public/dom0_ops.h>
    1.12 @@ -40,6 +42,11 @@ static struct t_buf *t_bufs[NR_CPUS];
    1.13  static struct t_rec *t_recs[NR_CPUS];
    1.14  static int nr_recs;
    1.15  
    1.16 +/* High water mark for trace buffers; */
    1.17 +/* Send virtual interrupt when buffer level reaches this point */
    1.18 +static int t_buf_highwater;
    1.19 +
    1.20 +
    1.21  /* a flag recording whether initialization has been done */
    1.22  /* or more properly, if the tbuf subsystem is enabled right now */
    1.23  int tb_init_done;
    1.24 @@ -50,6 +57,12 @@ static unsigned long tb_cpu_mask = (~0UL
    1.25  /* which tracing events are enabled */
    1.26  static u32 tb_event_mask = TRC_ALL;
    1.27  
    1.28 +static void trace_notify_guest(void)
    1.29 +{
    1.30 +    send_guest_global_virq(dom0, VIRQ_TBUF);
    1.31 +}
    1.32 +
    1.33 +
    1.34  /**
    1.35   * alloc_trace_bufs - performs initialization of the per-cpu trace buffers.
    1.36   *
    1.37 @@ -93,6 +106,9 @@ static int alloc_trace_bufs(void)
    1.38          t_recs[i] = (struct t_rec *)(buf + 1);
    1.39      }
    1.40  
    1.41 +    t_buf_highwater = nr_recs >> 1; /* 50% high water */
    1.42 +    open_softirq(TRACE_SOFTIRQ, trace_notify_guest);
    1.43 +
    1.44      return 0;
    1.45  }
    1.46  
    1.47 @@ -272,6 +288,13 @@ void trace(u32 event, unsigned long d1, 
    1.48      buf->prod++;
    1.49  
    1.50      local_irq_restore(flags);
    1.51 +
    1.52 +    /*
    1.53 +     * Notify trace buffer consumer that we've reached the high water mark.
    1.54 +     *
    1.55 +     */
    1.56 +    if ( (buf->prod - buf->cons) == t_buf_highwater )
    1.57 +        raise_softirq(TRACE_SOFTIRQ);
    1.58  }
    1.59  
    1.60  /*
     2.1 --- a/xen/include/public/xen.h	Fri Apr 07 18:41:28 2006 +0100
     2.2 +++ b/xen/include/public/xen.h	Sat Apr 08 09:05:53 2006 +0100
     2.3 @@ -77,6 +77,7 @@
     2.4  #define VIRQ_DEBUG      1  /* V. Request guest to dump debug info.           */
     2.5  #define VIRQ_CONSOLE    2  /* G. (DOM0) Bytes received on emergency console. */
     2.6  #define VIRQ_DOM_EXC    3  /* G. (DOM0) Exceptional event for some domain.   */
     2.7 +#define VIRQ_TBUF       4  /* G. (DOM0) Trace buffer has records available.  */
     2.8  #define VIRQ_DEBUGGER   6  /* G. (DOM0) A domain has paused for debugging.   */
     2.9  #define VIRQ_XENOPROF   7  /* V. XenOprofile interrupt: new sample available */
    2.10  #define NR_VIRQS        8
     3.1 --- a/xen/include/xen/softirq.h	Fri Apr 07 18:41:28 2006 +0100
     3.2 +++ b/xen/include/xen/softirq.h	Sat Apr 08 09:05:53 2006 +0100
     3.3 @@ -9,7 +9,8 @@
     3.4  #define NMI_SOFTIRQ                       4
     3.5  #define PAGE_SCRUB_SOFTIRQ                5
     3.6  #define DOMAIN_SHUTDOWN_FINALISE_SOFTIRQ  6
     3.7 -#define NR_SOFTIRQS                       7
     3.8 +#define TRACE_SOFTIRQ                     7
     3.9 +#define NR_SOFTIRQS                       8
    3.10  
    3.11  #ifndef __ASSEMBLY__
    3.12