提交 5fcf3a55 编写于 作者: G Gavin Shan 提交者: Paolo Bonzini

tools/kvm_stat: Fix kvm_exit filter name

The filter name is fixed to "exit_reason" for some kvm_exit events, no
matter what architect we have. Actually, the filter name ("exit_reason")
is only applicable to x86, meaning it's broken on other architects
including aarch64.

This fixes the issue by providing various kvm_exit filter names, depending
on architect we're on. Afterwards, the variable filter name is picked and
applied through ioctl(fd, SET_FILTER).
Reported-by: NAndrew Jones <drjones@redhat.com>
Signed-off-by: NGavin Shan <gshan@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 56871d44
...@@ -270,6 +270,7 @@ class ArchX86(Arch): ...@@ -270,6 +270,7 @@ class ArchX86(Arch):
def __init__(self, exit_reasons): def __init__(self, exit_reasons):
self.sc_perf_evt_open = 298 self.sc_perf_evt_open = 298
self.ioctl_numbers = IOCTL_NUMBERS self.ioctl_numbers = IOCTL_NUMBERS
self.exit_reason_field = 'exit_reason'
self.exit_reasons = exit_reasons self.exit_reasons = exit_reasons
def debugfs_is_child(self, field): def debugfs_is_child(self, field):
...@@ -289,6 +290,7 @@ class ArchPPC(Arch): ...@@ -289,6 +290,7 @@ class ArchPPC(Arch):
# numbers depend on the wordsize. # numbers depend on the wordsize.
char_ptr_size = ctypes.sizeof(ctypes.c_char_p) char_ptr_size = ctypes.sizeof(ctypes.c_char_p)
self.ioctl_numbers['SET_FILTER'] = 0x80002406 | char_ptr_size << 16 self.ioctl_numbers['SET_FILTER'] = 0x80002406 | char_ptr_size << 16
self.exit_reason_field = 'exit_nr'
self.exit_reasons = {} self.exit_reasons = {}
def debugfs_is_child(self, field): def debugfs_is_child(self, field):
...@@ -300,6 +302,7 @@ class ArchA64(Arch): ...@@ -300,6 +302,7 @@ class ArchA64(Arch):
def __init__(self): def __init__(self):
self.sc_perf_evt_open = 241 self.sc_perf_evt_open = 241
self.ioctl_numbers = IOCTL_NUMBERS self.ioctl_numbers = IOCTL_NUMBERS
self.exit_reason_field = 'esr_ec'
self.exit_reasons = AARCH64_EXIT_REASONS self.exit_reasons = AARCH64_EXIT_REASONS
def debugfs_is_child(self, field): def debugfs_is_child(self, field):
...@@ -311,6 +314,7 @@ class ArchS390(Arch): ...@@ -311,6 +314,7 @@ class ArchS390(Arch):
def __init__(self): def __init__(self):
self.sc_perf_evt_open = 331 self.sc_perf_evt_open = 331
self.ioctl_numbers = IOCTL_NUMBERS self.ioctl_numbers = IOCTL_NUMBERS
self.exit_reason_field = None
self.exit_reasons = None self.exit_reasons = None
def debugfs_is_child(self, field): def debugfs_is_child(self, field):
...@@ -541,8 +545,8 @@ class TracepointProvider(Provider): ...@@ -541,8 +545,8 @@ class TracepointProvider(Provider):
""" """
filters = {} filters = {}
filters['kvm_userspace_exit'] = ('reason', USERSPACE_EXIT_REASONS) filters['kvm_userspace_exit'] = ('reason', USERSPACE_EXIT_REASONS)
if ARCH.exit_reasons: if ARCH.exit_reason_field and ARCH.exit_reasons:
filters['kvm_exit'] = ('exit_reason', ARCH.exit_reasons) filters['kvm_exit'] = (ARCH.exit_reason_field, ARCH.exit_reasons)
return filters return filters
def _get_available_fields(self): def _get_available_fields(self):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册