diff options
Diffstat (limited to 'tools/perf/util/hist.c')
-rw-r--r-- | tools/perf/util/hist.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index dfff2ee8effb..b9facf33b224 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -279,7 +279,8 @@ void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel) | |||
279 | * histogram, sorted on item, collects periods | 279 | * histogram, sorted on item, collects periods |
280 | */ | 280 | */ |
281 | 281 | ||
282 | static struct hist_entry *hist_entry__new(struct hist_entry *template) | 282 | static struct hist_entry *hist_entry__new(struct hist_entry *template, |
283 | bool sample_self) | ||
283 | { | 284 | { |
284 | size_t callchain_size = 0; | 285 | size_t callchain_size = 0; |
285 | struct hist_entry *he; | 286 | struct hist_entry *he; |
@@ -299,6 +300,8 @@ static struct hist_entry *hist_entry__new(struct hist_entry *template) | |||
299 | return NULL; | 300 | return NULL; |
300 | } | 301 | } |
301 | memcpy(he->stat_acc, &he->stat, sizeof(he->stat)); | 302 | memcpy(he->stat_acc, &he->stat, sizeof(he->stat)); |
303 | if (!sample_self) | ||
304 | memset(&he->stat, 0, sizeof(he->stat)); | ||
302 | } | 305 | } |
303 | 306 | ||
304 | if (he->ms.map) | 307 | if (he->ms.map) |
@@ -351,7 +354,8 @@ static u8 symbol__parent_filter(const struct symbol *parent) | |||
351 | 354 | ||
352 | static struct hist_entry *add_hist_entry(struct hists *hists, | 355 | static struct hist_entry *add_hist_entry(struct hists *hists, |
353 | struct hist_entry *entry, | 356 | struct hist_entry *entry, |
354 | struct addr_location *al) | 357 | struct addr_location *al, |
358 | bool sample_self) | ||
355 | { | 359 | { |
356 | struct rb_node **p; | 360 | struct rb_node **p; |
357 | struct rb_node *parent = NULL; | 361 | struct rb_node *parent = NULL; |
@@ -375,7 +379,8 @@ static struct hist_entry *add_hist_entry(struct hists *hists, | |||
375 | cmp = hist_entry__cmp(he, entry); | 379 | cmp = hist_entry__cmp(he, entry); |
376 | 380 | ||
377 | if (!cmp) { | 381 | if (!cmp) { |
378 | he_stat__add_period(&he->stat, period, weight); | 382 | if (sample_self) |
383 | he_stat__add_period(&he->stat, period, weight); | ||
379 | if (symbol_conf.cumulate_callchain) | 384 | if (symbol_conf.cumulate_callchain) |
380 | he_stat__add_period(he->stat_acc, period, weight); | 385 | he_stat__add_period(he->stat_acc, period, weight); |
381 | 386 | ||
@@ -405,14 +410,15 @@ static struct hist_entry *add_hist_entry(struct hists *hists, | |||
405 | p = &(*p)->rb_right; | 410 | p = &(*p)->rb_right; |
406 | } | 411 | } |
407 | 412 | ||
408 | he = hist_entry__new(entry); | 413 | he = hist_entry__new(entry, sample_self); |
409 | if (!he) | 414 | if (!he) |
410 | return NULL; | 415 | return NULL; |
411 | 416 | ||
412 | rb_link_node(&he->rb_node_in, parent, p); | 417 | rb_link_node(&he->rb_node_in, parent, p); |
413 | rb_insert_color(&he->rb_node_in, hists->entries_in); | 418 | rb_insert_color(&he->rb_node_in, hists->entries_in); |
414 | out: | 419 | out: |
415 | he_stat__add_cpumode_period(&he->stat, al->cpumode, period); | 420 | if (sample_self) |
421 | he_stat__add_cpumode_period(&he->stat, al->cpumode, period); | ||
416 | if (symbol_conf.cumulate_callchain) | 422 | if (symbol_conf.cumulate_callchain) |
417 | he_stat__add_cpumode_period(he->stat_acc, al->cpumode, period); | 423 | he_stat__add_cpumode_period(he->stat_acc, al->cpumode, period); |
418 | return he; | 424 | return he; |
@@ -423,7 +429,8 @@ struct hist_entry *__hists__add_entry(struct hists *hists, | |||
423 | struct symbol *sym_parent, | 429 | struct symbol *sym_parent, |
424 | struct branch_info *bi, | 430 | struct branch_info *bi, |
425 | struct mem_info *mi, | 431 | struct mem_info *mi, |
426 | u64 period, u64 weight, u64 transaction) | 432 | u64 period, u64 weight, u64 transaction, |
433 | bool sample_self) | ||
427 | { | 434 | { |
428 | struct hist_entry entry = { | 435 | struct hist_entry entry = { |
429 | .thread = al->thread, | 436 | .thread = al->thread, |
@@ -448,7 +455,7 @@ struct hist_entry *__hists__add_entry(struct hists *hists, | |||
448 | .transaction = transaction, | 455 | .transaction = transaction, |
449 | }; | 456 | }; |
450 | 457 | ||
451 | return add_hist_entry(hists, &entry, al); | 458 | return add_hist_entry(hists, &entry, al, sample_self); |
452 | } | 459 | } |
453 | 460 | ||
454 | static int | 461 | static int |
@@ -501,7 +508,7 @@ iter_add_single_mem_entry(struct hist_entry_iter *iter, struct addr_location *al | |||
501 | * and the he_stat__add_period() function. | 508 | * and the he_stat__add_period() function. |
502 | */ | 509 | */ |
503 | he = __hists__add_entry(&iter->evsel->hists, al, iter->parent, NULL, mi, | 510 | he = __hists__add_entry(&iter->evsel->hists, al, iter->parent, NULL, mi, |
504 | cost, cost, 0); | 511 | cost, cost, 0, true); |
505 | if (!he) | 512 | if (!he) |
506 | return -ENOMEM; | 513 | return -ENOMEM; |
507 | 514 | ||
@@ -608,7 +615,7 @@ iter_add_next_branch_entry(struct hist_entry_iter *iter, struct addr_location *a | |||
608 | * and not events sampled. Thus we use a pseudo period of 1. | 615 | * and not events sampled. Thus we use a pseudo period of 1. |
609 | */ | 616 | */ |
610 | he = __hists__add_entry(&evsel->hists, al, iter->parent, &bi[i], NULL, | 617 | he = __hists__add_entry(&evsel->hists, al, iter->parent, &bi[i], NULL, |
611 | 1, 1, 0); | 618 | 1, 1, 0, true); |
612 | if (he == NULL) | 619 | if (he == NULL) |
613 | return -ENOMEM; | 620 | return -ENOMEM; |
614 | 621 | ||
@@ -657,7 +664,7 @@ iter_add_single_normal_entry(struct hist_entry_iter *iter, struct addr_location | |||
657 | 664 | ||
658 | he = __hists__add_entry(&evsel->hists, al, iter->parent, NULL, NULL, | 665 | he = __hists__add_entry(&evsel->hists, al, iter->parent, NULL, NULL, |
659 | sample->period, sample->weight, | 666 | sample->period, sample->weight, |
660 | sample->transaction); | 667 | sample->transaction, true); |
661 | if (he == NULL) | 668 | if (he == NULL) |
662 | return -ENOMEM; | 669 | return -ENOMEM; |
663 | 670 | ||
@@ -1161,7 +1168,7 @@ static struct hist_entry *hists__add_dummy_entry(struct hists *hists, | |||
1161 | p = &(*p)->rb_right; | 1168 | p = &(*p)->rb_right; |
1162 | } | 1169 | } |
1163 | 1170 | ||
1164 | he = hist_entry__new(pair); | 1171 | he = hist_entry__new(pair, true); |
1165 | if (he) { | 1172 | if (he) { |
1166 | memset(&he->stat, 0, sizeof(he->stat)); | 1173 | memset(&he->stat, 0, sizeof(he->stat)); |
1167 | he->hists = hists; | 1174 | he->hists = hists; |