kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tools/kvm_stat: fix fields filter for child events
@ 2019-04-21 13:26 Stefan Raspl
  2019-05-20 13:42 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Raspl @ 2019-04-21 13:26 UTC (permalink / raw)
  To: kvm; +Cc: pbonzini, borntraeger

From: Stefan Raspl <stefan.raspl@de.ibm.com>

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>
---
 tools/kvm/kvm_stat/kvm_stat     | 16 ++++++++++++----
 tools/kvm/kvm_stat/kvm_stat.txt |  2 ++
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat
index 2ed395b817cb..bc508dae286c 100755
--- a/tools/kvm/kvm_stat/kvm_stat
+++ b/tools/kvm/kvm_stat/kvm_stat
@@ -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():
@@ -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):
diff --git a/tools/kvm/kvm_stat/kvm_stat.txt b/tools/kvm/kvm_stat/kvm_stat.txt
index 0811d860fe75..c057ba52364e 100644
--- a/tools/kvm/kvm_stat/kvm_stat.txt
+++ b/tools/kvm/kvm_stat/kvm_stat.txt
@@ -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
 
-- 
2.16.4


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

* Re: [PATCH] tools/kvm_stat: fix fields filter for child events
  2019-04-21 13:26 [PATCH] tools/kvm_stat: fix fields filter for child events Stefan Raspl
@ 2019-05-20 13:42 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2019-05-20 13:42 UTC (permalink / raw)
  To: Stefan Raspl, kvm; +Cc: borntraeger

On 21/04/19 15:26, Stefan Raspl wrote:
> From: Stefan Raspl <stefan.raspl@de.ibm.com>
> 
> 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>
> ---
>  tools/kvm/kvm_stat/kvm_stat     | 16 ++++++++++++----
>  tools/kvm/kvm_stat/kvm_stat.txt |  2 ++
>  2 files changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat
> index 2ed395b817cb..bc508dae286c 100755
> --- a/tools/kvm/kvm_stat/kvm_stat
> +++ b/tools/kvm/kvm_stat/kvm_stat
> @@ -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():
> @@ -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):
> diff --git a/tools/kvm/kvm_stat/kvm_stat.txt b/tools/kvm/kvm_stat/kvm_stat.txt
> index 0811d860fe75..c057ba52364e 100644
> --- a/tools/kvm/kvm_stat/kvm_stat.txt
> +++ b/tools/kvm/kvm_stat/kvm_stat.txt
> @@ -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
>  
> 

Queued, thanks.

Paolo

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

end of thread, other threads:[~2019-05-20 13:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-21 13:26 [PATCH] tools/kvm_stat: fix fields filter for child events Stefan Raspl
2019-05-20 13:42 ` Paolo Bonzini

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