All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Raspl <raspl@linux.vnet.ibm.com>
To: kvm@vger.kernel.org
Cc: pbonzini@redhat.com, rkrcmar@redhat.com, frankja@linux.vnet.ibm.com
Subject: [PATCH v1 16/19] tools/kvm_stat: add new interactive command 't'
Date: Wed,  7 Jun 2017 21:08:40 +0200	[thread overview]
Message-ID: <20170607190843.76869-17-raspl@linux.vnet.ibm.com> (raw)
In-Reply-To: <20170607190843.76869-1-raspl@linux.vnet.ibm.com>

It might be handy to display the full history of event stats in some cases.
Since we have that available for debugfs, we offer a respective command to
display what's available.
Note that this command does not toggle - one merely has to reset the stats
via 'r' to do the next best thing to reverting the effect of 't'.

Signed-off-by: Stefan Raspl <raspl@linux.vnet.ibm.com>
---
 tools/kvm/kvm_stat/kvm_stat     | 38 ++++++++++++++++++++++++++++++++++++--
 tools/kvm/kvm_stat/kvm_stat.txt |  2 ++
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat
index 1276b88937c0..169f6601a90c 100755
--- a/tools/kvm/kvm_stat/kvm_stat
+++ b/tools/kvm/kvm_stat/kvm_stat
@@ -677,6 +677,10 @@ class TracepointProvider(Provider):
             for event in group.events:
                 event.reset()
 
+    def restore(self):
+        """No historic data available that we could restore"""
+        pass
+
 
 class DebugfsProvider(Provider):
     """Provides data from the files that KVM creates in the kvm debugfs
@@ -730,7 +734,14 @@ class DebugfsProvider(Provider):
         self.reset()
 
     def read(self, reset=0):
-        """Returns a dict with format:'file name / field -> current value'."""
+        """Returns a dict with format:'file name / field -> current value'.
+
+        Parameter 'reset':
+          0   plain read
+          1   reset field counts to 0
+          2   restore the original field counts
+
+        """
         results = {}
 
         # If no debugfs filtering support is available, then don't read.
@@ -747,8 +758,10 @@ class DebugfsProvider(Provider):
             for field in self._fields:
                 value = self.read_field(field, path)
                 key = path + field
-                if reset:
+                if reset == 1:
                     self._baseline[key] = value
+                if reset == 2:
+                    self._baseline[key] = 0
                 if self._baseline.get(key, -1) == -1:
                     self._baseline[key] = value
                 results[field] = (results.get(field, 0) + value -
@@ -771,6 +784,11 @@ class DebugfsProvider(Provider):
         self._baseline = {}
         self.read(1)
 
+    def restore(self):
+        """Reset field counters"""
+        self._baseline = {}
+        self.read(2)
+
 
 class Stats(object):
     """Manages the data providers and the data they provide.
@@ -806,10 +824,20 @@ class Stats(object):
             provider.update_fields(self._fields_filter)
 
     def reset(self):
+        """Reset providers' field counters"""
         self.values = {}
         for provider in self.providers:
             provider.reset()
 
+    def restore(self):
+        """Restore providers' field counters"""
+        self.values = {}
+        for provider in self.providers:
+            provider.restore()
+        # Updates oldval (see get()) for all fields to prevent the totals from
+        # being displayed in the 'CurAvg/s' column on next refresh
+        self.get()
+
     @property
     def fields_filter(self):
         return self._fields_filter
@@ -1029,6 +1057,7 @@ class Tui(object):
                '   q     quit',
                '   r     reset stats',
                '   s     set update interval',
+               '   t     show total available stats (debugfs only)',
                '   x     toggle reporting of stats for individual child trace'
                ' events',
                'Any other key refreshes statistics immediately')
@@ -1229,8 +1258,12 @@ class Tui(object):
                     self.show_set_update_interval()
                     curses.curs_set(0)
                     sleeptime = self._delay_initial
+                if char == 't':
+                    self.stats.restore()
                 if char == 'x':
                     self.update_drilldown()
+                    # prevents display of current values on next refresh
+                    self.stats.get()
             except KeyboardInterrupt:
                 break
             except curses.error:
