diff mbox

[6/6] kvm_stat: Add powerpc support

Message ID 1402991675-24905-6-git-send-email-mpe@ellerman.id.au
State New
Headers show

Commit Message

Michael Ellerman June 17, 2014, 7:54 a.m. UTC
Add support for powerpc platforms. We use uname -m, which allows us to
detect ppc, ppc64 and ppc64le/el.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 scripts/kvm/kvm_stat | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

Comments

Michael Ellerman June 18, 2014, 12:50 a.m. UTC | #1
On Tue, 2014-06-17 at 10:27 +0200, Alexander Graf wrote:
> On 17.06.14 09:54, Michael Ellerman wrote:
> > Add support for powerpc platforms. We use uname -m, which allows us to
> > detect ppc, ppc64 and ppc64le/el.
> >
> > Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> 
> Could you please add support for PR KVM tracepoints along the way? There 
> we do know the exit reason for every single guest <-> host transition. I 
> would like to move to a similar model with HV in the future, so we can 
> hopefully just reuse this by then.

So I think what you're saying is you want it to somehow support using
'kvm_exit' for PR and 'kvm_userspace_exit' for HV?

Or actually use 'kvm_exit' if it exists and fall back to 'kvm_userspace_exit',
so that if HV starts providing 'kvm_exit' the script will pick that up without
further changes.

cheers
Alexander Graf June 18, 2014, 12:59 a.m. UTC | #2
On 18.06.14 02:50, Michael Ellerman wrote:
> On Tue, 2014-06-17 at 10:27 +0200, Alexander Graf wrote:
>> On 17.06.14 09:54, Michael Ellerman wrote:
>>> Add support for powerpc platforms. We use uname -m, which allows us to
>>> detect ppc, ppc64 and ppc64le/el.
>>>
>>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
>> Could you please add support for PR KVM tracepoints along the way? There
>> we do know the exit reason for every single guest <-> host transition. I
>> would like to move to a similar model with HV in the future, so we can
>> hopefully just reuse this by then.
> So I think what you're saying is you want it to somehow support using
> 'kvm_exit' for PR and 'kvm_userspace_exit' for HV?

"kvm_userspace_exit" is implemented on both HV and PR. "kvm_exit" is PR 
only, but I'm hoping we can get it working in HV as well.

> Or actually use 'kvm_exit' if it exists and fall back to 'kvm_userspace_exit',
> so that if HV starts providing 'kvm_exit' the script will pick that up without
> further changes.

They are completely different things. "kvm_userspace_exit" tells us 
which exits we take from KVM -> QEMU. "kvm_exit" tells us which exits we 
take from guest -> KVM.

In fact, IIRC x86 also implements kvm_userspace_exit - or at least 
something very similar to it. It's a completely separate category. Maybe 
it should be a command line switch to distinguish between the count types?

Paolo, do you have any strong opinion here?


Alex
Michael Ellerman June 18, 2014, 1:37 a.m. UTC | #3
On Wed, 2014-06-18 at 02:59 +0200, Alexander Graf wrote:
> On 18.06.14 02:50, Michael Ellerman wrote:
> > On Tue, 2014-06-17 at 10:27 +0200, Alexander Graf wrote:
> >> On 17.06.14 09:54, Michael Ellerman wrote:
> >>> Add support for powerpc platforms. We use uname -m, which allows us to
> >>> detect ppc, ppc64 and ppc64le/el.
> >>>
> >>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> >> Could you please add support for PR KVM tracepoints along the way? There
> >> we do know the exit reason for every single guest <-> host transition. I
> >> would like to move to a similar model with HV in the future, so we can
> >> hopefully just reuse this by then.
> > So I think what you're saying is you want it to somehow support using
> > 'kvm_exit' for PR and 'kvm_userspace_exit' for HV?
> 
> "kvm_userspace_exit" is implemented on both HV and PR. "kvm_exit" is PR 
> only, but I'm hoping we can get it working in HV as well.
> 
> > Or actually use 'kvm_exit' if it exists and fall back to 'kvm_userspace_exit',
> > so that if HV starts providing 'kvm_exit' the script will pick that up without
> > further changes.
> 
> They are completely different things. "kvm_userspace_exit" tells us 
> which exits we take from KVM -> QEMU. "kvm_exit" tells us which exits we 
> take from guest -> KVM.
>
> In fact, IIRC x86 also implements kvm_userspace_exit - or at least 
> something very similar to it. It's a completely separate category. 

Right. Everyone implements kvm_userspace_exit, it's in virt/kvm/kvm_main.c

> Maybe it should be a command line switch to distinguish between the count types?

Or just we always read the kvm_userspace_exit counts, and if we find kvm_exit
we expose that as well - with an arch specific set of reasons.

