From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965160AbcLTTXM (ORCPT ); Tue, 20 Dec 2016 14:23:12 -0500 Received: from terminus.zytor.com ([198.137.202.10]:35350 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965120AbcLTTW4 (ORCPT ); Tue, 20 Dec 2016 14:22:56 -0500 Date: Tue, 20 Dec 2016 11:20:33 -0800 From: tip-bot for Namhyung Kim Message-ID: Cc: linux-kernel@vger.kernel.org, andi@firstfloor.org, peterz@infradead.org, acme@redhat.com, dsahern@gmail.com, namhyung@kernel.org, hpa@zytor.com, minchan@kernel.org, jolsa@kernel.org, mingo@kernel.org, tglx@linutronix.de Reply-To: minchan@kernel.org, hpa@zytor.com, tglx@linutronix.de, mingo@kernel.org, jolsa@kernel.org, namhyung@kernel.org, dsahern@gmail.com, acme@redhat.com, peterz@infradead.org, andi@firstfloor.org, linux-kernel@vger.kernel.org In-Reply-To: <20161213080632.19099-1-namhyung@kernel.org> References: <20161208144755.16673-4-namhyung@kernel.org> <20161213080632.19099-1-namhyung@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf sched timehist: Save callchain when entering idle Git-Commit-ID: 699b5b920db04a6ff5c03a519e4c182aeb350952 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 699b5b920db04a6ff5c03a519e4c182aeb350952 Gitweb: http://git.kernel.org/tip/699b5b920db04a6ff5c03a519e4c182aeb350952 Author: Namhyung Kim AuthorDate: Thu, 8 Dec 2016 23:47:52 +0900 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 15 Dec 2016 16:25:44 -0300 perf sched timehist: Save callchain when entering idle In order to investigate the idleness reason, it is necessary to keep the callchains when entering idle. This can be identified by the sched:sched_switch event having the next_pid field as 0. Signed-off-by: Namhyung Kim Acked-by: David Ahern Cc: Andi Kleen Cc: Jiri Olsa Cc: Minchan Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20161208144755.16673-4-namhyung@kernel.org Link: http://lkml.kernel.org/r/20161213080632.19099-1-namhyung@kernel.org [ Merged fix from Namhyung, see second Link: tag ] Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-sched.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index e108b0f..dc83b80 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,15 @@ static struct thread *get_idle_thread(int cpu) return idle_threads[cpu]; } +static void save_idle_callchain(struct idle_thread_runtime *itr, + struct perf_sample *sample) +{ + if (!symbol_conf.use_callchain || sample->callchain == NULL) + return; + + callchain_cursor__copy(&itr->cursor, &callchain_cursor); +} + /* * handle runtime stats saved per thread */ @@ -2154,6 +2164,26 @@ static struct thread *timehist_get_thread(struct perf_sched *sched, } save_task_callchain(sched, sample, evsel, machine); + if (sched->idle_hist) { + struct thread *idle; + struct idle_thread_runtime *itr; + + idle = get_idle_thread(sample->cpu); + if (idle == NULL) { + pr_err("Failed to get idle thread for cpu %d.\n", sample->cpu); + return NULL; + } + + itr = thread__priv(idle); + if (itr == NULL) + return NULL; + + itr->last_thread = thread; + + /* copy task callchain when entering to idle */ + if (perf_evsel__intval(evsel, sample, "next_pid") == 0) + save_idle_callchain(itr, sample); + } } return thread;