File perf-hists-pass-perf_sample-to-_symbol__inc_addr_samples.patch of Package perf
197
1
From: Taeung Song <treeze.taeung@gmail.com>
2
Date: Thu, 20 Jul 2017 16:28:53 -0300
3
Subject: perf hists: Pass perf_sample to __symbol__inc_addr_samples()
4
Git-commit: bab89f6aed7e745893e009014354d0caaf62acf7
5
Patch-mainline: v4.14-rc1
6
References: bsc#1070010 (git-fixes)
7
Signed-off-By: Tony Jones <tonyj@suse.de>
8
9
To pave the way to use perf_sample fields in the annotate code, storing
10
sample->period in sym_hist->addr->period and its sum in
11
sym_hist->period.
12
13
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
14
Cc: Jiri Olsa <jolsa@redhat.com>
15
Cc: Namhyung Kim <namhyung@kernel.org>
16
Link: http://lkml.kernel.org/r/1500500215-16646-1-git-send-email-treeze.taeung@gmail.com
17
[ split and adjusted from a larger patch ]
18
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
19
---
20
tools/perf/builtin-annotate.c | 2 +-
21
tools/perf/builtin-report.c | 15 ++++++++-------
22
tools/perf/builtin-top.c | 5 +++--
23
tools/perf/util/annotate.c | 18 +++++++++++-------
24
tools/perf/util/annotate.h | 6 ++++--
25
5 files changed, 27 insertions(+), 19 deletions(-)
26
27
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
28
index 5205408e795b..96fe1a88c1e5 100644
29
--- a/tools/perf/builtin-annotate.c
30
+++ b/tools/perf/builtin-annotate.c
31
32
if (he == NULL)
33
return -ENOMEM;
34
35
- ret = hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
36
+ ret = hist_entry__inc_addr_samples(he, sample, evsel->idx, al->addr);
37
hists__inc_nr_samples(hists, true);
38
return ret;
39
}
40
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
41
index cea25d03f4dd..983b238d5eea 100644
42
--- a/tools/perf/builtin-report.c
43
+++ b/tools/perf/builtin-report.c
44
45
struct report *rep = arg;
46
struct hist_entry *he = iter->he;
47
struct perf_evsel *evsel = iter->evsel;
48
+ struct perf_sample *sample = iter->sample;
49
struct mem_info *mi;
50
struct branch_info *bi;
51
52
if (!ui__has_annotation())
53
return 0;
54
55
- hist__account_cycles(iter->sample->branch_stack, al, iter->sample,
56
+ hist__account_cycles(sample->branch_stack, al, sample,
57
rep->nonany_branch_mode);
58
59
if (sort__mode == SORT_MODE__BRANCH) {
60
bi = he->branch_info;
61
- err = addr_map_symbol__inc_samples(&bi->from, evsel->idx);
62
+ err = addr_map_symbol__inc_samples(&bi->from, sample, evsel->idx);
63
if (err)
64
goto out;
65
66
- err = addr_map_symbol__inc_samples(&bi->to, evsel->idx);
67
+ err = addr_map_symbol__inc_samples(&bi->to, sample, evsel->idx);
68
69
} else if (rep->mem_mode) {
70
mi = he->mem_info;
71
- err = addr_map_symbol__inc_samples(&mi->daddr, evsel->idx);
72
+ err = addr_map_symbol__inc_samples(&mi->daddr, sample, evsel->idx);
73
if (err)
74
goto out;
75
76
- err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
77
+ err = hist_entry__inc_addr_samples(he, sample, evsel->idx, al->addr);
78
79
} else if (symbol_conf.cumulate_callchain) {
80
if (single)
81
- err = hist_entry__inc_addr_samples(he, evsel->idx,
82
+ err = hist_entry__inc_addr_samples(he, sample, evsel->idx,
83
al->addr);
84
} else {
85
- err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
86
+ err = hist_entry__inc_addr_samples(he, sample, evsel->idx, al->addr);
87
}
88
89
out:
90
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
91
index 022486dc67f5..e5a8f249077f 100644
92
--- a/tools/perf/builtin-top.c
93
+++ b/tools/perf/builtin-top.c
94
95
96
static void perf_top__record_precise_ip(struct perf_top *top,
97
struct hist_entry *he,
98
+ struct perf_sample *sample,
99
int counter, u64 ip)
100
{
101
struct annotation *notes;
102
103
if (pthread_mutex_trylock(¬es->lock))
104
return;
105
106
- err = hist_entry__inc_addr_samples(he, counter, ip);
107
+ err = hist_entry__inc_addr_samples(he, sample, counter, ip);
108
109
pthread_mutex_unlock(¬es->lock);
110
111
112
struct perf_evsel *evsel = iter->evsel;
113
114
if (perf_hpp_list.sym && single)
115
- perf_top__record_precise_ip(top, he, evsel->idx, al->addr);
116
+ perf_top__record_precise_ip(top, he, iter->sample, evsel->idx, al->addr);
117
118
hist__account_cycles(iter->sample->branch_stack, al, iter->sample,
119
!(top->record_opts.branch_stack & PERF_SAMPLE_BRANCH_ANY));
120
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
121
index 58c6b63ff049..c2fe16d5e473 100644
122
--- a/tools/perf/util/annotate.c
123
+++ b/tools/perf/util/annotate.c
124
125
}
126
127
static int __symbol__inc_addr_samples(struct symbol *sym, struct map *map,
128
- struct annotation *notes, int evidx, u64 addr)
129
+ struct annotation *notes, int evidx, u64 addr,
130
+ struct perf_sample *sample __maybe_unused)
131
{
132
unsigned offset;
133
struct sym_hist *h;
134
135
}
136
137
static int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
138
- int evidx, u64 addr)
139
+ int evidx, u64 addr,
140
+ struct perf_sample *sample)
141
{
142
struct annotation *notes;
143
144
145
notes = symbol__get_annotation(sym, false);
146
if (notes == NULL)
147
return -ENOMEM;
148
- return __symbol__inc_addr_samples(sym, map, notes, evidx, addr);
149
+ return __symbol__inc_addr_samples(sym, map, notes, evidx, addr, sample);
150
}
151
152
static int symbol__account_cycles(u64 addr, u64 start,
153
154
return err;
155
}
156
157
-int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, int evidx)
158
+int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, struct perf_sample *sample,
159
+ int evidx)
160
{
161
- return symbol__inc_addr_samples(ams->sym, ams->map, evidx, ams->al_addr);
162
+ return symbol__inc_addr_samples(ams->sym, ams->map, evidx, ams->al_addr, sample);
163
}
164
165
-int hist_entry__inc_addr_samples(struct hist_entry *he, int evidx, u64 ip)
166
+int hist_entry__inc_addr_samples(struct hist_entry *he, struct perf_sample *sample,
167
+ int evidx, u64 ip)
168
{
169
- return symbol__inc_addr_samples(he->ms.sym, he->ms.map, evidx, ip);
170
+ return symbol__inc_addr_samples(he->ms.sym, he->ms.map, evidx, ip, sample);
171
}
172
173
static void disasm_line__init_ins(struct disasm_line *dl, struct arch *arch, struct map *map)
174
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
175
index e8c246ec53df..720f18195046 100644
176
--- a/tools/perf/util/annotate.h
177
+++ b/tools/perf/util/annotate.h
178
179
return (void *)sym - symbol_conf.priv_size;
180
}
181
182
-int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, int evidx);
183
+int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, struct perf_sample *sample,
184
+ int evidx);
185
186
int addr_map_symbol__account_cycles(struct addr_map_symbol *ams,
187
struct addr_map_symbol *start,
188
unsigned cycles);
189
190
-int hist_entry__inc_addr_samples(struct hist_entry *he, int evidx, u64 addr);
191
+int hist_entry__inc_addr_samples(struct hist_entry *he, struct perf_sample *sample,
192
+ int evidx, u64 addr);
193
194
int symbol__alloc_hist(struct symbol *sym);
195
void symbol__annotate_zero_histograms(struct symbol *sym);
196
197