public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>,
	Ingo Molnar <mingo@kernel.org>,
	linux-kernel@vger.kernel.org, Andi Kleen <andi@firstfloor.org>,
	David Ahern <dsahern@gmail.com>, Jiri Olsa <jolsa@redhat.com>,
	Kan Liang <kan.liang@intel.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: Re: [PATCH 34/37] perf hists browser: Support flat callchains
Date: Tue, 24 Nov 2015 14:27:08 +0900	[thread overview]
Message-ID: <20151124052708.GB2636@sejong> (raw)
In-Reply-To: <20151123151647.GD3587@lerouge>

On Mon, Nov 23, 2015 at 04:16:48PM +0100, Frederic Weisbecker wrote:
> On Thu, Nov 19, 2015 at 02:53:20PM -0300, Arnaldo Carvalho de Melo wrote:
> > From: Namhyung Kim <namhyung@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 <namhyung@kernel.org>
> > Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> > Tested-by: Brendan Gregg <brendan.d.gregg@gmail.com>
> > Cc: Andi Kleen <andi@firstfloor.org>
> > Cc: David Ahern <dsahern@gmail.com>
> > Cc: Frederic Weisbecker <fweisbec@gmail.com>
> > Cc: Jiri Olsa <jolsa@redhat.com>
> > Cc: Kan Liang <kan.liang@intel.com>
> > Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> > Link: http://lkml.kernel.org/r/1447047946-1691-8-git-send-email-namhyung@kernel.org
> > Signed-off-by: Arnaldo Carvalho de Melo <acme@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?

Yes, this code is to simplify things on parent nodes.  Maybe we could
go up to parents and print the callchain list there as you said.

However, problem I think is how to handle 'has_children' information
on parents.  That info controls folding status of each callchain.  As
the info is in the struct callchain_list and flat or folded callchain
mode require the info should be in the top-most entry, I cannot share
entries in parent nodes.

Thus I simply copied callchain lists in parents to leaf nodes.  Yes,
it will consume some memory but can simplify the code.

