public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cpuidle: menu governor: reduce latency on exit
@ 2009-07-19 14:59 Corrado Zoccolo
  2009-07-23 22:05 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Corrado Zoccolo @ 2009-07-19 14:59 UTC (permalink / raw)
  To: venkatesh.pallipadi, abelay; +Cc: linux-pm, linux-kernel

This patch moves the state residency accounting and statistics
computation off the hot exit path.
On exit, the need to recompute statistics is recorded, and new
statistics will be computed when menu_select is called again.

Signed-off-by: Corrado Zoccolo <czoccolo@gmail.com>

---
diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index f1df59f..5e905e0 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -19,6 +19,7 @@
 
 struct menu_device {
 	int		last_state_idx;
+	int             needs_update;
 
 	unsigned int	expected_us;
 	unsigned int	predicted_us;
@@ -29,6 +30,8 @@ struct menu_device {
 
 static DEFINE_PER_CPU(struct menu_device, menu_devices);
 
+static void menu_update(struct cpuidle_device *dev);
+
 /**
  * menu_select - selects the next idle state to enter
  * @dev: the CPU
@@ -39,6 +42,11 @@ static int menu_select(struct cpuidle_device *dev)
 	int latency_req = pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY);
 	int i;
 
+	if (data->needs_update) {
+		menu_update(dev);
+		data->needs_update = 0;
+	}
+
 	/* Special case when user has set very strict latency requirement */
 	if (unlikely(latency_req == 0)) {
 		data->last_state_idx = 0;
@@ -72,7 +80,7 @@ static int menu_select(struct cpuidle_device *dev)
 }
 
 /**
- * menu_reflect - attempts to guess what happened after entry
+ * menu_reflect - records that data structures need update
  * @dev: the CPU
  *
  * NOTE: it's important to be fast here because this operation will add to
@@ -81,6 +89,16 @@ static int menu_select(struct cpuidle_device *dev)
 static void menu_reflect(struct cpuidle_device *dev)
 {
 	struct menu_device *data = &__get_cpu_var(menu_devices);
+	data->needs_update = 1;
+}
+
+/**
+ * menu_update - attempts to guess what happened after entry
+ * @dev: the CPU
+ */
+static void menu_update(struct cpuidle_device *dev)
+{
+	struct menu_device *data = &__get_cpu_var(menu_devices);
 	int last_idx = data->last_state_idx;
 	unsigned int last_idle_us = cpuidle_get_last_residency(dev);
 	struct cpuidle_state *target = &dev->states[last_idx];


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] cpuidle: menu governor: reduce latency on exit
  2009-07-19 14:59 [PATCH] cpuidle: menu governor: reduce latency on exit Corrado Zoccolo
@ 2009-07-23 22:05 ` Andrew Morton
  2009-07-24 15:41   ` Corrado Zoccolo
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2009-07-23 22:05 UTC (permalink / raw)
  To: Corrado Zoccolo; +Cc: venkatesh.pallipadi, abelay, linux-pm, linux-kernel

On Sun, 19 Jul 2009 16:59:46 +0200
Corrado Zoccolo <czoccolo@gmail.com> wrote:

> This patch moves the state residency accounting and statistics
> computation off the hot exit path.
> On exit, the need to recompute statistics is recorded, and new
> statistics will be computed when menu_select is called again.
> 

Was there any observed and/or measured effect as a result of this patch?

If so, please send a description of that effect, thanks.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cpuidle: menu governor: reduce latency on exit
  2009-07-23 22:05 ` Andrew Morton
@ 2009-07-24 15:41   ` Corrado Zoccolo
  0 siblings, 0 replies; 3+ messages in thread
From: Corrado Zoccolo @ 2009-07-24 15:41 UTC (permalink / raw)
  To: Andrew Morton; +Cc: venkatesh.pallipadi, abelay, linux-pm, linux-kernel

Hi Andrew,
the expected effect is to reduce processor wakeup latency from sleep (C-states).

We are speaking of few hundreds of cycles reduction out of a several
microseconds latency (determined by the hardware transition), so it is
difficult to measure.

Corrado

On Fri, Jul 24, 2009 at 12:05 AM, Andrew
Morton<akpm@linux-foundation.org> wrote:
> On Sun, 19 Jul 2009 16:59:46 +0200
> Corrado Zoccolo <czoccolo@gmail.com> wrote:
>
>> This patch moves the state residency accounting and statistics
>> computation off the hot exit path.
>> On exit, the need to recompute statistics is recorded, and new
>> statistics will be computed when menu_select is called again.
>>
>
> Was there any observed and/or measured effect as a result of this patch?
>
> If so, please send a description of that effect, thanks.
>
>



-- 
__________________________________________________________________________

dott. Corrado Zoccolo                          mailto:czoccolo@gmail.com
PhD - Department of Computer Science - University of Pisa, Italy
--------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-07-24 15:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-19 14:59 [PATCH] cpuidle: menu governor: reduce latency on exit Corrado Zoccolo
2009-07-23 22:05 ` Andrew Morton
2009-07-24 15:41   ` Corrado Zoccolo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox