ia64/xen-unstable

changeset 10719:e05d60be5adb

[XENTRACE] Remember number of lost trace records when
trace buffer is full and write a 'number of lost records'
entry when space becomes available.
From: Rob Gardner <rob.gardner@hp.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Mon Jul 10 17:05:44 2006 +0100 (2006-07-10)
parents 3cdb93867f81
children 8922c1fbe684
files xen/common/trace.c xen/include/public/trace.h
line diff
     1.1 --- a/xen/common/trace.c	Mon Jul 10 16:09:20 2006 +0100
     1.2 +++ b/xen/common/trace.c	Mon Jul 10 17:05:44 2006 +0100
     1.3 @@ -46,6 +46,8 @@ static int nr_recs;
     1.4  /* Send virtual interrupt when buffer level reaches this point */
     1.5  static int t_buf_highwater;
     1.6  
     1.7 +/* Number of records lost due to per-CPU trace buffer being full. */
     1.8 +static DEFINE_PER_CPU(unsigned long, lost_records);
     1.9  
    1.10  /* a flag recording whether initialization has been done */
    1.11  /* or more properly, if the tbuf subsystem is enabled right now */
    1.12 @@ -234,7 +236,7 @@ void trace(u32 event, unsigned long d1, 
    1.13      struct t_buf *buf;
    1.14      struct t_rec *rec;
    1.15      unsigned long flags;
    1.16 -
    1.17 +    
    1.18      BUG_ON(!tb_init_done);
    1.19  
    1.20      if ( (tb_event_mask & event) == 0 )
    1.21 @@ -259,12 +261,27 @@ void trace(u32 event, unsigned long d1, 
    1.22  
    1.23      local_irq_save(flags);
    1.24  
    1.25 -    if ( (buf->prod - buf->cons) >= nr_recs )
    1.26 +    /* Check if space for two records (we write two if there are lost recs). */
    1.27 +    if ( (buf->prod - buf->cons) >= (nr_recs - 1) )
    1.28      {
    1.29 +        this_cpu(lost_records)++;
    1.30          local_irq_restore(flags);
    1.31          return;
    1.32      }
    1.33  
    1.34 +    if ( unlikely(this_cpu(lost_records) != 0) )
    1.35 +    {
    1.36 +        rec = &t_recs[smp_processor_id()][buf->prod % nr_recs];
    1.37 +        memset(rec, 0, sizeof(*rec));
    1.38 +        rec->cycles  = (u64)get_cycles();
    1.39 +        rec->event   = TRC_LOST_RECORDS;
    1.40 +        rec->data[0] = this_cpu(lost_records);
    1.41 +        this_cpu(lost_records) = 0;
    1.42 +
    1.43 +        wmb();
    1.44 +        buf->prod++;
    1.45 +    }
    1.46 +
    1.47      rec = &t_recs[smp_processor_id()][buf->prod % nr_recs];
    1.48      rec->cycles  = (u64)get_cycles();
    1.49      rec->event   = event;
     2.1 --- a/xen/include/public/trace.h	Mon Jul 10 16:09:20 2006 +0100
     2.2 +++ b/xen/include/public/trace.h	Mon Jul 10 17:05:44 2006 +0100
     2.3 @@ -26,6 +26,7 @@
     2.4  #define TRC_VMXIO    0x00088000   /* VMX io emulation trace  */
     2.5  
     2.6  /* Trace events per class */
     2.7 +#define TRC_LOST_RECORDS        (TRC_GEN + 1)
     2.8  
     2.9  #define TRC_SCHED_DOM_ADD       (TRC_SCHED +  1)
    2.10  #define TRC_SCHED_DOM_REM       (TRC_SCHED +  2)