[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[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@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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.