Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1528588

[PATCH 13/18] perf evsel: Support printing callchains with arrows

From Arnaldo Carvalho de Melo <acme@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 13/18] perf evsel: Support printing callchains with arrows
Date 2016-11-23 17:50 +0100
Message-ID <sGIUa-7ig-43@gated-at.bofh.it> (permalink)
References <sGIU9-7ig-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Namhyung Kim <namhyung@kernel.org>

The EVSEL__PRINT_CALLCHAIN_ARROW options can be used to print callchains
with arrows for readability.  It will be used 'sched timehist' command
like below:

    __schedule <- schedule <- schedule_timeout <- rcu_gp_kthread <- kthread <- ret_from_fork
    __schedule <- schedule <- schedule_timeout <- rcu_gp_kthread <- kthread <- ret_from_fork
    __schedule <- schedule <- worker_thread <- kthread <- ret_from_fork

Suggested-and-Acked-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/20161116060634.28477-3-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evsel.h         | 1 +
 tools/perf/util/evsel_fprintf.c | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 8cd7cd227483..27fa3a343577 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -391,6 +391,7 @@ int perf_evsel__fprintf(struct perf_evsel *evsel,
 #define EVSEL__PRINT_ONELINE		(1<<4)
 #define EVSEL__PRINT_SRCLINE		(1<<5)
 #define EVSEL__PRINT_UNKNOWN_AS_ADDR	(1<<6)
+#define EVSEL__PRINT_CALLCHAIN_ARROW	(1<<7)
 
 struct callchain_cursor;
 
diff --git a/tools/perf/util/evsel_fprintf.c b/tools/perf/util/evsel_fprintf.c
index ccb602397b60..53bb614feafb 100644
--- a/tools/perf/util/evsel_fprintf.c
+++ b/tools/perf/util/evsel_fprintf.c
@@ -108,7 +108,9 @@ int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment,
 	int print_oneline = print_opts & EVSEL__PRINT_ONELINE;
 	int print_srcline = print_opts & EVSEL__PRINT_SRCLINE;
 	int print_unknown_as_addr = print_opts & EVSEL__PRINT_UNKNOWN_AS_ADDR;
+	int print_arrow = print_opts & EVSEL__PRINT_CALLCHAIN_ARROW;
 	char s = print_oneline ? ' ' : '\t';
+	bool first = true;
 
 	if (sample->callchain) {
 		struct addr_location node_al;
@@ -124,6 +126,9 @@ int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment,
 
 			printed += fprintf(fp, "%-*.*s", left_alignment, left_alignment, " ");
 
+			if (print_arrow && !first)
+				printed += fprintf(fp, " <-");
+
 			if (print_ip)
 				printed += fprintf(fp, "%c%16" PRIx64, s, node->ip);
 
@@ -158,6 +163,7 @@ int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment,
 				printed += fprintf(fp, "\n");
 
 			callchain_cursor_advance(cursor);
+			first = false;
 		}
 	}
 
-- 
2.7.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[GIT PULL 00/18] perf/core improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-11-23 17:50 +0100
  [PATCH 12/18] perf symbols: Print symbol offsets conditionally Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-11-23 17:50 +0100
  [PATCH 06/18] perf tools: Show event fd in debug output Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-11-23 17:50 +0100
  [PATCH 11/18] perf c2c: Support cascading options Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-11-23 17:50 +0100
  [PATCH 13/18] perf evsel: Support printing callchains with arrows Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-11-23 17:50 +0100
  [PATCH 14/18] perf sched timehist: Introduce timehist command Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-11-23 17:50 +0100
  [PATCH 10/18] perf c2c report: Display total HITMs on default Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-11-23 17:50 +0100
  [PATCH 01/18] perf annotate: Start supporting cross arch annotation Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-11-23 17:50 +0100
  [PATCH 02/18] perf annotate: Allow arches to specify functions to skip Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-11-23 17:50 +0100
  [PATCH 03/18] perf annotate: Add per arch instructions annotate handlers Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-11-23 17:50 +0100
  [PATCH 17/18] perf sched timehist: Add call graph options Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-11-23 17:50 +0100
  [PATCH 15/18] perf sched timehist: Add summary options Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-11-23 17:50 +0100
  Re: [GIT PULL 00/18] perf/core improvements and fixes Ingo Molnar <mingo@kernel.org> - 2016-11-24 05:20 +0100

csiph-web