[PATCH 18/19] perf sched timehist: Print all events in verbose mode

David Ahern
2013-08-08T02:52:38Z

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

Signed-off-by: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@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