Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1538598
| From | Namhyung Kim <namhyung@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 3/6] perf sched timehist: Save callchain when entering idle |
| Date | 2016-12-08 16:00 +0100 |
| Message-ID | <sM8kW-7mt-31@gated-at.bofh.it> (permalink) |
| References | <sM8bf-7j1-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCHSET 0/6] perf sched timehist: Introduce --idle-hist option (v2) Namhyung Kim <namhyung@kernel.org> - 2016-12-08 15:50 +0100 [PATCH v2 2/6] perf sched timehist: Introduce struct idle_time_data Namhyung Kim <namhyung@kernel.org> - 2016-12-08 16:00 +0100 [PATCH v2 3/6] perf sched timehist: Save callchain when entering idle Namhyung Kim <namhyung@kernel.org> - 2016-12-08 16:00 +0100 Re: [PATCHSET 0/6] perf sched timehist: Introduce --idle-hist option (v2) David Ahern <dsahern@gmail.com> - 2016-12-10 17:40 +0100
csiph-web