WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] tools/xenbaked: fix bug of getting trace buffer size

To: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] tools/xenbaked: fix bug of getting trace buffer size
From: Yu Zhiguo <yuzg@xxxxxxxxxxxxxx>
Date: Wed, 10 Feb 2010 11:25:30 +0800
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Tue, 09 Feb 2010 19:25:21 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4B71349F.6060808@xxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <4B71349F.6060808@xxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 3.0a1 (Windows/2008050715)
Hi, Keir

 Please ignore this patch.

 Run xenbaked will occur Segmentation fault, because
some other bugs exist: the tbuf's meta&data which be gotten
is wrong, so SIGSEGV occurs in routine process_record()

static int process_record(int cpu, struct t_rec *r)
{
...snip...
    if ( r->cycles_included )    --- SIGSEGV

 The method to get tbuf's meta is wrong, I think it can be
fixed according to xentrace and I'll make a new patch.


regards,
Yu


Yu Zhiguo wrote:
> Size of t_info pages is regarded as trace buffer size now,
> it is wrong. This size should be t_info->tbuf_size * XC_PAGE_SIZE.
> 
> Signed-off-by: Yu Zhiguo <yuzg@xxxxxxxxxxxxxx>
> 
> diff --git a/tools/xenmon/xenbaked.c b/tools/xenmon/xenbaked.c
> --- a/tools/xenmon/xenbaked.c
> +++ b/tools/xenmon/xenbaked.c
> @@ -469,6 +469,40 @@
>      return physinfo.nr_cpus;
>  }
>  
> +/**
> + * get_tbuf_size - get the size in pages of each trace buffer
> + */
> +uint16_t get_tbuf_size(unsigned long tbufs_mfn, unsigned long tinfo_size)
> +{
> +    struct t_info *t_info;
> +    int xc_handle;
> +
> +    xc_handle = xc_interface_open();
> +    if ( xc_handle < 0 ) 
> +    {
> +        exit(EXIT_FAILURE);
> +    }
> +
> +    t_info = xc_map_foreign_range(xc_handle, DOMID_XEN,
> +                    tinfo_size, PROT_READ | PROT_WRITE,
> +                    tbufs_mfn);
> +
> +    if ( t_info == 0 ) 
> +    {
> +        PERROR("Failed to mmap trace buffers");
> +        exit(EXIT_FAILURE);
> +    }
> +
> +    if ( t_info->tbuf_size == 0 )
> +    {
> +        fprintf(stderr, "%s: tbuf_size 0!\n", __func__);
> +        exit(EXIT_FAILURE);
> +    }
> +
> +    xc_interface_close(xc_handle);
> +
> +    return t_info->tbuf_size;
> +}
>  
>  /**
>   * monitor_tbufs - monitor the contents of tbufs
> @@ -483,6 +517,8 @@
>                                    * where they are mapped into user space.   
> */
>      unsigned long tbufs_mfn;     /* mfn of the tbufs                         
> */
>      unsigned int  num;           /* number of trace buffers / logical CPUS   
> */
> +    unsigned long tinfo_size;    /* size of t_info metadata map              
> */
> +    uint16_t tbuf_size;          /* Size in pages of each trace buffer       
> */
>      unsigned long size;          /* size of a single trace buffer            
> */
>  
>      unsigned long data_size, rec_size;
> @@ -496,9 +532,12 @@
>      printf("CPU Frequency = %7.2f\n", opts.cpu_freq);
>      
>      /* setup access to trace buffers */
> -    get_tbufs(&tbufs_mfn, &size);
> +    get_tbufs(&tbufs_mfn, &tinfo_size);
>  
> -    tbufs_mapped = map_tbufs(tbufs_mfn, num, size);
> +    tbufs_mapped = map_tbufs(tbufs_mfn, num, tinfo_size);
> +
> +    tbuf_size = get_tbuf_size(tbufs_mfn, tinfo_size);
> +    size = tbuf_size * XC_PAGE_SIZE;
>  
>      data_size = size - sizeof(struct t_buf);
>  
> 
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel
> 
> 
> 


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>