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 <aubrey...@linux.intel.com> > --- > 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 <linux/module.h> > #include <linux/suspend.h> > #include <linux/tick.h> > +#include <linux/interrupt.h> > #include <trace/events/power.h> > > #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(); > /* >