diff options
author | Namhyung Kim <namhyung@kernel.org> | 2012-09-11 00:15:07 -0400 |
---|---|---|
committer | Jiri Olsa <jolsa@kernel.org> | 2014-06-01 08:34:56 -0400 |
commit | f8be1c8c48c8469d1ce95ccdc77b1e2c6a29700e (patch) | |
tree | f7d8f836cba20bc69038f271268a5b84dba3ac6f /tools | |
parent | 69bcb019fc809874f518559c8e5b0a90176f0532 (diff) |
perf hists: Add support for accumulated stat of hist entry
Maintain accumulated stat information in hist_entry->stat_acc if
symbol_conf.cumulate_callchain is set. Fields in ->stat_acc have same
vaules initially, and will be updated as callchain is processed later.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arun Sharma <asharma@fb.com>
Tested-by: Rodrigo Campos <rodrigo@sdfg.com.ar>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Link: http://lkml.kernel.org/r/1401335910-16832-4-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/hist.c | 28 | ||||
-rw-r--r-- | tools/perf/util/sort.h | 1 | ||||
-rw-r--r-- | tools/perf/util/symbol.h | 1 |
3 files changed, 28 insertions, 2 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index d8662356de20..dfff2ee8effb 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -232,6 +232,8 @@ static bool hists__decay_entry(struct hists *hists, struct hist_entry *he) | |||
232 | return true; | 232 | return true; |
233 | 233 | ||
234 | he_stat__decay(&he->stat); | 234 | he_stat__decay(&he->stat); |
235 | if (symbol_conf.cumulate_callchain) | ||
236 | he_stat__decay(he->stat_acc); | ||
235 | 237 | ||
236 | diff = prev_period - he->stat.period; | 238 | diff = prev_period - he->stat.period; |
237 | 239 | ||
@@ -279,12 +281,26 @@ void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel) | |||
279 | 281 | ||
280 | static struct hist_entry *hist_entry__new(struct hist_entry *template) | 282 | static struct hist_entry *hist_entry__new(struct hist_entry *template) |
281 | { | 283 | { |
282 | size_t callchain_size = symbol_conf.use_callchain ? sizeof(struct callchain_root) : 0; | 284 | size_t callchain_size = 0; |
283 | struct hist_entry *he = zalloc(sizeof(*he) + callchain_size); | 285 | struct hist_entry *he; |
286 | |||
287 | if (symbol_conf.use_callchain || symbol_conf.cumulate_callchain) | ||
288 | callchain_size = sizeof(struct callchain_root); | ||
289 | |||
290 | he = zalloc(sizeof(*he) + callchain_size); | ||
284 | 291 | ||
285 | if (he != NULL) { | 292 | if (he != NULL) { |
286 | *he = *template; | 293 | *he = *template; |
287 | 294 | ||
295 | if (symbol_conf.cumulate_callchain) { | ||
296 | he->stat_acc = malloc(sizeof(he->stat)); | ||
297 | if (he->stat_acc == NULL) { | ||
298 | free(he); | ||
299 | return NULL; | ||
300 | } | ||
301 | memcpy(he->stat_acc, &he->stat, sizeof(he->stat)); | ||
302 | } | ||
303 | |||
288 | if (he->ms.map) | 304 | if (he->ms.map) |
289 | he->ms.map->referenced = true; | 305 | he->ms.map->referenced = true; |
290 | 306 | ||
@@ -296,6 +312,7 @@ static struct hist_entry *hist_entry__new(struct hist_entry *template) | |||
296 | */ | 312 | */ |
297 | he->branch_info = malloc(sizeof(*he->branch_info)); | 313 | he->branch_info = malloc(sizeof(*he->branch_info)); |
298 | if (he->branch_info == NULL) { | 314 | if (he->branch_info == NULL) { |
315 | free(he->stat_acc); | ||
299 | free(he); | 316 | free(he); |
300 | return NULL; | 317 | return NULL; |
301 | } | 318 | } |
@@ -359,6 +376,8 @@ static struct hist_entry *add_hist_entry(struct hists *hists, | |||
359 | 376 | ||
360 | if (!cmp) { | 377 | if (!cmp) { |
361 | he_stat__add_period(&he->stat, period, weight); | 378 | he_stat__add_period(&he->stat, period, weight); |
379 | if (symbol_conf.cumulate_callchain) | ||
380 | he_stat__add_period(he->stat_acc, period, weight); | ||
362 | 381 | ||
363 | /* | 382 | /* |
364 | * This mem info was allocated from sample__resolve_mem | 383 | * This mem info was allocated from sample__resolve_mem |
@@ -394,6 +413,8 @@ static struct hist_entry *add_hist_entry(struct hists *hists, | |||
394 | rb_insert_color(&he->rb_node_in, hists->entries_in); | 413 | rb_insert_color(&he->rb_node_in, hists->entries_in); |
395 | out: | 414 | out: |
396 | he_stat__add_cpumode_period(&he->stat, al->cpumode, period); | 415 | he_stat__add_cpumode_period(&he->stat, al->cpumode, period); |
416 | if (symbol_conf.cumulate_callchain) | ||
417 | he_stat__add_cpumode_period(he->stat_acc, al->cpumode, period); | ||
397 | return he; | 418 | return he; |
398 | } | 419 | } |
399 | 420 | ||
@@ -768,6 +789,7 @@ void hist_entry__free(struct hist_entry *he) | |||
768 | { | 789 | { |
769 | zfree(&he->branch_info); | 790 | zfree(&he->branch_info); |
770 | zfree(&he->mem_info); | 791 | zfree(&he->mem_info); |
792 | zfree(&he->stat_acc); | ||
771 | free_srcline(he->srcline); | 793 | free_srcline(he->srcline); |
772 | free(he); | 794 | free(he); |
773 | } | 795 | } |
@@ -793,6 +815,8 @@ static bool hists__collapse_insert_entry(struct hists *hists __maybe_unused, | |||
793 | 815 | ||
794 | if (!cmp) { | 816 | if (!cmp) { |
795 | he_stat__add_stat(&iter->stat, &he->stat); | 817 | he_stat__add_stat(&iter->stat, &he->stat); |
818 | if (symbol_conf.cumulate_callchain) | ||
819 | he_stat__add_stat(iter->stat_acc, he->stat_acc); | ||
796 | 820 | ||
797 | if (symbol_conf.use_callchain) { | 821 | if (symbol_conf.use_callchain) { |
798 | callchain_cursor_reset(&callchain_cursor); | 822 | callchain_cursor_reset(&callchain_cursor); |
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index 5f38d925e92f..c9ffa031becd 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h | |||
@@ -82,6 +82,7 @@ struct hist_entry { | |||
82 | struct list_head head; | 82 | struct list_head head; |
83 | } pairs; | 83 | } pairs; |
84 | struct he_stat stat; | 84 | struct he_stat stat; |
85 | struct he_stat *stat_acc; | ||
85 | struct map_symbol ms; | 86 | struct map_symbol ms; |
86 | struct thread *thread; | 87 | struct thread *thread; |
87 | struct comm *comm; | 88 | struct comm *comm; |
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 33ede53fa6b9..615c752dd767 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -109,6 +109,7 @@ struct symbol_conf { | |||
109 | show_nr_samples, | 109 | show_nr_samples, |
110 | show_total_period, | 110 | show_total_period, |
111 | use_callchain, | 111 | use_callchain, |
112 | cumulate_callchain, | ||
112 | exclude_other, | 113 | exclude_other, |
113 | show_cpu_utilization, | 114 | show_cpu_utilization, |
114 | initialized, | 115 | initialized, |