On Thu, Nov 19, 2015 at 02:53:20PM -0300, Arnaldo Carvalho de Melo wrote:
> From: Namhyung Kim <namhy...@kernel.org>
> 
> The flat callchain mode is to print all chains in a single, simple
> hierarchy so make it easy to see.
> 
> Currently perf report --tui doesn't show flat callchains properly.  With
> flat callchains, only leaf nodes are added to the final rbtree so it
> should show entries in parent nodes.  To do that, add parent_val list to
> struct callchain_node and show them along with the (normal) val list.
> 
> For example, consider following callchains with '-g graph'.
> 
>   $ perf report -g graph
>   - 39.93%  swapper  [kernel.vmlinux]  [k] intel_idle
>        intel_idle
>        cpuidle_enter_state
>        cpuidle_enter
>        call_cpuidle
>      - cpu_startup_entry
>           28.63% start_secondary
>         - 11.30% rest_init
>              start_kernel
>              x86_64_start_reservations
>              x86_64_start_kernel
> 
> Before:
>   $ perf report -g flat
>   - 39.93%  swapper  [kernel.vmlinux]  [k] intel_idle
>        28.63% start_secondary
>      - 11.30% rest_init
>           start_kernel
>           x86_64_start_reservations
>           x86_64_start_kernel
> 
> After:
>   $ perf report -g flat
>   - 39.93%  swapper  [kernel.vmlinux]  [k] intel_idle
>      - 28.63% intel_idle
>           cpuidle_enter_state
>           cpuidle_enter
>           call_cpuidle
>           cpu_startup_entry
>           start_secondary
>      - 11.30% intel_idle
>           cpuidle_enter_state
>           cpuidle_enter
>           call_cpuidle
>           cpu_startup_entry
>           start_kernel
>           x86_64_start_reservations
>           x86_64_start_kernel
> 
> Signed-off-by: Namhyung Kim <namhy...@kernel.org>
> Tested-by: Arnaldo Carvalho de Melo <a...@redhat.com>
> Tested-by: Brendan Gregg <brendan.d.gr...@gmail.com>
> Cc: Andi Kleen <a...@firstfloor.org>
> Cc: David Ahern <dsah...@gmail.com>
> Cc: Frederic Weisbecker <fweis...@gmail.com>
> Cc: Jiri Olsa <jo...@redhat.com>
> Cc: Kan Liang <kan.li...@intel.com>
> Cc: Peter Zijlstra <a.p.zijls...@chello.nl>
> Link: 
> http://lkml.kernel.org/r/1447047946-1691-8-git-send-email-namhy...@kernel.org
> Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
> ---

[...]

> +int callchain_node__make_parent_list(struct callchain_node *node)
> +{
> +     struct callchain_node *parent = node->parent;
> +     struct callchain_list *chain, *new;
> +     LIST_HEAD(head);
> +
> +     while (parent) {
> +             list_for_each_entry_reverse(chain, &parent->val, list) {
> +                     new = malloc(sizeof(*new));
> +                     if (new == NULL)
> +                             goto out;
> +                     *new = *chain;
> +                     new->has_children = false;
> +                     list_add_tail(&new->list, &head);
> +             }
> +             parent = parent->parent;
> +     }
> +
> +     list_for_each_entry_safe_reverse(chain, new, &head, list)
> +             list_move_tail(&chain->list, &node->parent_val);
> +
> +     if (!list_empty(&node->parent_val)) {
> +             chain = list_first_entry(&node->parent_val, struct 
> callchain_list, list);
> +             chain->has_children = rb_prev(&node->rb_node) || 
> rb_next(&node->rb_node);
> +
> +             chain = list_first_entry(&node->val, struct callchain_list, 
> list);
> +             chain->has_children = false;

I'm a bit puzzled with this, can't we rewind through the parents on printing or 
adding
to the flat rbtree instead of having this parent_val field?

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to