All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yu Zhiguo <yuzg@cn.fujitsu.com>
To: Keir Fraser <keir.fraser@eu.citrix.com>, xen-devel@lists.xensource.com
Subject: tools/xenbaked: fix bug of getting trace buffer size
Date: Tue, 09 Feb 2010 18:10:39 +0800	[thread overview]
Message-ID: <4B71349F.6060808@cn.fujitsu.com> (raw)

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);

             reply	other threads:[~2010-02-09 10:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-09 10:10 Yu Zhiguo [this message]
2010-02-10  3:25 ` tools/xenbaked: fix bug of getting trace buffer size Yu Zhiguo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B71349F.6060808@cn.fujitsu.com \
    --to=yuzg@cn.fujitsu.com \
    --cc=keir.fraser@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.