From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752125AbcLGCMu (ORCPT ); Tue, 6 Dec 2016 21:12:50 -0500 Received: from LGEAMRELO12.lge.com ([156.147.23.52]:48574 "EHLO lgeamrelo12.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751488AbcLGCMt (ORCPT ); Tue, 6 Dec 2016 21:12:49 -0500 X-Original-SENDERIP: 156.147.1.121 X-Original-MAILFROM: namhyung@kernel.org X-Original-SENDERIP: 165.244.249.25 X-Original-MAILFROM: namhyung@kernel.org X-Original-SENDERIP: 10.177.227.17 X-Original-MAILFROM: namhyung@kernel.org Date: Wed, 7 Dec 2016 11:12:32 +0900 From: Namhyung Kim To: David Ahern CC: Arnaldo Carvalho de Melo , Ingo Molnar , Peter Zijlstra , Jiri Olsa , LKML , Andi Kleen , Minchan Kim Subject: Re: [PATCH 06/10] perf sched timehist: Introduce struct idle_time_data Message-ID: <20161207021232.GC17879@sejong> References: <20161206034010.6499-1-namhyung@kernel.org> <20161206034010.6499-7-namhyung@kernel.org> <21a35a2f-2cdb-78d1-a42d-078f267fdc1c@gmail.com> MIME-Version: 1.0 In-Reply-To: <21a35a2f-2cdb-78d1-a42d-078f267fdc1c@gmail.com> User-Agent: Mutt/1.7.1 (2016-10-04) X-MIMETrack: Itemize by SMTP Server on LGEKRMHUB05/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2016/12/07 11:12:35, Serialize by Router on LGEKRMHUB05/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2016/12/07 11:12:45, Serialize complete at 2016/12/07 11:12:45 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 On Mon, Dec 05, 2016 at 08:07:09PM -0800, David Ahern wrote: > On 12/5/16 7:40 PM, Namhyung Kim wrote: > > 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); > > perhaps the common lines above should be put into init_idle_thread() > and called in both places to init a single idle thread instance. Will change. Thanks, Namhyung > > > > } > > > > 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); > > } > > } > > > > >