@@ -1306,6 +1339,7 @@ Interactive Commands:
    q     quit
    r     reset stats
    s     set update interval
+   t     show total available stats (debugfs only)
    x     toggle reporting of stats for individual child trace events
 Press any other key to refresh statistics immediately.
 """
diff --git a/tools/kvm/kvm_stat/kvm_stat.txt b/tools/kvm/kvm_stat/kvm_stat.txt
index cc019b09e0f5..53478ff6eded 100644
--- a/tools/kvm/kvm_stat/kvm_stat.txt
+++ b/tools/kvm/kvm_stat/kvm_stat.txt
@@ -45,6 +45,8 @@ INTERACTIVE COMMANDS
 
 *s*::   set update interval
 
+*t*::   show total available stats (debugfs only)
+
 *x*::	toggle reporting of stats for child trace events
 
 Press any other key to refresh statistics immediately.
-- 
2.11.2

  parent reply	other threads:[~2017-06-07 19:09 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-07 19:08 [PATCH v1 00/19] tools/kvm_stat: More misc patches Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 01/19] tools/kvm_stat: fix typo Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 02/19] tools/kvm_stat: fix event counts display for interrupted intervals Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 03/19] tools/kvm_stat: fix undue use of initial sleeptime Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 04/19] tools/kvm_stat: remove unnecessary header redraws Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 05/19] tools/kvm_stat: simplify line print logic Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 06/19] tools/kvm_stat: removed unused function Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 07/19] tools/kvm_stat: remove extra statement Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 08/19] tools/kvm_stat: simplify initializers Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 09/19] tools/kvm_stat: move functions to corresponding classes Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 10/19] tools/kvm_stat: show cursor in selection screens Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 11/19] tools/kvm_stat: display message indicating lack of events Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 12/19] tools/kvm_stat: make heading look a bit more like 'top' Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 13/19] tools/kvm_stat: rename 'Current' column to 'CurAvg/s' Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 14/19] tools/kvm_stat: add new interactive command 'h' Stefan Raspl
2017-06-08 16:19   ` Paolo Bonzini
2017-06-20  9:10     ` Stefan Raspl
2017-06-20 12:34       ` Paolo Bonzini
2017-06-07 19:08 ` [PATCH v1 15/19] tools/kvm_stat: add new interactive command 's' Stefan Raspl
2017-06-07 19:08 ` Stefan Raspl [this message]
2017-06-08 16:21   ` [PATCH v1 16/19] tools/kvm_stat: add new interactive command 't' Paolo Bonzini
2017-06-20  9:10     ` Stefan Raspl
2017-06-20 12:34       ` Paolo Bonzini
2017-06-20 13:09         ` Stefan Raspl
2017-06-20 13:17           ` Paolo Bonzini
2017-06-20 14:17             ` Stefan Raspl
2017-06-20 14:47               ` Paolo Bonzini
2017-06-21  6:54                 ` Stefan Raspl
2017-06-21 10:37                   ` Paolo Bonzini
2017-06-22  7:46                     ` Stefan Raspl
2017-06-22  7:52                       ` Paolo Bonzini
2017-06-22  8:51                         ` Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 17/19] tools/kvm_stat: add new interactive command 'o' Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 18/19] tools/kvm_stat: add new interactive command 'b' Stefan Raspl
2017-06-08 16:24   ` Paolo Bonzini
2017-06-20  9:10     ` Stefan Raspl
2017-06-20 12:33       ` Paolo Bonzini
2017-06-20 13:07         ` Stefan Raspl
2017-06-20 13:10           ` Paolo Bonzini
2017-06-20 14:41             ` Stefan Raspl
2017-06-20 14:47               ` Paolo Bonzini
2017-06-21  4:51                 ` Stefan Raspl
2017-06-07 19:08 ` [PATCH v1 19/19] tools/kvm_stat: display guest list in pid/guest selection screens Stefan Raspl
2017-06-08 16:25 ` [PATCH v1 00/19] tools/kvm_stat: More misc patches Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170607190843.76869-17-raspl@linux.vnet.ibm.com \
    --to=raspl@linux.vnet.ibm.com \
    --cc=frankja@linux.vnet.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.