Re: [PATCH 10/28] perf report: Cache cumulative callchains

Jiri Olsa
2014-01-09T18:06:59Z

On Wed, Jan 08, 2014 at 05:46:15PM +0900, Namhyung Kim wrote:

SNIP

> goto out;
> }
>
> - if (al->map->groups == &iter->machine->kmaps) {
> - if (machine__is_host(iter->machine)) {
> + if (al->map->groups == &al->machine->kmaps) {
> + if (machine__is_host(al->machine)) {
> al->cpumode = PERF_RECORD_MISC_KERNEL;
> al->level = 'k';
> } else {
> @@ -417,7 +440,7 @@ iter_next_cumulative_entry(struct hist_entry_iter *iter,
> al->level = 'g';
> }
> } else {
> - if (machine__is_host(iter->machine)) {
> + if (machine__is_host(al->machine)) {
> al->cpumode = PERF_RECORD_MISC_USER;
> al->level = '.';
> } else if (perf_guest) {
> @@ -440,7 +463,29 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter,
> {
> struct perf_evsel *evsel = iter->evsel;
> struct perf_sample *sample = iter->sample;
> + struct hist_entry **he_cache = iter->priv;
> struct hist_entry *he;
> + struct hist_entry he_tmp = {
> + .cpu = al->cpu,
> + .thread = al->thread,
> + .comm = thread__comm(al->thread),
> + .ip = al->addr,
> + .ms = {
> + .map = al->map,
> + .sym = al->sym,
> + },
> + .parent = iter->parent,
> + };
> + int i;
> +
> + /*
> + * Check if there's duplicate entries in the callchain.
> + * It's possible that it has cycles or recursive calls.
> + */
> + for (i = 0; i < iter->curr; i++) {
> + if (hist_entry__cmp(he_cache[i], &he_tmp) == 0)

we need here:
iter->he = he_cache[i];

> + return 0;
> + }

otherwise iter->he and al are not in sync and
hist_entry__inc_addr_samples fails in hist_iter_cb

jirka