Yu Zhiguo
2010-Feb-09 10:10 UTC
[Xen-devel] tools/xenbaked: fix bug of getting trace buffer size
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@cn.fujitsu.com>
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@lists.xensource.com
http://lists.xensource.com/xen-devel
Yu Zhiguo
2010-Feb-10 03:25 UTC
Re: [Xen-devel] tools/xenbaked: fix bug of getting trace buffer size
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@cn.fujitsu.com>
>
> 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@lists.xensource.com
> http://lists.xensource.com/xen-devel
>
>
>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel