debuggers.hg

changeset 21208:e2ec5cd8b396

xentrace: Skip to low cpu when throwing away portions of the circular buffer

Skip to the next "low" cpu when throwing away portions of the circular
memory buffer. This makes subsequent analysis easier.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Apr 13 18:18:36 2010 +0100 (2010-04-13)
parents 0bebb5fa4f05
children b4fce8f4ec37
files tools/xentrace/xentrace.c
line diff
     1.1 --- a/tools/xentrace/xentrace.c	Tue Apr 13 15:38:27 2010 +0100
     1.2 +++ b/tools/xentrace/xentrace.c	Tue Apr 13 18:18:36 2010 +0100
     1.3 @@ -149,6 +149,7 @@ void membuf_reserve_window(unsigned cpu,
     1.4  {
     1.5      struct cpu_change_record *rec;
     1.6      long need_to_consume, free, freed;
     1.7 +    int last_cpu = -1;
     1.8  
     1.9      if ( membuf.pending_size > 0 )
    1.10      {
    1.11 @@ -193,11 +194,25 @@ void membuf_reserve_window(unsigned cpu,
    1.12  
    1.13          if ( need_to_consume > 0 )
    1.14          {
    1.15 +            last_cpu = rec->data.cpu;
    1.16              MEMBUF_CONS_INCREMENT(freed);
    1.17              need_to_consume -= freed;
    1.18          }
    1.19      } while( need_to_consume > 0 );
    1.20  
    1.21 +    /* For good tsc consistency, we need to start at a low-cpu buffer.  Keep
    1.22 +     * skipping until the cpu goes down or stays the same. */
    1.23 +    rec = (struct cpu_change_record *)MEMBUF_POINTER(membuf.cons);
    1.24 +    while ( rec->data.cpu > last_cpu )
    1.25 +    {
    1.26 +        last_cpu = rec->data.cpu; 
    1.27 +
    1.28 +        freed = sizeof(*rec) + rec->data.window_size;
    1.29 +        
    1.30 +        MEMBUF_CONS_INCREMENT(freed);
    1.31 +        rec = (struct cpu_change_record *)MEMBUF_POINTER(membuf.cons);
    1.32 +    }
    1.33 +
    1.34  start_window:
    1.35      /*
    1.36       * Start writing "pending" data.  Update prod once all this data is