cheers
Alexander Graf June 18, 2014, 1:54 a.m. UTC | #4
On 18.06.14 03:37, Michael Ellerman wrote:
> On Wed, 2014-06-18 at 02:59 +0200, Alexander Graf wrote:
>> On 18.06.14 02:50, Michael Ellerman wrote:
>>> On Tue, 2014-06-17 at 10:27 +0200, Alexander Graf wrote:
>>>> On 17.06.14 09:54, Michael Ellerman wrote:
>>>>> Add support for powerpc platforms. We use uname -m, which allows us to
>>>>> detect ppc, ppc64 and ppc64le/el.
>>>>>
>>>>> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
>>>> Could you please add support for PR KVM tracepoints along the way? There
>>>> we do know the exit reason for every single guest <-> host transition. I
>>>> would like to move to a similar model with HV in the future, so we can
>>>> hopefully just reuse this by then.
>>> So I think what you're saying is you want it to somehow support using
>>> 'kvm_exit' for PR and 'kvm_userspace_exit' for HV?
>> "kvm_userspace_exit" is implemented on both HV and PR. "kvm_exit" is PR
>> only, but I'm hoping we can get it working in HV as well.
>>
>>> Or actually use 'kvm_exit' if it exists and fall back to 'kvm_userspace_exit',
>>> so that if HV starts providing 'kvm_exit' the script will pick that up without
>>> further changes.
>> They are completely different things. "kvm_userspace_exit" tells us
>> which exits we take from KVM -> QEMU. "kvm_exit" tells us which exits we
>> take from guest -> KVM.
>>
>> In fact, IIRC x86 also implements kvm_userspace_exit - or at least
>> something very similar to it. It's a completely separate category.
> Right. Everyone implements kvm_userspace_exit, it's in virt/kvm/kvm_main.c
>
>> Maybe it should be a command line switch to distinguish between the count types?
> Or just we always read the kvm_userspace_exit counts, and if we find kvm_exit
> we expose that as well - with an arch specific set of reasons.

That would work too. I'm not sure how interesting the exit count of 
kvm_userspace_exit really is, but it certainly works for me to have it 
available as well.


Alex
Paolo Bonzini Oct. 31, 2014, 3:36 p.m. UTC | #5
Thanks, applied the series at last.

Paolo

On 17/06/2014 09:54, Michael Ellerman wrote:
> Add support for powerpc platforms. We use uname -m, which allows us to
> detect ppc, ppc64 and ppc64le/el.
> 
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  scripts/kvm/kvm_stat | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat
> index 2e0f5ed..db867fe 100755
> --- a/scripts/kvm/kvm_stat
> +++ b/scripts/kvm/kvm_stat
> @@ -12,7 +12,7 @@
>  # the COPYING file in the top-level directory.
>  
>  import curses
> -import sys, os, time, optparse
> +import sys, os, time, optparse, ctypes
>  
>  class DebugfsProvider(object):
>      def __init__(self):
> @@ -199,7 +199,21 @@ def s390_init():
>          'sc_perf_evt_open' : 331,
>      })
>  
> +def ppc_init():
> +    globals().update({
> +        'sc_perf_evt_open' : 319,
> +        'ioctl_numbers' : {
> +            'SET_FILTER' : 0x80002406 | (ctypes.sizeof(ctypes.c_char_p) << 16),
> +            'ENABLE'     : 0x20002400,
> +            'DISABLE'    : 0x20002401,
> +        }
> +    })
> +
>  def detect_platform():
> +    if os.uname()[4].startswith('ppc'):
> +        ppc_init()
> +        return
> +
>      for line in file('/proc/cpuinfo').readlines():
>          if line.startswith('flags'):
>              for flag in line.split():
> @@ -220,7 +234,7 @@ def invert(d):
>  for f in filters:
>      filters[f] = (filters[f][0], invert(filters[f][1]))
>  
> -import ctypes, struct, array
> +import struct, array
>  
>  libc = ctypes.CDLL('libc.so.6')
>  syscall = libc.syscall
>
Michael Ellerman Nov. 3, 2014, 12:40 a.m. UTC | #6
On Fri, 2014-10-31 at 16:36 +0100, Paolo Bonzini wrote:
> Thanks, applied the series at last.

Thanks.

cheers
diff mbox

Patch

diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat
index 2e0f5ed..db867fe 100755
--- a/scripts/kvm/kvm_stat
+++ b/scripts/kvm/kvm_stat
@@ -12,7 +12,7 @@ 
 # the COPYING file in the top-level directory.
 
 import curses
-import sys, os, time, optparse
+import sys, os, time, optparse, ctypes
 
 class DebugfsProvider(object):
     def __init__(self):
@@ -199,7 +199,21 @@  def s390_init():
         'sc_perf_evt_open' : 331,
     })
 
+def ppc_init():
+    globals().update({
+        'sc_perf_evt_open' : 319,
+        'ioctl_numbers' : {
+            'SET_FILTER' : 0x80002406 | (ctypes.sizeof(ctypes.c_char_p) << 16),
+            'ENABLE'     : 0x20002400,
+            'DISABLE'    : 0x20002401,
+        }
+    })
+
 def detect_platform():
+    if os.uname()[4].startswith('ppc'):
+        ppc_init()
+        return
+
     for line in file('/proc/cpuinfo').readlines():
         if line.startswith('flags'):
             for flag in line.split():
@@ -220,7 +234,7 @@  def invert(d):
 for f in filters:
     filters[f] = (filters[f][0], invert(filters[f][1]))
 
-import ctypes, struct, array
+import struct, array
 
 libc = ctypes.CDLL('libc.so.6')
 syscall = libc.syscall