From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751975AbcLFEHO (ORCPT ); Mon, 5 Dec 2016 23:07:14 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:35690 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751451AbcLFEHN (ORCPT ); Mon, 5 Dec 2016 23:07:13 -0500 Subject: Re: [PATCH 06/10] perf sched timehist: Introduce struct idle_time_data To: Namhyung Kim , Arnaldo Carvalho de Melo References: <20161206034010.6499-1-namhyung@kernel.org> <20161206034010.6499-7-namhyung@kernel.org> Cc: Ingo Molnar , Peter Zijlstra , Jiri Olsa , LKML , Andi Kleen , Minchan Kim From: David Ahern Message-ID: <21a35a2f-2cdb-78d1-a42d-078f267fdc1c@gmail.com> Date: Mon, 5 Dec 2016 20:07:09 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20161206034010.6499-7-namhyung@kernel.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > } > > 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); > } > } > >