]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - pending-5.1/tools-kvm_stat-fix-fields-filter-for-child-events.patch
move existing queues out of the way for the moment...
[thirdparty/kernel/stable-queue.git] / pending-5.1 / tools-kvm_stat-fix-fields-filter-for-child-events.patch
1 From fb979946f7556bc5f8ddec9cdb94e8269c6a1895 Mon Sep 17 00:00:00 2001
2 From: Stefan Raspl <stefan.raspl@de.ibm.com>
3 Date: Sun, 21 Apr 2019 15:26:24 +0200
4 Subject: tools/kvm_stat: fix fields filter for child events
5
6 [ Upstream commit 883d25e70b2f699fed9017e509d1ef8e36229b89 ]
7
8 The fields filter would not work with child fields, as the respective
9 parents would not be included. No parents displayed == no childs displayed.
10 To reproduce, run on s390 (would work on other platforms, too, but would
11 require a different filter name):
12 - Run 'kvm_stat -d'
13 - Press 'f'
14 - Enter 'instruct'
15 Notice that events like instruction_diag_44 or instruction_diag_500 are not
16 displayed - the output remains empty.
17 With this patch, we will filter by matching events and their parents.
18 However, consider the following example where we filter by
19 instruction_diag_44:
20
21 kvm statistics - summary
22 regex filter: instruction_diag_44
23 Event Total %Total CurAvg/s
24 exit_instruction 276 100.0 12
25 instruction_diag_44 256 92.8 11
26 Total 276 12
27
28 Note that the parent ('exit_instruction') displays the total events, but
29 the childs listed do not match its total (256 instead of 276). This is
30 intended (since we're filtering all but one child), but might be confusing
31 on first sight.
32
33 Signed-off-by: Stefan Raspl <raspl@linux.ibm.com>
34 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
35 Signed-off-by: Sasha Levin <sashal@kernel.org>
36 ---
37 tools/kvm/kvm_stat/kvm_stat | 16 ++++++++++++----
38 tools/kvm/kvm_stat/kvm_stat.txt | 2 ++
39 2 files changed, 14 insertions(+), 4 deletions(-)
40
41 diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat
42 index 2ed395b817cb..bc508dae286c 100755
43 --- a/tools/kvm/kvm_stat/kvm_stat
44 +++ b/tools/kvm/kvm_stat/kvm_stat
45 @@ -575,8 +575,12 @@ class TracepointProvider(Provider):
46 def update_fields(self, fields_filter):
47 """Refresh fields, applying fields_filter"""
48 self.fields = [field for field in self._get_available_fields()
49 - if self.is_field_wanted(fields_filter, field) or
50 - ARCH.tracepoint_is_child(field)]
51 + if self.is_field_wanted(fields_filter, field)]
52 + # add parents for child fields - otherwise we won't see any output!
53 + for field in self._fields:
54 + parent = ARCH.tracepoint_is_child(field)
55 + if (parent and parent not in self._fields):
56 + self.fields.append(parent)
57
58 @staticmethod
59 def _get_online_cpus():
60 @@ -735,8 +739,12 @@ class DebugfsProvider(Provider):
61 def update_fields(self, fields_filter):
62 """Refresh fields, applying fields_filter"""
63 self._fields = [field for field in self._get_available_fields()
64 - if self.is_field_wanted(fields_filter, field) or
65 - ARCH.debugfs_is_child(field)]
66 + if self.is_field_wanted(fields_filter, field)]
67 + # add parents for child fields - otherwise we won't see any output!
68 + for field in self._fields:
69 + parent = ARCH.debugfs_is_child(field)
70 + if (parent and parent not in self._fields):
71 + self.fields.append(parent)
72
73 @property
74 def fields(self):
75 diff --git a/tools/kvm/kvm_stat/kvm_stat.txt b/tools/kvm/kvm_stat/kvm_stat.txt
76 index 0811d860fe75..c057ba52364e 100644
77 --- a/tools/kvm/kvm_stat/kvm_stat.txt
78 +++ b/tools/kvm/kvm_stat/kvm_stat.txt
79 @@ -34,6 +34,8 @@ INTERACTIVE COMMANDS
80 *c*:: clear filter
81
82 *f*:: filter by regular expression
83 + :: *Note*: Child events pull in their parents, and parents' stats summarize
84 + all child events, not just the filtered ones
85
86 *g*:: filter by guest name/PID
87
88 --
89 2.20.1
90