Skip to content

Commit 96e9518

Browse files
tuukka.tikkanen@linaro.orgrafaeljw
authored andcommitted
cpuidle: Move perf multiplier calculation out of the selection loop
The menu governor performance multiplier defines a minimum predicted idle duration to latency ratio. Instead of checking this separately in every iteration of the state selection loop, adjust the overall latency restriction for the whole loop if this restriction is tighter than what is set by the QoS subsystem. The original test s->exit_latency * multiplier > data->predicted_us becomes s->exit_latency > data->predicted_us / multiplier by dividing both sides of the comparison by "multiplier". While division is likely to be several times slower than multiplication, the minor performance hit allows making a generic sleep state selection function based on (sleep duration, maximum latency) tuple. Signed-off-by: Tuukka Tikkanen <tuukka.tikkanen@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 61c66d6 commit 96e9518

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

  • drivers/cpuidle/governors

‎drivers/cpuidle/governors/menu.c‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
288288
struct menu_device *data = &__get_cpu_var(menu_devices);
289289
int latency_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY);
290290
int i;
291-
int multiplier;
291+
unsigned int interactivity_req;
292292
struct timespec t;
293293

294294
if (data->needs_update) {
@@ -310,8 +310,6 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
310310

311311
data->bucket = which_bucket(data->next_timer_us);
312312

313-
multiplier = performance_multiplier();
314-
315313
/*
316314
* if the correction factor is 0 (eg first time init or cpu hotplug
317315
* etc), we actually want to start out with a unity factor.
@@ -330,6 +328,15 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
330328

331329
get_typical_interval(data);
332330

331+
/*
332+
* Performance multiplier defines a minimum predicted idle
333+
* duration / latency ratio. Adjust the latency limit if
334+
* necessary.
335+
*/
336+
interactivity_req = data->predicted_us / performance_multiplier();
337+
if (latency_req > interactivity_req)
338+
latency_req = interactivity_req;
339+
333340
/*
334341
* We want to default to C1 (hlt), not to busy polling
335342
* unless the timer is happening really really soon.
@@ -353,8 +360,6 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
353360
continue;
354361
if (s->exit_latency > latency_req)
355362
continue;
356-
if (s->exit_latency * multiplier > data->predicted_us)
357-
continue;
358363

359364
data->last_state_idx = i;
360365
}

0 commit comments

Comments
 (0)