File perf-annotate-rename-sum-to-nr_samples-in-struct-sym_hist.patch of Package perf
xxxxxxxxxx
1
From: Taeung Song <treeze.taeung@gmail.com>
2
Date: Thu, 20 Jul 2017 06:36:51 +0900
3
Subject: perf annotate: Rename 'sum' to 'nr_samples' in struct sym_hist
4
Git-commit: 8158683da3d30e0346275702a8e08f2b22726c45
5
Patch-mainline: v4.14-rc1
6
References: bsc#1070010 (git-fixes)
7
Signed-off-By: Tony Jones <tonyj@suse.de>
8
9
To make it more clear that it is the sum of all the nr_samples fields in the
10
addr[] entries, i.e.:
11
12
sym_hist->nr_samples = sum(sym_hist->addr[0 .. symbol__size(sym)]->nr_samples)
13
14
Committer notes:
15
16
Taeung had renamed it to total_samples, but using nr_samples, as in the
17
added explanation above, looks clearer and establishes the direct
18
connection, making clear it is about the _number_ of samples.
19
20
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
21
Cc: Jiri Olsa <jolsa@redhat.com>
22
Cc: Namhyung Kim <namhyung@kernel.org>
23
Link: http://lkml.kernel.org/r/1500500211-16599-1-git-send-email-treeze.taeung@gmail.com
24
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
25
---
26
tools/perf/ui/gtk/annotate.c | 2 +-
27
tools/perf/util/annotate.c | 26 +++++++++++++-------------
28
tools/perf/util/annotate.h | 2 +-
29
3 files changed, 15 insertions(+), 15 deletions(-)
30
31
diff --git a/tools/perf/ui/gtk/annotate.c b/tools/perf/ui/gtk/annotate.c
32
index d736fd57ab9b..02176193f427 100644
33
--- a/tools/perf/ui/gtk/annotate.c
34
+++ b/tools/perf/ui/gtk/annotate.c
35
36
if (!symbol_conf.event_group && !symhist->addr[dl->offset].nr_samples)
37
return 0;
38
39
- percent = 100.0 * symhist->addr[dl->offset].nr_samples / symhist->sum;
40
+ percent = 100.0 * symhist->addr[dl->offset].nr_samples / symhist->nr_samples;
41
42
markup = perf_gtk__get_percent_color(percent);
43
if (markup)
44
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
45
index c3829555ce1c..58c6b63ff049 100644
46
--- a/tools/perf/util/annotate.c
47
+++ b/tools/perf/util/annotate.c
48
49
50
offset = addr - sym->start;
51
h = annotation__histogram(notes, evidx);
52
- h->sum++;
53
+ h->nr_samples++;
54
h->addr[offset].nr_samples++;
55
56
pr_debug3("%#" PRIx64 " %s: period++ [addr: %#" PRIx64 ", %#" PRIx64
57
58
while (offset < end)
59
hits += h->addr[offset++].nr_samples;
60
61
- if (h->sum) {
62
+ if (h->nr_samples) {
63
sample->nr_samples = hits;
64
- percent = 100.0 * hits / h->sum;
65
+ percent = 100.0 * hits / h->nr_samples;
66
}
67
}
68
69
70
struct sym_hist *h = annotation__histogram(notes, evidx);
71
struct rb_root tmp_root = RB_ROOT;
72
int nr_pcnt = 1;
73
- u64 h_sum = h->sum;
74
+ u64 nr_samples = h->nr_samples;
75
size_t sizeof_src_line = sizeof(struct source_line);
76
77
if (perf_evsel__is_group_event(evsel)) {
78
for (i = 1; i < evsel->nr_members; i++) {
79
h = annotation__histogram(notes, evidx + i);
80
- h_sum += h->sum;
81
+ nr_samples += h->nr_samples;
82
}
83
nr_pcnt = evsel->nr_members;
84
sizeof_src_line += (nr_pcnt - 1) * sizeof(src_line->samples);
85
}
86
87
- if (!h_sum)
88
+ if (!nr_samples)
89
return 0;
90
91
src_line = notes->src->lines = calloc(len, sizeof_src_line);
92
93
start = map__rip_2objdump(map, sym->start);
94
95
for (i = 0; i < len; i++) {
96
- u64 offset, nr_samples;
97
+ u64 offset;
98
double percent_max = 0.0;
99
100
src_line->nr_pcnt = nr_pcnt;
101
102
103
h = annotation__histogram(notes, evidx + k);
104
nr_samples = h->addr[i].nr_samples;
105
- if (h->sum)
106
- percent = 100.0 * nr_samples / h->sum;
107
+ if (h->nr_samples)
108
+ percent = 100.0 * nr_samples / h->nr_samples;
109
110
if (percent > percent_max)
111
percent_max = percent;
112
113
if (h->addr[offset].nr_samples != 0)
114
printf("%*" PRIx64 ": %" PRIu64 "\n", BITS_PER_LONG / 2,
115
sym->start + offset, h->addr[offset].nr_samples);
116
- printf("%*s: %" PRIu64 "\n", BITS_PER_LONG / 2, "h->sum", h->sum);
117
+ printf("%*s: %" PRIu64 "\n", BITS_PER_LONG / 2, "h->nr_samples", h->nr_samples);
118
}
119
120
int symbol__annotate_printf(struct symbol *sym, struct map *map,
121
122
width *= evsel->nr_members;
123
124
graph_dotted_len = printf(" %-*.*s| Source code & Disassembly of %s for %s (%" PRIu64 " samples)\n",
125
- width, width, "Percent", d_filename, evsel_name, h->sum);
126
+ width, width, "Percent", d_filename, evsel_name, h->nr_samples);
127
128
printf("%-*.*s----\n",
129
graph_dotted_len, graph_dotted_len, graph_dotted_line);
130
131
struct sym_hist *h = annotation__histogram(notes, evidx);
132
int len = symbol__size(sym), offset;
133
134
- h->sum = 0;
135
+ h->nr_samples = 0;
136
for (offset = 0; offset < len; ++offset) {
137
h->addr[offset].nr_samples = h->addr[offset].nr_samples * 7 / 8;
138
- h->sum += h->addr[offset].nr_samples;
139
+ h->nr_samples += h->addr[offset].nr_samples;
140
}
141
}
142
143
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
144
index 3a176633b324..e8c246ec53df 100644
145
--- a/tools/perf/util/annotate.h
146
+++ b/tools/perf/util/annotate.h
147
148
s64 end, const char **path, struct sym_hist_entry *sample);
149
150
struct sym_hist {
151
- u64 sum;
152
+ u64 nr_samples;
153
struct sym_hist_entry addr[0];
154
};
155
156
157