From: Mel Gorman <mgorman@suse.de>
To: Rafael J Wysocki <rafael.j.wysocki@intel.com>,
Nicolas Pitre <nico@linaro.org>
Cc: Mike Galbraith <mgalbraith@suse.de>,
LKML <linux-kernel@vger.kernel.org>, Mel Gorman <mgorman@suse.de>
Subject: [PATCH 3/4] cpuidle: menu: Call nr_iowait_cpu less times
Date: Wed, 6 Aug 2014 14:19:20 +0100 [thread overview]
Message-ID: <1407331161-4642-4-git-send-email-mgorman@suse.de> (raw)
In-Reply-To: <1407331161-4642-1-git-send-email-mgorman@suse.de>
menu_select() via inline functions calls nr_iowait_cpu() twice as much
as necessary.
Signed-off-by: Mel Gorman <mgorman@suse.de>
---
| 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
--git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index 373278a..90d8109 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -143,7 +143,7 @@ static int get_loadavg(void)
return LOAD_INT(this) * 10 + LOAD_FRAC(this) / 10;
}
-static inline int which_bucket(unsigned int duration)
+static inline int which_bucket(unsigned int duration, unsigned long nr_iowaiters)
{
int bucket = 0;
@@ -153,7 +153,7 @@ static inline int which_bucket(unsigned int duration)
* This allows us to calculate
* E(duration)|iowait
*/
- if (nr_iowait_cpu(smp_processor_id()))
+ if (nr_iowaiters)
bucket = BUCKETS/2;
if (duration < 10)
@@ -176,7 +176,7 @@ static inline int which_bucket(unsigned int duration)
* to be, the higher this multiplier, and thus the higher
* the barrier to go to an expensive C state.
*/
-static inline int performance_multiplier(void)
+static inline int performance_multiplier(unsigned long nr_iowaiters)
{
int mult = 1;
@@ -185,7 +185,7 @@ static inline int performance_multiplier(void)
mult += 2 * get_loadavg();
/* for IO wait tasks (per cpu!) we add 5x each */
- mult += 10 * nr_iowait_cpu(smp_processor_id());
+ mult += 10 * nr_iowaiters;
return mult;
}
@@ -297,6 +297,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
int latency_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY);
int i;
unsigned int interactivity_req;
+ unsigned long nr_iowaiters;
if (data->needs_update) {
menu_update(drv, dev);
@@ -312,8 +313,8 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
/* determine the expected residency time, round up */
data->next_timer_us = ktime_to_us(tick_nohz_get_sleep_length());
-
- data->bucket = which_bucket(data->next_timer_us);
+ nr_iowaiters = nr_iowait_cpu(smp_processor_id());
+ data->bucket = which_bucket(data->next_timer_us, nr_iowaiters);
/*
* Force the result of multiplication to be 64 bits even if both
@@ -331,7 +332,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
* duration / latency ratio. Adjust the latency limit if
* necessary.
*/
- interactivity_req = data->predicted_us / performance_multiplier();
+ interactivity_req = data->predicted_us / performance_multiplier(nr_iowaiters);
if (latency_req > interactivity_req)
latency_req = interactivity_req;
--
1.8.4.5
next prev parent reply other threads:[~2014-08-06 13:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-06 13:19 [PATCH 0/4] Reduce overhead of menu governor Mel Gorman
2014-08-06 13:19 ` [PATCH 1/4] cpuidle: menu: Use shifts when calculating averages where possible Mel Gorman
2014-08-06 13:19 ` [PATCH 2/4] cpuidle: menu: Use ktime_to_us instead of reinventing the wheel Mel Gorman
2014-08-06 14:17 ` Daniel Lezcano
2014-08-06 13:19 ` Mel Gorman [this message]
2014-08-06 13:19 ` [PATCH 4/4] cpuidle: menu: Lookup CPU runqueues less Mel Gorman
2014-08-06 19:17 ` [PATCH 0/4] Reduce overhead of menu governor Rafael J. Wysocki
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=1407331161-4642-4-git-send-email-mgorman@suse.de \
--to=mgorman@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mgalbraith@suse.de \
--cc=nico@linaro.org \
--cc=rafael.j.wysocki@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
all inboxes | Powered by JetHome®