Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1742544 > unrolled thread

[RFC PATCH v2 7/8] cpuidle: introduce irq timing to make idle prediction

Started byAubrey Li <aubrey.li@intel.com>
First post2017-09-30 09:30 +0200
Last post2017-09-30 09:30 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [RFC PATCH v2 7/8] cpuidle: introduce irq timing to make idle prediction Aubrey Li <aubrey.li@intel.com> - 2017-09-30 09:30 +0200

#1742544 — [RFC PATCH v2 7/8] cpuidle: introduce irq timing to make idle prediction

FromAubrey Li <aubrey.li@intel.com>
Date2017-09-30 09:30 +0200
Subject[RFC PATCH v2 7/8] cpuidle: introduce irq timing to make idle prediction
Message-ID<uvknM-12H-11@gated-at.bofh.it>
Introduce irq timings output as a factor to predict the duration
of the coming idle

Signed-off-by: Aubrey Li <aubrey.li@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);
+	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();
 		/*
-- 
2.7.4

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web