ia64/xen-unstable

changeset 17520:e382c13fab2b

xenbaked: Fix access to trace buffer after xentrace changes

Signed-off-by: Naoki Nishiguchi <nisiguti@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Apr 24 09:59:57 2008 +0100 (2008-04-24)
parents f73b9a286ee4
children b3454459ba31
files tools/xenmon/xenbaked.c
line diff
     1.1 --- a/tools/xenmon/xenbaked.c	Thu Apr 24 09:58:29 2008 +0100
     1.2 +++ b/tools/xenmon/xenbaked.c	Thu Apr 24 09:59:57 2008 +0100
     1.3 @@ -509,14 +509,36 @@ int monitor_tbufs(void)
     1.4      {
     1.5          for ( i = 0; (i < num) && !interrupted; i++ )
     1.6          {
     1.7 -            while ( meta[i]->cons != meta[i]->prod )
     1.8 +            unsigned long start_offset, end_offset, cons, prod;
     1.9 +
    1.10 +            cons = meta[i]->cons;
    1.11 +            prod = meta[i]->prod;
    1.12 +            xen_rmb(); /* read prod, then read item. */
    1.13 +
    1.14 +            if ( cons == prod )
    1.15 +                continue;
    1.16 +
    1.17 +            start_offset = cons % data_size;
    1.18 +            end_offset = prod % data_size;
    1.19 +
    1.20 +            if ( start_offset >= end_offset )
    1.21              {
    1.22 -                xen_rmb(); /* read prod, then read item. */
    1.23 +                while ( start_offset != data_size )
    1.24 +                {
    1.25 +                    rec_size = process_record(
    1.26 +                        i, (struct t_rec *)(data[i] + start_offset));
    1.27 +                    start_offset += rec_size;
    1.28 +                }
    1.29 +                start_offset = 0;
    1.30 +            }
    1.31 +            while ( start_offset != end_offset )
    1.32 +            {
    1.33                  rec_size = process_record(
    1.34 -                    i, (struct t_rec *)(data[i] + meta[i]->cons % data_size));
    1.35 -                xen_mb(); /* read item, then update cons. */
    1.36 -                meta[i]->cons += rec_size;
    1.37 +                    i, (struct t_rec *)(data[i] + start_offset));
    1.38 +                start_offset += rec_size;
    1.39              }
    1.40 +            xen_mb(); /* read item, then update cons. */
    1.41 +            meta[i]->cons = prod;
    1.42          }
    1.43  
    1.44  	wait_for_event();