From: Youquan Song <youquan.song@intel.com>
To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-pm@lists.linux-foundation.org, len.brown@intel.com,
akpm@linux-foundation.org
Cc: arjan@linux.intel.com, len.brown@linux.intel.com,
suresh.b.siddha@intel.com,
Youquan Song <youquan.song@linux.intel.com>,
Youquan Song <youquan.song@intel.com>
Subject: [PATCH 2/3] x86,idle: Quickly notice prediction failure in general case
Date: Fri, 11 May 2012 11:15:56 -0400 [thread overview]
Message-ID: <1336749357-9133-3-git-send-email-youquan.song@intel.com> (raw)
In-Reply-To: <1336749357-9133-2-git-send-email-youquan.song@intel.com>
The patch extends the patch to enhance the prediction for repeat mode by add a
timer when menu governor choose a shallow C-state.
The timer is set to time out in 50 milli-seconds by default. It is special twist
that there are no power saving gains even sleep longer than it.
When C-state is waken up prior to the adding timer, the timer will be cancelled
initiatively. When the timer is triggered and menu governor will quickly notice
prediction failure and re-evaluates deeper C-states possibility.
Signed-off-by: Youquan Song <youquan.song@intel.com>
---
| 48 ++++++++++++++++++++++++++------------
1 files changed, 33 insertions(+), 15 deletions(-)
--git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index 8c23fbd..9f92dd4 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -113,6 +113,13 @@ static DEFINE_PER_CPU(int, hrtimer_started);
* represented in the system load average.
*
*/
+
+/*
+ * Default set to 50 milliseconds based on special twist mentioned above that
+ * there are no power gains sleep longer than it.
+ */
+static unsigned int perfect_cstate_ms __read_mostly = 50;
+module_param(perfect_cstate_ms, uint, 0000);
struct menu_device {
int last_state_idx;
@@ -343,26 +350,37 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
data->exit_us = s->exit_latency;
}
}
-
+
+ /* not deepest C-state chosen */
if (data->last_state_idx < drv->state_count - 1) {
+ unsigned int repeat_us = 0;
+ unsigned int perfect_us = 0;
+
+ /*
+ * Set enough timer to recognize the repeat mode broken.
+ * If the timer is time out, the repeat mode prediction
+ * fails,then re-evaluate deeper C-states possibility.
+ * If the timer is not triggered, the timer will be
+ * cancelled when CPU waken up.
+ */
+ repeat_us =
+ (repeat ? (2 * data->predicted_us + MAX_DEVIATION) : 0);
+ perfect_us = perfect_cstate_ms * 1000;
/* Repeat mode detected */
- if (repeat) {
- unsigned int repeat_us = 0;
- /*
- * Set enough timer to recognize the repeat mode broken.
- * If the timer is time out, the repeat mode prediction
- * fails,then re-evaluate deeper C-states possibility.
- * If the timer is not triggered, the timer will be
- * cancelled when CPU waken up.
- */
- repeat_us = 2 * data->predicted_us + MAX_DEVIATION;
- hrtimer_start(hrtmr, ns_to_ktime(1000 * repeat_us),
- HRTIMER_MODE_REL_PINNED);
+ if (repeat && (repeat_us < perfect_us)) {
+ hrtimer_start(hrtmr, ns_to_ktime(1000 * repeat_us),
+ HRTIMER_MODE_REL_PINNED);
+ /* menu hrtimer is started */
+ per_cpu(hrtimer_started, cpu) = 1;
+ } else if (perfect_us < data->expected_us) {
+ /* expected time is larger than adding timer time */
+ hrtimer_start(hrtmr, ns_to_ktime(1000 * perfect_us),
+ HRTIMER_MODE_REL_PINNED);
/* menu hrtimer is started */
per_cpu(hrtimer_started, cpu) = 1;
- }
- }
+ }
+ }
return data->last_state_idx;
}
--
1.6.4.2
next prev parent reply other threads:[~2012-05-11 15:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-11 15:15 [PATCH 0/3] x86,idle: Enhance cpuidle prediction to handle its failure Youquan Song
2012-05-11 15:15 ` [PATCH 1/3] x86,idle: Quickly notice prediction failure for repeat mode Youquan Song
2012-05-11 15:15 ` Youquan Song [this message]
2012-05-11 15:15 ` [PATCH 3/3] x86,idle: Set residency to 0 if target Cstate not really enter Youquan Song
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=1336749357-9133-3-git-send-email-youquan.song@intel.com \
--to=youquan.song@intel.com \
--cc=akpm@linux-foundation.org \
--cc=arjan@linux.intel.com \
--cc=len.brown@intel.com \
--cc=len.brown@linux.intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=suresh.b.siddha@intel.com \
--cc=youquan.song@linux.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