qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/3] kvm_stat update
@ 2015-01-21 21:15 Wei Huang
  2015-01-21 21:15 ` [Qemu-devel] [PATCH 1/3] kvm_stat: Add aarch64 support Wei Huang
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Wei Huang @ 2015-01-21 21:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, pbonzini

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

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH 1/3] kvm_stat: Add aarch64 support
  2015-01-21 21:15 [Qemu-devel] [PATCH 0/3] kvm_stat update Wei Huang
@ 2015-01-21 21:15 ` Wei Huang
  2015-01-21 21:15 ` [Qemu-devel] [PATCH 2/3] kvm_stat: Update exit reasons to the latest defintion Wei Huang
  2015-01-21 21:15 ` [Qemu-devel] [PATCH 3/3] kvm_stat: Print errno when syscall to perf_event_open() fails Wei Huang
  2 siblings, 0 replies; 7+ messages in thread
From: Wei Huang @ 2015-01-21 21:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, pbonzini

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

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

diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat
index 7b1437c..470ca08 100755
--- a/scripts/kvm/kvm_stat
+++ b/scripts/kvm/kvm_stat
@@ -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'):
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH 2/3] kvm_stat: Update exit reasons to the latest defintion
  2015-01-21 21:15 [Qemu-devel] [PATCH 0/3] kvm_stat update Wei Huang
  2015-01-21 21:15 ` [Qemu-devel] [PATCH 1/3] kvm_stat: Add aarch64 support Wei Huang
@ 2015-01-21 21:15 ` Wei Huang
  2015-01-22 12:56   ` Paolo Bonzini
  2015-01-21 21:15 ` [Qemu-devel] [PATCH 3/3] kvm_stat: Print errno when syscall to perf_event_open() fails Wei Huang
  2 siblings, 1 reply; 7+ messages in thread
From: Wei Huang @ 2015-01-21 21:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, pbonzini

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

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

diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat
index 470ca08..e8b3295 100755
--- a/scripts/kvm/kvm_stat
+++ b/scripts/kvm/kvm_stat
@@ -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 = {
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH 3/3] kvm_stat: Print errno when syscall to perf_event_open() fails
  2015-01-21 21:15 [Qemu-devel] [PATCH 0/3] kvm_stat update Wei Huang
  2015-01-21 21:15 ` [Qemu-devel] [PATCH 1/3] kvm_stat: Add aarch64 support Wei Huang
  2015-01-21 21:15 ` [Qemu-devel] [PATCH 2/3] kvm_stat: Update exit reasons to the latest defintion Wei Huang
@ 2015-01-21 21:15 ` Wei Huang
  2 siblings, 0 replies; 7+ messages in thread
From: Wei Huang @ 2015-01-21 21:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, pbonzini

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".

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

diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat
index e8b3295..f5f1c58 100755
--- a/scripts/kvm/kvm_stat
+++ b/scripts/kvm/kvm_stat
@@ -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)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH 2/3] kvm_stat: Update exit reasons to the latest defintion
  2015-01-21 21:15 ` [Qemu-devel] [PATCH 2/3] kvm_stat: Update exit reasons to the latest defintion Wei Huang
@ 2015-01-22 12:56   ` Paolo Bonzini
  2015-01-22 15:23     ` Wei Huang
  0 siblings, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2015-01-22 12:56 UTC (permalink / raw)
  To: Wei Huang, qemu-devel; +Cc: peter.maydell



On 21/01/2015 22:15, Wei Huang wrote:
> +    56: 'ACPI_WRITE',

APIC_WRITE. :)

Will fix when committing.

Paolo

> +    58: 'INVPCID',
>  }
>  

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH 2/3] kvm_stat: Update exit reasons to the latest defintion
  2015-01-22 12:56   ` Paolo Bonzini
@ 2015-01-22 15:23     ` Wei Huang
  2015-01-23 20:50       ` Wei Huang
  0 siblings, 1 reply; 7+ messages in thread
From: Wei Huang @ 2015-01-22 15:23 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: peter.maydell

On 01/22/2015 06:56 AM, Paolo Bonzini wrote:
> 
> 
> On 21/01/2015 22:15, Wei Huang wrote:
>> +    56: 'ACPI_WRITE',
> 
> APIC_WRITE. :)
> 
> Will fix when committing.
Gerr... thanks!

-Wei
> 
> Paolo
> 
>> +    58: 'INVPCID',
>>  }
>>  
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH 2/3] kvm_stat: Update exit reasons to the latest defintion
  2015-01-22 15:23     ` Wei Huang
@ 2015-01-23 20:50       ` Wei Huang
  0 siblings, 0 replies; 7+ messages in thread
From: Wei Huang @ 2015-01-23 20:50 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: peter.maydell

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

On 01/22/2015 09:23 AM, Wei Huang wrote:
> On 01/22/2015 06:56 AM, Paolo Bonzini wrote:
>>
>>
>> On 21/01/2015 22:15, Wei Huang wrote:
>>> +    56: 'ACPI_WRITE',
>>
>> APIC_WRITE. :)
>>
>> Will fix when committing.
> Gerr... thanks!
> 
> -Wei
>>
>> Paolo
>>
>>> +    58: 'INVPCID',
>>>  }
>>>  
>>
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-01-23 20:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-21 21:15 [Qemu-devel] [PATCH 0/3] kvm_stat update Wei Huang
2015-01-21 21:15 ` [Qemu-devel] [PATCH 1/3] kvm_stat: Add aarch64 support Wei Huang
2015-01-21 21:15 ` [Qemu-devel] [PATCH 2/3] kvm_stat: Update exit reasons to the latest defintion Wei Huang
2015-01-22 12:56   ` Paolo Bonzini
2015-01-22 15:23     ` Wei Huang
2015-01-23 20:50       ` Wei Huang
2015-01-21 21:15 ` [Qemu-devel] [PATCH 3/3] kvm_stat: Print errno when syscall to perf_event_open() fails Wei Huang

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