Skip to content

Commit

Permalink
cpuidle: menu: Call nr_iowait_cpu less times
Browse files Browse the repository at this point in the history
menu_select() via inline functions calls nr_iowait_cpu() twice as much
as necessary.

Signed-off-by: Mel Gorman <mgorman@suse.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Mel Gorman authored and Rafael J. Wysocki committed Aug 6, 2014
1 parent 107d4f4 commit 64b4ca5
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions drivers/cpuidle/governors/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,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;

Expand All @@ -152,7 +152,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)
Expand All @@ -175,7 +175,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;

Expand All @@ -184,7 +184,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;
}
Expand Down Expand Up @@ -296,6 +296,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);
Expand All @@ -311,8 +312,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
Expand All @@ -330,7 +331,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;

Expand Down

0 comments on commit 64b4ca5

Please sign in to comment.