summary refs log tree commit diff stats
path: root/scripts/kvm/kvm_stat
diff options
context:
space:
mode:
authorWei Huang <wei@redhat.com>2015-01-23 15:56:04 -0500
committerPaolo Bonzini <pbonzini@redhat.com>2015-01-26 12:27:05 +0100
commitfc116efad0aadb2f8a49d51240bddbfe21b631a0 (patch)
treeb23457793d38d52d98f884ea96bc206a19fda762 /scripts/kvm/kvm_stat
parent13704e4c455770d500d6b87b117e32f0d01252c9 (diff)
downloadfocaccia-qemu-fc116efad0aadb2f8a49d51240bddbfe21b631a0.tar.gz
focaccia-qemu-fc116efad0aadb2f8a49d51240bddbfe21b631a0.zip
kvm_stat: Add RESET support for perf event ioctl
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>
Diffstat (limited to 'scripts/kvm/kvm_stat')
-rwxr-xr-xscripts/kvm/kvm_stat5
1 files changed, 5 insertions, 0 deletions
diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat
index 8f6f00715e..c0c4ff0de3 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,6 +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()