linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: rob.lee@linaro.org (Robert Lee)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH] cpuidle: avoid unnecessary expensive governor processing
Date: Tue,  6 Mar 2012 21:42:18 -0600	[thread overview]
Message-ID: <1331091738-26322-1-git-send-email-rob.lee@linaro.org> (raw)

There a few cases when a platform's cpuidle_device will only have one
cpuidle state.  e.g., when a single idle state system uses cpuidle
to provide sysfs staticstics for profiling (powertop, etc).  This can
also be the case for coupled smp system implementations that keep
all but one cpuidle_device at a state_count of 1, but they still want
to export idle statistics for these states using cpuidle.

Signed-off-by: Robert Lee <rob.lee@linaro.org>
---
 drivers/cpuidle/governors/ladder.c |    7 +++++--
 drivers/cpuidle/governors/menu.c   |    7 +++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/cpuidle/governors/ladder.c b/drivers/cpuidle/governors/ladder.c
index b6a09ea..13abdba 100644
--- a/drivers/cpuidle/governors/ladder.c
+++ b/drivers/cpuidle/governors/ladder.c
@@ -71,8 +71,11 @@ static int ladder_select_state(struct cpuidle_driver *drv,
 	int last_residency, last_idx = ldev->last_state_idx;
 	int latency_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY);
 
-	/* Special case when user has set very strict latency requirement */
-	if (unlikely(latency_req == 0)) {
+	/*
+	 * Special case when user has set very strict latency requirement or
+	 * there is currently only one state for this device.
+	 */
+	if ((latency_req == 0) || (dev->state_count == 1)) {
 		ladder_do_selection(ldev, last_idx, 0);
 		return 0;
 	}
diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index ad09526..80eb606 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -249,8 +249,11 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
 	data->last_state_idx = 0;
 	data->exit_us = 0;
 
-	/* Special case when user has set very strict latency requirement */
-	if (unlikely(latency_req == 0))
+	/*
+	 * Special case when user has set very strict latency requirement or
+	 * there is currently only one state for this device.
+	 */
+	if ((latency_req == 0) || (dev->state_count == 1))
 		return 0;
 
 	/* determine the expected residency time, round up */
-- 
1.7.1

                 reply	other threads:[~2012-03-07  3:42 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=1331091738-26322-1-git-send-email-rob.lee@linaro.org \
    --to=rob.lee@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).