qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Wei Huang <wei@redhat.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, peter.maydell@linaro.org
Subject: [Qemu-devel] [PATCH V3 4/4] kvm_stat: Add RESET support for perf event ioctl
Date: Fri, 23 Jan 2015 15:56:04 -0500	[thread overview]
Message-ID: <1422046564-10270-5-git-send-email-wei@redhat.com> (raw)
In-Reply-To: <1422046564-10270-1-git-send-email-wei@redhat.com>

While running kvm_stat using tracepoint on ARM64 hardware (e.g. "kvm_stat
-1 -t"), the initial values of some kvm_userspace_exit counters were found
to be very suspecious. For instance the tracing tool showed that S390_TSCH
was called many times on ARM64 machine, which apparently was wrong.

This patch adds RESET ioctl support for perf monitoring. Before calling
ioctl to enable a perf event, this patch resets the counter first. With
this patch, the init counter values become correct on ARM64 hardware.

Example:

==== before patch ====
kvm_userspace_exit(S390_SIEIC)      1426         0
kvm_userspace_exit(S390_TSCH)       339         0

==== after patch ====
kvm_userspace_exit(S390_SIEIC)         0         0
kvm_userspace_exit(S390_TSCH)         0         0

Signed-off-by: Wei Huang <wei@redhat.com>
---
 scripts/kvm/kvm_stat | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat
index 8f6f007..f927e97 100755
--- a/scripts/kvm/kvm_stat
+++ b/scripts/kvm/kvm_stat
@@ -186,6 +186,7 @@ ioctl_numbers = {
     'SET_FILTER' : 0x40082406,
     'ENABLE'     : 0x00002400,
     'DISABLE'    : 0x00002401,
+    'RESET'      : 0x00002403,
 }
 
 def x86_init(flag):
@@ -346,6 +347,9 @@ class Event(object):
     def disable(self):
         import fcntl
         fcntl.ioctl(self.fd, ioctl_numbers['DISABLE'], 0)
+    def reset(self):
+        import fcntl
+        fcntl.ioctl(self.fd, ioctl_numbers['RESET'], 0)
 
 class TracepointProvider(object):
     def __init__(self):
@@ -405,7 +409,7 @@ class TracepointProvider(object):
         for group in self.group_leaders:
             for event in group.events:
                 if event.name in fields:
+                    event.reset()
                     event.enable()
                 else:
                     event.disable()
-- 
1.8.3.1

      parent reply	other threads:[~2015-01-23 20:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-23 20:56 [Qemu-devel] [PATCH V3 0/4] kvm_stat update Wei Huang
2015-01-23 20:56 ` [Qemu-devel] [PATCH V3 1/4] kvm_stat: Update exit reasons to the latest defintion Wei Huang
2015-01-23 20:56 ` [Qemu-devel] [PATCH V3 2/4] kvm_stat: Print errno when syscall to perf_event_open() fails Wei Huang
2015-01-23 20:56 ` [Qemu-devel] [PATCH V3 3/4] kvm_stat: Add aarch64 support Wei Huang
2015-01-23 20:56 ` Wei Huang [this message]

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=1422046564-10270-5-git-send-email-wei@redhat.com \
    --to=wei@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).