Skip to content

Commit 883d25e

Browse files
Stefan-Rasplbonzini
authored andcommitted
tools/kvm_stat: fix fields filter for child events
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 <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent c795720 commit 883d25e

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

tools/kvm/kvm_stat/kvm_stat

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,12 @@ class TracepointProvider(Provider):
575575
def update_fields(self, fields_filter):
576576
"""Refresh fields, applying fields_filter"""
577577
self.fields = [field for field in self._get_available_fields()
578-
if self.is_field_wanted(fields_filter, field) or
579-
ARCH.tracepoint_is_child(field)]
578+
if self.is_field_wanted(fields_filter, field)]
579+
# add parents for child fields - otherwise we won't see any output!
580+
for field in self._fields:
581+
parent = ARCH.tracepoint_is_child(field)
582+
if (parent and parent not in self._fields):
583+
self.fields.append(parent)
580584

581585
@staticmethod
582586
def _get_online_cpus():
@@ -735,8 +739,12 @@ class DebugfsProvider(Provider):
735739
def update_fields(self, fields_filter):
736740
"""Refresh fields, applying fields_filter"""
737741
self._fields = [field for field in self._get_available_fields()
738-
if self.is_field_wanted(fields_filter, field) or
739-
ARCH.debugfs_is_child(field)]
742+
if self.is_field_wanted(fields_filter, field)]
743+
# add parents for child fields - otherwise we won't see any output!
744+
for field in self._fields:
745+
parent = ARCH.debugfs_is_child(field)
746+
if (parent and parent not in self._fields):
747+
self.fields.append(parent)
740748

741749
@property
742750
def fields(self):

tools/kvm/kvm_stat/kvm_stat.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ INTERACTIVE COMMANDS
3434
*c*:: clear filter
3535

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

3840
*g*:: filter by guest name/PID
3941

0 commit comments

Comments
 (0)