Skip to content

Commit

Permalink
tools/kvm_stat: fix fields filter for child events
Browse files Browse the repository at this point in the history
The fields filter would not work with child fields, as the respective
parents would not be included. No parents displayed == no childs displayed.
To reproduce, run on s390 (would work on other platforms, too, but would
require a different filter name):
- Run 'kvm_stat -d'
- Press 'f'
- Enter 'instruct'
Notice that events like instruction_diag_44 or instruction_diag_500 are not
displayed - the output remains empty.
With this patch, we will filter by matching events and their parents.
However, consider the following example where we filter by
instruction_diag_44:

  kvm statistics - summary
                   regex filter: instruction_diag_44
   Event                                         Total %Total CurAvg/s
   exit_instruction                                276  100.0       12
     instruction_diag_44                           256   92.8       11
   Total                                           276              12

Note that the parent ('exit_instruction') displays the total events, but
the childs listed do not match its total (256 instead of 276). This is
intended (since we're filtering all but one child), but might be confusing
on first sight.

Signed-off-by: Stefan Raspl <raspl@linux.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Stefan Raspl authored and Paolo Bonzini committed May 24, 2019
1 parent c795720 commit 883d25e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 12 additions & 4 deletions tools/kvm/kvm_stat/kvm_stat
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,12 @@ class TracepointProvider(Provider):
def update_fields(self, fields_filter):
"""Refresh fields, applying fields_filter"""
self.fields = [field for field in self._get_available_fields()
if self.is_field_wanted(fields_filter, field) or
ARCH.tracepoint_is_child(field)]
if self.is_field_wanted(fields_filter, field)]
# add parents for child fields - otherwise we won't see any output!
for field in self._fields:
parent = ARCH.tracepoint_is_child(field)
if (parent and parent not in self._fields):
self.fields.append(parent)

@staticmethod
def _get_online_cpus():
Expand Down Expand Up @@ -735,8 +739,12 @@ class DebugfsProvider(Provider):
def update_fields(self, fields_filter):
"""Refresh fields, applying fields_filter"""
self._fields = [field for field in self._get_available_fields()
if self.is_field_wanted(fields_filter, field) or
ARCH.debugfs_is_child(field)]
if self.is_field_wanted(fields_filter, field)]
# add parents for child fields - otherwise we won't see any output!
for field in self._fields:
parent = ARCH.debugfs_is_child(field)
if (parent and parent not in self._fields):
self.fields.append(parent)

@property
def fields(self):
Expand Down
2 changes: 2 additions & 0 deletions tools/kvm/kvm_stat/kvm_stat.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ INTERACTIVE COMMANDS
*c*:: clear filter

*f*:: filter by regular expression
:: *Note*: Child events pull in their parents, and parents' stats summarize
all child events, not just the filtered ones

*g*:: filter by guest name/PID

Expand Down

0 comments on commit 883d25e

Please sign in to comment.