From 6f8d67fa0c6bdca535ecab137c44b095023cc1b4 Mon Sep 17 00:00:00 2001 From: Stanislav Fomichev Date: Fri, 1 Nov 2013 20:25:51 +0400 Subject: perf timechart: Add backtrace support Add -g flag to `perf timechart record` which saves callchain info in the perf.data. When generating SVG, add backtrace information to the figure details, so now it's possible to see which code path woke up the task and why some task went to sleep. Signed-off-by: Stanislav Fomichev Acked-by: Namhyung Kim Cc: Ingo Molnar Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1383323151-19810-8-git-send-email-stfomichev@yandex-team.ru Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/svghelper.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'tools/perf/util/svghelper.c') diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c index 9a5b41392e01..8b79d3ad1246 100644 --- a/tools/perf/util/svghelper.c +++ b/tools/perf/util/svghelper.c @@ -130,7 +130,7 @@ void svg_box(int Yslot, u64 start, u64 end, const char *type) } static char *time_to_string(u64 duration); -void svg_blocked(int Yslot, int cpu, u64 start, u64 end) +void svg_blocked(int Yslot, int cpu, u64 start, u64 end, const char *backtrace) { if (!svgfile) return; @@ -138,11 +138,13 @@ void svg_blocked(int Yslot, int cpu, u64 start, u64 end) fprintf(svgfile, "\n"); fprintf(svgfile, "#%d blocked %s\n", cpu, time_to_string(end - start)); + if (backtrace) + fprintf(svgfile, "Blocked on:\n%s\n", backtrace); svg_box(Yslot, start, end, "blocked"); fprintf(svgfile, "\n"); } -void svg_running(int Yslot, int cpu, u64 start, u64 end) +void svg_running(int Yslot, int cpu, u64 start, u64 end, const char *backtrace) { double text_size; if (!svgfile) @@ -152,6 +154,8 @@ void svg_running(int Yslot, int cpu, u64 start, u64 end) fprintf(svgfile, "#%d running %s\n", cpu, time_to_string(end - start)); + if (backtrace) + fprintf(svgfile, "Switched because:\n%s\n", backtrace); fprintf(svgfile, "\n", time2pixels(start), time2pixels(end)-time2pixels(start), Yslot * SLOT_MULT, SLOT_HEIGHT); @@ -187,7 +191,7 @@ static char *time_to_string(u64 duration) return text; } -void svg_waiting(int Yslot, int cpu, u64 start, u64 end) +void svg_waiting(int Yslot, int cpu, u64 start, u64 end, const char *backtrace) { char *text; const char *style; @@ -212,6 +216,8 @@ void svg_waiting(int Yslot, int cpu, u64 start, u64 end) fprintf(svgfile, "\n", time2pixels(start), Yslot * SLOT_MULT); fprintf(svgfile, "#%d waiting %s\n", cpu, time_to_string(end - start)); + if (backtrace) + fprintf(svgfile, "Waiting on:\n%s\n", backtrace); fprintf(svgfile, "\n", time2pixels(end)-time2pixels(start), SLOT_HEIGHT, style); if (font_size > MIN_TEXT_SIZE) @@ -382,7 +388,7 @@ void svg_pstate(int cpu, u64 start, u64 end, u64 freq) } -void svg_partial_wakeline(u64 start, int row1, char *desc1, int row2, char *desc2) +void svg_partial_wakeline(u64 start, int row1, char *desc1, int row2, char *desc2, const char *backtrace) { double height; @@ -396,6 +402,9 @@ void svg_partial_wakeline(u64 start, int row1, char *desc1, int row2, char *desc desc1 ? desc1 : "?", desc2 ? desc2 : "?"); + if (backtrace) + fprintf(svgfile, "%s\n", backtrace); + if (row1 < row2) { if (row1) { fprintf(svgfile, "\n", @@ -437,7 +446,7 @@ void svg_partial_wakeline(u64 start, int row1, char *desc1, int row2, char *desc fprintf(svgfile, "\n"); } -void svg_wakeline(u64 start, int row1, int row2) +void svg_wakeline(u64 start, int row1, int row2, const char *backtrace) { double height; @@ -447,6 +456,9 @@ void svg_wakeline(u64 start, int row1, int row2) fprintf(svgfile, "\n"); + if (backtrace) + fprintf(svgfile, "%s\n", backtrace); + if (row1 < row2) fprintf(svgfile, "\n", time2pixels(start), row1 * SLOT_MULT + SLOT_HEIGHT, time2pixels(start), row2 * SLOT_MULT); @@ -463,7 +475,7 @@ void svg_wakeline(u64 start, int row1, int row2) fprintf(svgfile, "\n"); } -void svg_interrupt(u64 start, int row) +void svg_interrupt(u64 start, int row, const char *backtrace) { if (!svgfile) return; @@ -472,6 +484,9 @@ void svg_interrupt(u64 start, int row) fprintf(svgfile, "Wakeup from interrupt\n"); + if (backtrace) + fprintf(svgfile, "%s\n", backtrace); + fprintf(svgfile, "\n", time2pixels(start), row * SLOT_MULT); fprintf(svgfile, "\n", -- cgit v1.2.3