From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752641AbcLFDme (ORCPT ); Mon, 5 Dec 2016 22:42:34 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:35193 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752121AbcLFDlf (ORCPT ); Mon, 5 Dec 2016 22:41:35 -0500 From: Namhyung Kim To: Arnaldo Carvalho de Melo Cc: Ingo Molnar , Peter Zijlstra , Jiri Olsa , LKML , David Ahern , Andi Kleen , Minchan Kim Subject: [PATCH 06/10] perf sched timehist: Introduce struct idle_time_data Date: Tue, 6 Dec 2016 12:40:06 +0900 Message-Id: <20161206034010.6499-7-namhyung@kernel.org> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161206034010.6499-1-namhyung@kernel.org> References: <20161206034010.6499-1-namhyung@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The struct idle_time_data is to keep idle stats with callchains entering to the idle task. The normal thread_runtime calculation is done transparently since it extends the struct thread_runtime. Signed-off-by: Namhyung Kim --- tools/perf/builtin-sched.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 26efa99567b8..d3ee814ce77f 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -230,6 +230,15 @@ struct evsel_runtime { u32 ncpu; /* highest cpu slot allocated */ }; +/* per cpu idle time data */ +struct idle_thread_runtime { + struct thread_runtime tr; + struct thread *last_thread; + struct rb_root sorted_root; + struct callchain_root callchain; + struct callchain_cursor cursor; +}; + /* track idle times per cpu */ static struct thread **idle_threads; static int idle_max_cpu; @@ -2009,11 +2018,22 @@ static int init_idle_threads(int ncpu) /* allocate the actual thread struct if needed */ for (i = 0; i < ncpu; ++i) { + struct idle_thread_runtime *itr; + idle_threads[i] = thread__new(0, 0); if (idle_threads[i] == NULL) return -ENOMEM; thread__set_comm(idle_threads[i], idle_comm, 0); + + itr = zalloc(sizeof(*itr)); + if (itr == NULL) + return -ENOMEM; + + init_stats(&itr->tr.run_stats); + callchain_init(&itr->callchain); + callchain_cursor_reset(&itr->cursor); + thread__set_priv(idle_threads[i], itr); } return 0; @@ -2060,8 +2080,19 @@ static struct thread *get_idle_thread(int cpu) idle_threads[cpu] = thread__new(0, 0); if (idle_threads[cpu]) { + struct idle_thread_runtime *itr; + idle_threads[cpu]->tid = 0; thread__set_comm(idle_threads[cpu], idle_comm, 0); + + itr = zalloc(sizeof(*itr)); + if (itr == NULL) + return NULL; + + init_stats(&itr->tr.run_stats); + callchain_init(&itr->callchain); + callchain_cursor_reset(&itr->cursor); + thread__set_priv(idle_threads[cpu], itr); } } -- 2.10.1