Thank you for your review anyway!
Namhyung

  reply	other threads:[~2015-11-24  5:27 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-19 17:52 [GIT PULL 00/37] perf/core improvements and fixes Arnaldo Carvalho de Melo
2015-11-19 17:52 ` [PATCH 01/37] perf test: Fix build of BPF and LLVM on older glibc libraries Arnaldo Carvalho de Melo
2015-11-19 17:52 ` [PATCH 02/37] tools: Fix selftests_install Makefile rule Arnaldo Carvalho de Melo
2015-11-19 17:52 ` [PATCH 03/37] tools: Adopt memdup() from tools/perf, moving it to tools/lib/string.c Arnaldo Carvalho de Melo
2015-11-19 17:52 ` [PATCH 04/37] tools: Clone the kernel's strtobool function Arnaldo Carvalho de Melo
2015-11-19 17:52 ` [PATCH 05/37] bpf tools: Load a program with different instances using preprocessor Arnaldo Carvalho de Melo
2015-11-19 17:52 ` [PATCH 06/37] perf bpf: Add BPF_PROLOGUE config options for further patches Arnaldo Carvalho de Melo
2015-11-19 17:52 ` [PATCH 07/37] perf bpf: Compile dwarf-regs.c if CONFIG_BPF_PROLOGUE is on Arnaldo Carvalho de Melo
2015-11-19 17:52 ` [PATCH 08/37] perf bpf: Allow BPF program attach to uprobe events Arnaldo Carvalho de Melo
2015-11-19 17:52 ` [PATCH 09/37] perf bpf: Allow attaching BPF programs to modules symbols Arnaldo Carvalho de Melo
2015-11-19 17:52 ` [PATCH 10/37] perf bpf: Allow BPF program config probing options Arnaldo Carvalho de Melo
2015-11-19 17:52 ` [PATCH 11/37] perf bpf: Add prologue for BPF programs for fetching arguments Arnaldo Carvalho de Melo
2015-11-19 17:52 ` [PATCH 12/37] perf bpf: Generate prologue for BPF programs Arnaldo Carvalho de Melo
2015-11-19 17:52 ` [PATCH 13/37] perf test: Test the BPF prologue adding infrastructure Arnaldo Carvalho de Melo
2015-11-19 17:53 ` [PATCH 14/37] perf test: Fix 'perf test BPF' when it fails to find a suitable vmlinux Arnaldo Carvalho de Melo
2015-11-19 17:53 ` [PATCH 15/37] perf bpf: Use same BPF program if arguments are identical Arnaldo Carvalho de Melo
2015-11-19 17:53 ` [PATCH 16/37] perf tests: Pass the subtest index to each test routine Arnaldo Carvalho de Melo
2015-11-19 17:53 ` [PATCH 17/37] perf test: Print result for each LLVM subtest Arnaldo Carvalho de Melo
2015-11-19 17:53 ` [PATCH 18/37] perf test: Print result for each BPF subtest Arnaldo Carvalho de Melo
2015-11-19 17:53 ` [PATCH 19/37] perf test: Mute test cases error messages if verbose == 0 Arnaldo Carvalho de Melo
2015-11-19 17:53 ` [PATCH 20/37] perf probe: Fix to free temporal Dwarf_Frame Arnaldo Carvalho de Melo
2015-11-19 17:53 ` [PATCH 21/37] perf machine: Fix machine__findnew_module_map to put registered map Arnaldo Carvalho de Melo
2015-11-19 17:53 ` [PATCH 22/37] perf machine: Fix machine__destroy_kernel_maps to drop vmlinux_maps references Arnaldo Carvalho de Melo
2015-11-19 17:53 ` [PATCH 23/37] perf machine: Fix to destroy kernel maps when machine exits Arnaldo Carvalho de Melo
2015-11-19 17:53 ` [PATCH 24/37] perf tools: Make perf_exec_path() always return malloc'd string Arnaldo Carvalho de Melo
2015-11-19 17:53 ` [PATCH 25/37] perf tools: Fix to put new map after inserting to map_groups in dso__load_sym Arnaldo Carvalho de Melo
2015-11-19 17:53 ` [PATCH 26/37] perf tools: Fix __dsos__addnew to put dso after adding it to the list Arnaldo Carvalho de Melo
2015-11-19 17:53 ` [PATCH 27/37] perf tools: Fix machine__create_kernel_maps to put kernel dso refcount Arnaldo Carvalho de Melo
2015-11-19 17:53 ` [PATCH 28/37] perf machine: Fix machine__findnew_module_map to put dso Arnaldo Carvalho de Melo
2015-11-19 17:53 ` [PATCH 29/37] perf report: Support folded callchain mode on --stdio Arnaldo Carvalho de Melo
2015-11-19 17:53 ` [PATCH 30/37] perf callchain: Abstract callchain print function Arnaldo Carvalho de Melo
2015-11-19 17:53 ` [PATCH 31/37] perf callchain: Add count fields to struct callchain_node Arnaldo Carvalho de Melo
2015-11-23 14:35   ` Frederic Weisbecker
2015-11-24  5:15     ` Namhyung Kim
2015-11-19 17:53 ` [PATCH 32/37] perf report: Add callchain value option Arnaldo Carvalho de Melo
2015-11-19 17:53 ` [PATCH 33/37] perf hists browser: Factor out hist_browser__show_callchain_list() Arnaldo Carvalho de Melo
2015-11-19 17:53 ` [PATCH 34/37] perf hists browser: Support flat callchains Arnaldo Carvalho de Melo
2015-11-23 15:16   ` Frederic Weisbecker
2015-11-24  5:27     ` Namhyung Kim [this message]
2015-11-24 14:45       ` Arnaldo Carvalho de Melo
2015-11-25  1:26         ` Namhyung Kim
2015-11-25  1:34           ` Arnaldo Carvalho de Melo
2015-11-25  2:10             ` Arnaldo Carvalho de Melo
2015-11-25 21:03               ` Namhyung Kim
2015-11-19 17:53 ` [PATCH 35/37] perf hists browser: Support folded callchains Arnaldo Carvalho de Melo
2015-11-19 17:53 ` [PATCH 36/37] perf ui/gtk: Support flat callchains Arnaldo Carvalho de Melo
2015-11-19 17:53 ` [PATCH 37/37] perf ui/gtk: Support folded callchains Arnaldo Carvalho de Melo
2015-11-20 10:01 ` [GIT PULL 00/37] perf/core improvements and fixes 平松雅巳 / HIRAMATU,MASAMI
2015-11-20 12:08   ` 'Arnaldo Carvalho de Melo'
2015-11-20 16:50     ` 平松雅巳 / HIRAMATU,MASAMI
2015-11-23  8:16 ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151124052708.GB2636@sejong \
    --to=namhyung@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=andi@firstfloor.org \
    --cc=arnaldo.melo@gmail.com \
    --cc=dsahern@gmail.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox