Useful for debugging and correlating extra events in a file with
the scheduling events collected.

Signed-off-by: David Ahern <dsah...@gmail.com>
Cc: Frederic Weisbecker <fweis...@gmail.com>
Cc: Ingo Molnar <mi...@kernel.org>
Cc: Jiri Olsa <jo...@redhat.com>
Cc: Mike Galbraith <efa...@gmx.de>
Cc: Namhyung Kim <namhy...@kernel.org>
Cc: Peter Zijlstra <pet...@infradead.org>
Cc: Stephane Eranian <eran...@google.com>
---
 tools/perf/builtin-sched.c |   57 ++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 53 insertions(+), 4 deletions(-)

diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index f5e98f1..1be9081 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1897,6 +1897,50 @@ static struct thread *timehist_get_thread(struct 
perf_evsel *evsel,
        return thread;
 }
 
+static void timehist_print_sched_event(struct perf_tool *tool,
+                              struct perf_evsel *evsel,
+                              struct perf_sample *sample,
+                              struct machine *machine)
+{
+       struct perf_sched *sched = container_of(tool, struct perf_sched, tool);
+       struct thread *thread;
+       struct thread_runtime *tr;
+       const char *evname;
+       char tstr[64];
+
+       thread = machine__findnew_thread(machine, sample->tid);
+       if (thread == NULL)
+               return;
+
+       tr = thread__priv(thread);
+       if (tr == NULL) {
+               tr = thread__init_runtime(thread, sample->pid);
+               if (tr == NULL)
+                       return;
+       }
+
+       printf("%15s ", timehist_time_str(tstr, sizeof(tstr), sample->time));
+       printf("[%02d] ", sample->cpu);
+       if (sched->show_cpu_visual && sched->max_cpu)
+               printf("%*s  ", sched->max_cpu, "");
+
+       printf("%-*s ", comm_width, tr->commstr);
+
+       /* dt spacer */
+       printf(" %9s %9s ", "", "");
+
+       evname = perf_evsel__name(evsel);
+       printf("%s ", evname ? evname : "[unknown]");
+       if (evsel->attr.type == PERF_TYPE_TRACEPOINT) {
+               event_format__print(evsel->tp_format, sample->cpu,
+                                   sample->raw_data, sample->raw_size);
+       }
+
+       printf("\n");
+
+       return;
+}
+
 static int timehist_sched_change_event(struct perf_tool *tool,
                                       struct perf_evsel *evsel,
                                       struct perf_sample *sample,
@@ -2079,12 +2123,14 @@ static void timehist_print_summary(struct perf_session 
*session)
        printf_nsecs(total_run_time, 2);
        printf("\n");
 }
+
 static int perf_timehist__process_sample(struct perf_tool *tool,
-                                        union perf_event *event,
-                                        struct perf_sample *sample,
-                                        struct perf_evsel *evsel,
-                                        struct machine *machine)
+                                                union perf_event *event,
+                                                struct perf_sample *sample,
+                                                struct perf_evsel *evsel,
+                                                struct machine *machine)
 {
+       struct perf_sched *sched = container_of(tool, struct perf_sched, tool);
        int err = 0;
 
        evsel->hists.stats.total_period += sample->period;
@@ -2094,6 +2140,9 @@ static int perf_timehist__process_sample(struct perf_tool 
*tool,
                tracepoint_handler f = evsel->handler.func;
                evsel->handler.data = event;
 
+               if (sched->show_events && verbose)
+                       timehist_print_sched_event(tool, evsel, sample, 
machine);
+
                if (f)
                        err = f(tool, evsel, sample, machine);
        }
-- 
1.7.10.1

--
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