linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf tools: Fix to put caller above callee in children mode
@ 2017-05-22 12:50 Namhyung Kim
  2017-05-23  7:30 ` Jiri Olsa
  0 siblings, 1 reply; 2+ messages in thread
From: Namhyung Kim @ 2017-05-22 12:50 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ingo Molnar, Peter Zijlstra, Jiri Olsa, LKML, kernel-team,
	Frederic Weisbecker, Milian Wolff

The __hpp__sort_acc() sorts entries using callchain depth in order to
put callers above in children mode.  But it assumed the callchain order
was callee-first.  Now default (for children) is caller-first so the
order of entries is reverted.

For example, consider following case.

  $ perf report --no-children
  ..l
  # Overhead  Command  Shared Object        Symbol
  # ........  .......  ...................  ..........................
  #
      99.44%  a.out    a.out                [.] main
              |
              ---main
                 __libc_start_main
                 _start

Then children mode should show 'start' above '__libc_start_main' since
it's the caller (parent) of the __libc_start_main.  But it's reversed:

  # Children      Self  Command  Shared Object    Symbol
  # ........  ........  .......  ...............  .....................
  #
      99.61%     0.00%  a.out    libc-2.25.so     [.] __libc_start_main
      99.61%     0.00%  a.out    a.out            [.] _start
      99.54%    99.44%  a.out    a.out            [.] main

This patch fixes it.

  # Children      Self  Command  Shared Object    Symbol
  # ........  ........  .......  ...............  .....................
  #
      99.61%     0.00%  a.out    a.out            [.] _start
      99.61%     0.00%  a.out    libc-2.25.so     [.] __libc_start_main
      99.54%    99.44%  a.out    a.out            [.] main

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Milian Wolff <milian.wolff@kdab.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/ui/hist.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 59addd52d9cd..ddb2c6fbdf91 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -210,6 +210,8 @@ static int __hpp__sort_acc(struct hist_entry *a, struct hist_entry *b,
 			return 0;
 
 		ret = b->callchain->max_depth - a->callchain->max_depth;
+		if (callchain_param.order == ORDER_CALLER)
+			ret = -ret;
 	}
 	return ret;
 }
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] perf tools: Fix to put caller above callee in children mode
  2017-05-22 12:50 [PATCH] perf tools: Fix to put caller above callee in children mode Namhyung Kim
@ 2017-05-23  7:30 ` Jiri Olsa
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Olsa @ 2017-05-23  7:30 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, Peter Zijlstra, Jiri Olsa,
	LKML, kernel-team, Frederic Weisbecker, Milian Wolff

On Mon, May 22, 2017 at 09:50:29PM +0900, Namhyung Kim wrote:
> The __hpp__sort_acc() sorts entries using callchain depth in order to
> put callers above in children mode.  But it assumed the callchain order
> was callee-first.  Now default (for children) is caller-first so the
> order of entries is reverted.
> 
> For example, consider following case.
> 
>   $ perf report --no-children
>   ..l
>   # Overhead  Command  Shared Object        Symbol
>   # ........  .......  ...................  ..........................
>   #
>       99.44%  a.out    a.out                [.] main
>               |
>               ---main
>                  __libc_start_main
>                  _start
> 
> Then children mode should show 'start' above '__libc_start_main' since
> it's the caller (parent) of the __libc_start_main.  But it's reversed:
> 
>   # Children      Self  Command  Shared Object    Symbol
>   # ........  ........  .......  ...............  .....................
>   #
>       99.61%     0.00%  a.out    libc-2.25.so     [.] __libc_start_main
>       99.61%     0.00%  a.out    a.out            [.] _start
>       99.54%    99.44%  a.out    a.out            [.] main
> 
> This patch fixes it.
> 
>   # Children      Self  Command  Shared Object    Symbol
>   # ........  ........  .......  ...............  .....................
>   #
>       99.61%     0.00%  a.out    a.out            [.] _start
>       99.61%     0.00%  a.out    libc-2.25.so     [.] __libc_start_main
>       99.54%    99.44%  a.out    a.out            [.] main
> 
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Milian Wolff <milian.wolff@kdab.com>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-05-23  7:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-22 12:50 [PATCH] perf tools: Fix to put caller above callee in children mode Namhyung Kim
2017-05-23  7:30 ` Jiri Olsa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).