aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/hist.c
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2013-01-24 10:10:29 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-04-01 11:19:43 -0400
commit05484298cbfebbf8c8c55b000541a245bc286bec (patch)
tree1b1336957d96defc9e637faf14aebacb5b9b693a /tools/perf/util/hist.c
parent2fe85427e3bf65d791700d065132772fc26e4d75 (diff)
perf tools: Add support for weight v7 (modified)
perf record has a new option -W that enables weightened sampling. Add sorting support in top/report for the average weight per sample and the total weight sum. This allows to both compare relative cost per event and the total cost over the measurement period. Add the necessary glue to perf report, record and the library. v2: Merge with new hist refactoring. v3: Fix manpage. Remove value check. Rename global_weight to weight and weight to local_weight. v4: Readd sort keys to manpage v5: Move weight to end v6: Move weight to template v7: Rename weight key. Original patch from Andi modified by Stephane Eranian <eranian@google.com> to include ONLY the weight supporting code and apply to pristine 3.8.0-rc4. Signed-off-by: Andi Kleen <ak@linux.intel.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung.kim@lge.com> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/1359040242-8269-6-git-send-email-eranian@google.com [ committer note: changed to cope with fc5871ed and the hists_link perf test entry ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/hist.c')
-rw-r--r--tools/perf/util/hist.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index f855941bebea..97ddd18acd7c 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -155,9 +155,11 @@ static void hist_entry__add_cpumode_period(struct hist_entry *he,
155 } 155 }
156} 156}
157 157
158static void he_stat__add_period(struct he_stat *he_stat, u64 period) 158static void he_stat__add_period(struct he_stat *he_stat, u64 period,
159 u64 weight)
159{ 160{
160 he_stat->period += period; 161 he_stat->period += period;
162 he_stat->weight += weight;
161 he_stat->nr_events += 1; 163 he_stat->nr_events += 1;
162} 164}
163 165
@@ -169,12 +171,14 @@ static void he_stat__add_stat(struct he_stat *dest, struct he_stat *src)
169 dest->period_guest_sys += src->period_guest_sys; 171 dest->period_guest_sys += src->period_guest_sys;
170 dest->period_guest_us += src->period_guest_us; 172 dest->period_guest_us += src->period_guest_us;
171 dest->nr_events += src->nr_events; 173 dest->nr_events += src->nr_events;
174 dest->weight += src->weight;
172} 175}
173 176
174static void hist_entry__decay(struct hist_entry *he) 177static void hist_entry__decay(struct hist_entry *he)
175{ 178{
176 he->stat.period = (he->stat.period * 7) / 8; 179 he->stat.period = (he->stat.period * 7) / 8;
177 he->stat.nr_events = (he->stat.nr_events * 7) / 8; 180 he->stat.nr_events = (he->stat.nr_events * 7) / 8;
181 /* XXX need decay for weight too? */
178} 182}
179 183
180static bool hists__decay_entry(struct hists *hists, struct hist_entry *he) 184static bool hists__decay_entry(struct hists *hists, struct hist_entry *he)
@@ -282,7 +286,8 @@ static u8 symbol__parent_filter(const struct symbol *parent)
282static struct hist_entry *add_hist_entry(struct hists *hists, 286static struct hist_entry *add_hist_entry(struct hists *hists,
283 struct hist_entry *entry, 287 struct hist_entry *entry,
284 struct addr_location *al, 288 struct addr_location *al,
285 u64 period) 289 u64 period,
290 u64 weight)
286{ 291{
287 struct rb_node **p; 292 struct rb_node **p;
288 struct rb_node *parent = NULL; 293 struct rb_node *parent = NULL;
@@ -306,7 +311,7 @@ static struct hist_entry *add_hist_entry(struct hists *hists,
306 cmp = hist_entry__cmp(he, entry); 311 cmp = hist_entry__cmp(he, entry);
307 312
308 if (!cmp) { 313 if (!cmp) {
309 he_stat__add_period(&he->stat, period); 314 he_stat__add_period(&he->stat, period, weight);
310 315
311 /* If the map of an existing hist_entry has 316 /* If the map of an existing hist_entry has
312 * become out-of-date due to an exec() or 317 * become out-of-date due to an exec() or
@@ -345,7 +350,8 @@ struct hist_entry *__hists__add_branch_entry(struct hists *self,
345 struct addr_location *al, 350 struct addr_location *al,
346 struct symbol *sym_parent, 351 struct symbol *sym_parent,
347 struct branch_info *bi, 352 struct branch_info *bi,
348 u64 period) 353 u64 period,
354 u64 weight)
349{ 355{
350 struct hist_entry entry = { 356 struct hist_entry entry = {
351 .thread = al->thread, 357 .thread = al->thread,
@@ -359,6 +365,7 @@ struct hist_entry *__hists__add_branch_entry(struct hists *self,
359 .stat = { 365 .stat = {
360 .period = period, 366 .period = period,
361 .nr_events = 1, 367 .nr_events = 1,
368 .weight = weight,
362 }, 369 },
363 .parent = sym_parent, 370 .parent = sym_parent,
364 .filtered = symbol__parent_filter(sym_parent), 371 .filtered = symbol__parent_filter(sym_parent),
@@ -366,12 +373,13 @@ struct hist_entry *__hists__add_branch_entry(struct hists *self,
366 .hists = self, 373 .hists = self,
367 }; 374 };
368 375
369 return add_hist_entry(self, &entry, al, period); 376 return add_hist_entry(self, &entry, al, period, weight);
370} 377}
371 378
372struct hist_entry *__hists__add_entry(struct hists *self, 379struct hist_entry *__hists__add_entry(struct hists *self,
373 struct addr_location *al, 380 struct addr_location *al,
374 struct symbol *sym_parent, u64 period) 381 struct symbol *sym_parent, u64 period,
382 u64 weight)
375{ 383{
376 struct hist_entry entry = { 384 struct hist_entry entry = {
377 .thread = al->thread, 385 .thread = al->thread,
@@ -385,13 +393,14 @@ struct hist_entry *__hists__add_entry(struct hists *self,
385 .stat = { 393 .stat = {
386 .period = period, 394 .period = period,
387 .nr_events = 1, 395 .nr_events = 1,
396 .weight = weight,
388 }, 397 },
389 .parent = sym_parent, 398 .parent = sym_parent,
390 .filtered = symbol__parent_filter(sym_parent), 399 .filtered = symbol__parent_filter(sym_parent),
391 .hists = self, 400 .hists = self,
392 }; 401 };
393 402
394 return add_hist_entry(self, &entry, al, period); 403 return add_hist_entry(self, &entry, al, period, weight);
395} 404}
396 405
397int64_t 406int64_t