Linux ACPI
 help / color / mirror / Atom feed
From: Adam Belay <abelay@novell.com>
To: Brown@vger.kernel.org, Len <len.brown@intel.com>
Cc: linux acpi <linux-acpi@vger.kernel.org>,
	linux-pm@lists.linux-foundation.org,
	Venki Pallipadi <venkatesh.pallipadi@intel.com>,
	Shaohua Li <shaohua.li@intel.com>
Subject: [PATCH 2/6] CPUIDLE: menu governor updates
Date: Tue, 21 Aug 2007 18:25:14 -0400	[thread overview]
Message-ID: <1187735114.7199.49.camel@callisto.site> (raw)

This patch tweaks the menu governor to more effectively handle non-timer
break events.  Non-timer break events are detected by comparing the
actual sleep time to the expected sleep time.  In future revisions, it
may be more reliable to use the timer data structures directly.

Please Apply,
Adam

Change Summary:
 menu.c |   46 +++++++++++++++++++++++++++++-----------------
 1 file changed, 29 insertions(+), 17 deletions(-)
---

diff -urN a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
--- a/drivers/cpuidle/governors/menu.c	2007-08-13 00:02:10.000000000 -0400
+++ b/drivers/cpuidle/governors/menu.c	2007-08-13 02:00:09.000000000 -0400
@@ -15,15 +15,19 @@
 #include <linux/tick.h>
 
 #define BM_HOLDOFF	2000	/* 2 ms */
+#define BREAK_FUZZ	4	/* 4 us */
 
 struct menu_device {
-	int	last_state_idx;
+	int		last_state_idx;
 
-	int	predicted_us;
-	int	last_measured_us;
-	int	deepest_bm_state;
-	int	bm_elapsed_us;
-	int	bm_holdoff_us;
+	unsigned int	expected_us;
+	unsigned int	predicted_us;
+	unsigned int	last_measured_us;
+	unsigned int	elapsed_us;
+
+	int		deepest_bm_state;
+	unsigned int	bm_elapsed_us;
+	unsigned int	bm_holdoff_us;
 };
 
 static DEFINE_PER_CPU(struct menu_device, menu_devices);
@@ -35,10 +39,11 @@
 static int menu_select(struct cpuidle_device *dev)
 {
 	struct menu_device *data = &__get_cpu_var(menu_devices);
-	int i, expected_us, max_state = dev->state_count;
+	int i, max_state = dev->state_count;
 
 	/* determine the expected residency time */
-	expected_us = (s32) ktime_to_ns(tick_nohz_get_sleep_length()) / 1000;
+	data->expected_us =
+		(u32) ktime_to_ns(tick_nohz_get_sleep_length()) / 1000;
 
 	/* determine the maximum state compatible with current BM status */
 	if (cpuidle_get_bm_activity())
@@ -50,7 +55,7 @@
 	for (i = 1; i < max_state; i++) {
 		struct cpuidle_state *s = &dev->states[i];
 
-		if (s->target_residency > expected_us)
+		if (s->target_residency > data->expected_us)
 			break;
 		if (s->target_residency > data->predicted_us)
 			break;
@@ -73,7 +78,8 @@
 {
 	struct menu_device *data = &__get_cpu_var(menu_devices);
 	int last_idx = data->last_state_idx;
-	int measured_us = cpuidle_get_last_residency(dev);
+	unsigned int measured_us =
+		cpuidle_get_last_residency(dev) + data->elapsed_us;
 	struct cpuidle_state *target = &dev->states[last_idx];
 
 	/*
@@ -90,8 +96,17 @@
 		data->bm_elapsed_us += measured_us;
 
 	/* Predict time remaining until next break event */
-	data->predicted_us = max(measured_us, data->last_measured_us);
-	data->last_measured_us = measured_us;
+	if (measured_us + BREAK_FUZZ < data->expected_us - target->exit_latency) {
+		data->predicted_us = max(measured_us, data->last_measured_us);
+		data->last_measured_us = measured_us;
+		data->elapsed_us = 0;
+	} else {
+		if (data->elapsed_us < data->elapsed_us + measured_us)
+			data->elapsed_us = measured_us;
+		else
+			data->elapsed_us = -1;
+		data->predicted_us = max(measured_us, data->last_measured_us);
+	}
 }
 
 /**
@@ -103,10 +118,7 @@
 	struct menu_device *data = &per_cpu(menu_devices, dev->cpu);
 	int i;
 
-	data->last_state_idx = 0;
-	data->predicted_us = 0;
-	data->last_measured_us = 0;
-	data->bm_elapsed_us = 0;
+	memset(data, 0, sizeof(struct menu_device));
 	data->bm_holdoff_us = BM_HOLDOFF;
 
 	for (i = 1; i < dev->state_count; i++)
@@ -117,7 +129,7 @@
 	return 0;
 }
 
-struct cpuidle_governor menu_governor = {
+static struct cpuidle_governor menu_governor = {
 	.name =		"menu",
 	.rating =	20,
 	.enable =	menu_enable_device,




                 reply	other threads:[~2007-08-21 22:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1187735114.7199.49.camel@callisto.site \
    --to=abelay@novell.com \
    --cc=Brown@vger.kernel.org \
    --cc=len.brown@intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=shaohua.li@intel.com \
    --cc=venkatesh.pallipadi@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox