From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753521AbdJNBMa (ORCPT ); Fri, 13 Oct 2017 21:12:30 -0400 Received: from cloudserver094114.home.net.pl ([79.96.170.134]:55581 "EHLO cloudserver094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753250AbdJNBM3 (ORCPT ); Fri, 13 Oct 2017 21:12:29 -0400 From: "Rafael J. Wysocki" To: Aubrey Li Cc: tglx@linutronix.de, peterz@infradead.org, len.brown@intel.com, ak@linux.intel.com, tim.c.chen@linux.intel.com, x86@kernel.org, linux-kernel@vger.kernel.org, Aubrey Li Subject: Re: [RFC PATCH v2 8/8] cpuidle: introduce run queue average idle to make idle prediction Date: Sat, 14 Oct 2017 03:02:56 +0200 Message-ID: <1678239.jONkSWAMNZ@aspire.rjw.lan> In-Reply-To: <1506756034-6340-9-git-send-email-aubrey.li@intel.com> References: <1506756034-6340-1-git-send-email-aubrey.li@intel.com> <1506756034-6340-9-git-send-email-aubrey.li@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Saturday, September 30, 2017 9:20:34 AM CEST Aubrey Li wrote: > Introduce run queue average idle in scheduler as a factor to make > idle prediction > > Signed-off-by: Aubrey Li > --- > drivers/cpuidle/cpuidle.c | 12 ++++++++++++ > include/linux/cpuidle.h | 1 + > kernel/sched/idle.c | 5 +++++ > 3 files changed, 18 insertions(+) > > diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c > index be56cea..9424a2d 100644 > --- a/drivers/cpuidle/cpuidle.c > +++ b/drivers/cpuidle/cpuidle.c > @@ -364,6 +364,18 @@ void cpuidle_predict(void) > return; > } > > + /* > + * check scheduler if the coming idle is likely a fast idle > + */ > + idle_interval = div_u64(sched_idle_avg(), NSEC_PER_USEC); And one more division ... > + if (idle_interval < overhead_threshold) { > + dev->idle_stat.fast_idle = true; > + return; > + } > + > + /* > + * check the idle governor if the coming idle is likely a fast idle > + */ > if (cpuidle_curr_governor->predict) { > dev->idle_stat.predicted_us = cpuidle_curr_governor->predict(); > /* > diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h > index 45b8264..387d72b 100644 > --- a/include/linux/cpuidle.h > +++ b/include/linux/cpuidle.h > @@ -234,6 +234,7 @@ static inline void cpuidle_use_deepest_state(bool enable) > /* kernel/sched/idle.c */ > extern void sched_idle_set_state(struct cpuidle_state *idle_state); > extern void default_idle_call(void); > +extern u64 sched_idle_avg(void); > > #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED > void cpuidle_coupled_parallel_barrier(struct cpuidle_device *dev, atomic_t *a); > diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c > index 8704f3c..d23b472 100644 > --- a/kernel/sched/idle.c > +++ b/kernel/sched/idle.c > @@ -30,6 +30,11 @@ void sched_idle_set_state(struct cpuidle_state *idle_state) > idle_set_state(this_rq(), idle_state); > } > > +u64 sched_idle_avg(void) > +{ > + return this_rq()->avg_idle; > +} > + > static int __read_mostly cpu_idle_force_poll; > > void cpu_idle_poll_ctrl(bool enable) > You could easily combine this patch with the previous one IMO.