public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cpuidle: don't wakeup processor when set a longer latency
@ 2013-05-08  2:44 Lianwei Wang
  2013-05-08 11:08 ` [linux-pm] " Daniel Lezcano
  0 siblings, 1 reply; 9+ messages in thread
From: Lianwei Wang @ 2013-05-08  2:44 UTC (permalink / raw)
  To: linux-kernel, linux-pm

[-- Attachment #1: Type: text/plain, Size: 1707 bytes --]

When a PM-Qos is updated, the cpuidle driver will wakeup all the CPUs
no matter what a latency is set. But actually it only need to wakeup
the CPUs when a shorter latency is set. In this way we can reduce the
cpu wakeup count and save battery.

So we can pass the prev_value to the notifier callback and check the
latency curr_value and prev_value in the cpuidle latency notifier
callback. It modify a common interface(dummy --> prev_value) but shall
be safe since no one use the dummy parameter currently.

diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index e1f6860..1e1758c 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -498,7 +498,11 @@ static void smp_callback(void *v)
 static int cpuidle_latency_notify(struct notifier_block *b,
                unsigned long l, void *v)
 {
-       smp_call_function(smp_callback, NULL, 1);
+       unsigned long prev_value = (unsigned long) v;
+
+       /* Dont't waktup processor when set a longer latency */
+       if (l < prev_value)
+               smp_call_function(smp_callback, NULL, 1);
        return NOTIFY_OK;
 }

diff --git a/kernel/power/qos.c b/kernel/power/qos.c
index 9322ff7..533b8bc 100644
--- a/kernel/power/qos.c
+++ b/kernel/power/qos.c
@@ -205,7 +205,7 @@ int pm_qos_update_target(struct pm_qos_constraints
*c, struct plist_node *node,
        if (prev_value != curr_value) {
                blocking_notifier_call_chain(c->notifiers,
                                             (unsigned long)curr_value,
-                                            NULL);
+                                            (void *)prev_value);
                return 1;
        } else {
                return 0;

[-- Attachment #2: 0001-cpuidle-don-t-wakeup-processor-when-set-a-longer-lat.patch --]
[-- Type: application/octet-stream, Size: 1708 bytes --]

From 00d5e2ddb1c56f36358be290c2104e9feec84465 Mon Sep 17 00:00:00 2001
From: Lianwei Wang <lianwei.wang@gmail.com>
Date: Fri, 26 Apr 2013 10:59:24 +0800
Subject: [PATCH] cpuidle: don't wakeup processor when set a longer latency

We don't need wakeup the other CPUs immediately if a longer latency
is set. Pass the prev_value to the notifier callback so the latency
can be checked in cpuidle driver and only wakeup all the other CPUs
when a shorter latency is set.

Change-Id: If564fd0d9c53cf100bd85247bfd509dfeaf54c13
Signed-off-by: Lianwei Wang <lianwei.wang@gmail.com>
---
 drivers/cpuidle/cpuidle.c |    6 +++++-
 kernel/power/qos.c        |    2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index e1f6860..1e1758c 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -498,7 +498,11 @@ static void smp_callback(void *v)
 static int cpuidle_latency_notify(struct notifier_block *b,
 		unsigned long l, void *v)
 {
-	smp_call_function(smp_callback, NULL, 1);
+	unsigned long prev_value = (unsigned long) v;
+
+	/* Dont't waktup processor when set a longer latency */
+	if (l < prev_value)
+		smp_call_function(smp_callback, NULL, 1);
 	return NOTIFY_OK;
 }
 
diff --git a/kernel/power/qos.c b/kernel/power/qos.c
index 9322ff7..533b8bc 100644
--- a/kernel/power/qos.c
+++ b/kernel/power/qos.c
@@ -205,7 +205,7 @@ int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node,
 	if (prev_value != curr_value) {
 		blocking_notifier_call_chain(c->notifiers,
 					     (unsigned long)curr_value,
-					     NULL);
+					     (void *)prev_value);
 		return 1;
 	} else {
 		return 0;
-- 
1.7.4.1


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

end of thread, other threads:[~2013-05-13 20:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-08  2:44 [PATCH] cpuidle: don't wakeup processor when set a longer latency Lianwei Wang
2013-05-08 11:08 ` [linux-pm] " Daniel Lezcano
2013-05-09  7:14   ` Lianwei Wang
2013-05-09 23:45     ` Daniel Lezcano
2013-05-13  6:52       ` Lianwei Wang
2013-05-13  7:46         ` Lianwei Wang
2013-05-13  9:04         ` Srivatsa S. Bhat
2013-05-13 15:25           ` Daniel Lezcano
2013-05-13 20:27             ` Srivatsa S. Bhat

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