Received: from eggs.gnu.org ([2001:4830:134:3::10]:51886) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFfuz-00085I-H0 for qemu-devel@nongnu.org; Mon, 26 Jan 2015 04:25:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YFfuw-0006JX-4o for qemu-devel@nongnu.org; Mon, 26 Jan 2015 04:25:13 -0500 Received: from mail-we0-f179.google.com ([74.125.82.179]:49315) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFfuv-0006JM-Vg for qemu-devel@nongnu.org; Mon, 26 Jan 2015 04:25:10 -0500 Received: by mail-we0-f179.google.com with SMTP id q59so7862953wes.10 for ; Mon, 26 Jan 2015 01:25:09 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Mon, 26 Jan 2015 10:24:30 +0100 Message-Id: <1422264270-19278-20-git-send-email-pbonzini@redhat.com> In-Reply-To: <1422264270-19278-1-git-send-email-pbonzini@redhat.com> References: <1422264270-19278-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 19/19] kvm_stat: Add RESET support for perf event ioctl List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Wei Huang From: Wei Huang 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 --- scripts/kvm/kvm_stat | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat index 8f6f007..c0c4ff0 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() -- 1.8.3.1