Messages in this thread Patch in this message | | | From | Namhyung Kim <> | Subject | [PATCH v2 3/6] perf sched timehist: Save callchain when entering idle | Date | Thu, 8 Dec 2016 23:47:52 +0900 |
| |
In order to investigate reason of idle, it needs to keep the callchains when entering to idle. This can be identified sched_switch event having next_pid as 0.
Signed-off-by: Namhyung Kim <namhyung@kernel.org> --- tools/perf/builtin-sched.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 6f0687dd392d..4c5c58ce8958 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -200,6 +200,7 @@ struct perf_sched { /* options for timehist command */ bool summary; bool summary_only; + bool idle_hist; bool show_callchain; unsigned int max_stack; bool show_cpu_visual; @@ -2101,6 +2102,29 @@ static struct thread *get_idle_thread(int cpu) return idle_threads[cpu]; } +static void save_idle_callchain(struct thread *thread, + struct perf_sample *sample) +{ + struct thread *idle; + struct idle_thread_runtime *itr; + + if (!symbol_conf.use_callchain || sample->callchain == NULL) + return; + + idle = get_idle_thread(sample->cpu); + if (idle == NULL) { + pr_err("Failed to get idle thread for cpu %d.\n", sample->cpu); + return; + } + + itr = thread__priv(idle); + if (itr == NULL) + return; + + itr->last_thread = thread; + callchain_cursor__copy(&itr->cursor, &callchain_cursor); +} + /* * handle runtime stats saved per thread */ @@ -2154,6 +2178,11 @@ static struct thread *timehist_get_thread(struct perf_sched *sched, } save_task_callchain(sched, sample, evsel, machine); + if (sched->idle_hist) { + /* copy task callchain when entering to idle */ + if (perf_evsel__intval(evsel, sample, "next_pid") == 0) + save_idle_callchain(thread, sample); + } } return thread; -- 2.10.1
| |