Skip to contentSkip to conversation

kvm_stat update

PATCH Superseded Wei Huang 2 participants 7 messages Jan 21, 2015 – Jan 23, 2015

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Wei Huang

author
#0 lore raw

cover kvm_stat update

This patch set updates kvm_stat with the following new features:
* support for ARM aarch64
* the latest exit reasons (vmx, svm and userspace)
* print errno when syscall fails

Thanks,
-Wei

*** BLURB HERE ***

Wei Huang (3):
kvm_stat: Add aarch64 support
kvm_stat: Update exit reasons to the latest defintion
kvm_stat: Print errno when syscall to perf_event_open() fails

 scripts/kvm/kvm_stat | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH 1/3 kvm_stat: Add aarch64 support

This patch enables aarch64 support for kvm_stat. The platform detection is based on OS uname.

---
 scripts/kvm/kvm_stat | 8 ++++++++
 1 file changed, 8 insertions(+)
scripts/kvm/kvm_stat +8 -0
index 7b1437c..470ca08 100755
@@ -204,10 +204,18 @@ def ppc_init():
         }
     })
 
+def aarch64_init():
+    globals().update({
+        'sc_perf_evt_open' : 241
+    })
+
 def detect_platform():
     if os.uname()[4].startswith('ppc'):
         ppc_init()
         return
+    elif os.uname()[4].startswith('aarch64'):
+        aarch64_init()
+        return
 
     for line in file('/proc/cpuinfo').readlines():
         if line.startswith('flags'):
Signature · 1 line
1.8.3.1
author
#2 lore raw

PATCH 2/3 kvm_stat: Update exit reasons to the latest defintion

In reply to Wei Huang

This patch updates the exit reasons for x86_vmx, x86_svm, and userspace to the latest definition.

---
 scripts/kvm/kvm_stat | 4 ++++
 1 file changed, 4 insertions(+)
scripts/kvm/kvm_stat +4 -0
index 470ca08..e8b3295 100755
@@ -65,6 +65,8 @@ vmx_exit_reasons = {
     49: 'EPT_MISCONFIG',
     54: 'WBINVD',
     55: 'XSETBV',
+    56: 'ACPI_WRITE',
+    58: 'INVPCID',
 }
 
 svm_exit_reasons = {
@@ -138,6 +140,7 @@ svm_exit_reasons = {
     0x08a: 'MONITOR',
     0x08b: 'MWAIT',
     0x08c: 'MWAIT_COND',
+    0x08d: 'XSETBV',
     0x400: 'NPF',
 }
 
@@ -167,6 +170,7 @@ userspace_exit_reasons = {
     21: 'WATCHDOG',
     22: 'S390_TSCH',
     23: 'EPR',
+    24: 'SYSTEM_EVENT',
 }
 
 x86_exit_reasons = {
Signature · 1 line
1.8.3.1
#3 lore raw

Re: [Qemu-devel] [PATCH 2/3] kvm_stat: Update exit reasons to the latest defintion

Quoted 1 line · Wei Huang

+ 56: 'ACPI_WRITE',

APIC_WRITE. :)

Will fix when committing.

Paolo

Quoted 3 lines

+ 58: 'INVPCID',
}

author
#4 lore raw

Re: [Qemu-devel] [PATCH 2/3] kvm_stat: Update exit reasons to the latest defintion

Quoted 8 lines · Paolo Bonzini
Quoted 1 line · Wei Huang

+ 56: 'ACPI_WRITE',

APIC_WRITE. :)

Will fix when committing.

Gerr... thanks!

-Wei

Quoted 7 lines

Paolo

Quoted 3 lines

+ 58: 'INVPCID',
}

author
#5 lore raw

Re: [Qemu-devel] [PATCH 2/3] kvm_stat: Update exit reasons to the latest defintion

Hi Paolo,

I just sent out the second revision. You can cherry-pick the patch 04 if you have already queued my previous 3 patches.
Thanks for your review.

-Wei

Quoted 20 lines · Wei Huang
Quoted 8 lines · Paolo Bonzini
Quoted 1 line · Wei Huang

+ 56: 'ACPI_WRITE',

APIC_WRITE. :)

Will fix when committing.

Gerr... thanks!

-Wei

Quoted 7 lines

Paolo

Quoted 3 lines

+ 58: 'INVPCID',
}

author
#6 lore raw

PATCH 3/3 kvm_stat: Print errno when syscall to perf_event_open() fails

In reply to Wei Huang

kvm_stat uses syscall() to call perf_event_open(). If this function call fails, the returned value is -1, which doesn't tell the details of such failure (i.e. ENOSYS or EINVAL). This patch retrieves errno and prints it when syscall() fails. The error message will look like "Exception: perf_event_open failed, errno = 38".

---
 scripts/kvm/kvm_stat | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
scripts/kvm/kvm_stat +6 -1
index e8b3295..f5f1c58 100755
@@ -13,6 +13,7 @@
 
 import curses
 import sys, os, time, optparse, ctypes
+from ctypes import *
 
 class DebugfsProvider(object):
     def __init__(self):
@@ -247,6 +248,9 @@ import struct, array
 
 libc = ctypes.CDLL('libc.so.6')
 syscall = libc.syscall
+get_errno = libc.__errno_location
+get_errno.restype = POINTER(c_int)
+
 class perf_event_attr(ctypes.Structure):
     _fields_ = [('type', ctypes.c_uint32),
                 ('size', ctypes.c_uint32),
@@ -330,7 +334,8 @@ class Event(object):
             group_leader = group.events[0].fd
         fd = _perf_event_open(attr, -1, group.cpu, group_leader, 0)
         if fd == -1:
-            raise Exception('perf_event_open failed')
+            err = get_errno()[0]
+            raise Exception('perf_event_open failed, errno = ' + err.__str__())
         if filter:
             import fcntl
             fcntl.ioctl(fd, ioctl_numbers['SET_FILTER'], filter)
Signature · 1 line
1.8.3.1