From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753556AbdJNBLC (ORCPT ); Fri, 13 Oct 2017 21:11:02 -0400 Received: from cloudserver094114.home.net.pl ([79.96.170.134]:55918 "EHLO cloudserver094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753294AbdJNBLB (ORCPT ); Fri, 13 Oct 2017 21:11:01 -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 7/8] cpuidle: introduce irq timing to make idle prediction Date: Sat, 14 Oct 2017 03:01:28 +0200 Message-ID: <1759699.pn1NT78COC@aspire.rjw.lan> In-Reply-To: <1506756034-6340-8-git-send-email-aubrey.li@intel.com> References: <1506756034-6340-1-git-send-email-aubrey.li@intel.com> <1506756034-6340-8-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:33 AM CEST Aubrey Li wrote: > Introduce irq timings output as a factor to predict the duration > of the coming idle > > Signed-off-by: Aubrey Li > --- > drivers/cpuidle/Kconfig | 1 + > drivers/cpuidle/cpuidle.c | 17 ++++++++++++++++- > 2 files changed, 17 insertions(+), 1 deletion(-) > > diff --git a/drivers/cpuidle/Kconfig b/drivers/cpuidle/Kconfig > index 7e48eb5..8b07e1c 100644 > --- a/drivers/cpuidle/Kconfig > +++ b/drivers/cpuidle/Kconfig > @@ -5,6 +5,7 @@ config CPU_IDLE > default y if ACPI || PPC_PSERIES > select CPU_IDLE_GOV_LADDER if (!NO_HZ && !NO_HZ_IDLE) > select CPU_IDLE_GOV_MENU if (NO_HZ || NO_HZ_IDLE) > + select IRQ_TIMINGS > help > CPU idle is a generic framework for supporting software-controlled > idle processor power management. It includes modular cross-platform > diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c > index 5d4f0b6..be56cea 100644 > --- a/drivers/cpuidle/cpuidle.c > +++ b/drivers/cpuidle/cpuidle.c > @@ -22,6 +22,7 @@ > #include > #include > #include > +#include > #include > > #include "cpuidle.h" > @@ -342,13 +343,27 @@ void cpuidle_entry_end(void) > void cpuidle_predict(void) > { > struct cpuidle_device *dev = cpuidle_get_device(); > - unsigned int overhead_threshold; > + unsigned int idle_interval, overhead_threshold; > + u64 now, next_evt; > > if (!dev) > return; > > overhead_threshold = dev->idle_stat.overhead * sysctl_fast_idle_ratio; > > + /* > + * check irq timings if the next event is coming soon > + */ > + now = local_clock(); > + local_irq_disable(); > + next_evt = irq_timings_next_event(now); > + local_irq_enable(); > + idle_interval = div_u64(next_evt - now, NSEC_PER_USEC); Another division ... > + if (idle_interval < overhead_threshold) { > + dev->idle_stat.fast_idle = true; > + return; > + } > + > if (cpuidle_curr_governor->predict) { > dev->idle_stat.predicted_us = cpuidle_curr_governor->predict(); > /* >