Skip to content

Commit

Permalink
cpuidle: Do not use poll_idle unless user asks for it
Browse files Browse the repository at this point in the history
poll_idle was added to CPUIDLE, just as a low latency idle handler, to be
used in cases when user desires CPUs not to enter any idle state at all. It
was supposed to be a run time idle=poll option to the user. But, it was indeed
getting used during normal menu and ladder governor default case, with no
special user setting (Reported by Linus Torvalds).

Change below ensures that poll_idle will not be used unless user explicitly
asks pm_qos infrastructure for zero latency requirement.

Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
  • Loading branch information
venkatesh.pallipadi@intel.com authored and Andi Kleen committed Aug 15, 2008
1 parent b635ace commit a2bd920
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
14 changes: 10 additions & 4 deletions drivers/cpuidle/governors/ladder.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,17 @@ static int ladder_select_state(struct cpuidle_device *dev)
struct ladder_device *ldev = &__get_cpu_var(ladder_devices);
struct ladder_device_state *last_state;
int last_residency, last_idx = ldev->last_state_idx;
int latency_req = pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY);

if (unlikely(!ldev))
return 0;

/* Special case when user has set very strict latency requirement */
if (unlikely(latency_req == 0)) {
ladder_do_selection(ldev, last_idx, 0);
return 0;
}

last_state = &ldev->states[last_idx];

if (dev->states[last_idx].flags & CPUIDLE_FLAG_TIME_VALID)
Expand All @@ -81,8 +88,7 @@ static int ladder_select_state(struct cpuidle_device *dev)
/* consider promotion */
if (last_idx < dev->state_count - 1 &&
last_residency > last_state->threshold.promotion_time &&
dev->states[last_idx + 1].exit_latency <=
pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY)) {
dev->states[last_idx + 1].exit_latency <= latency_req) {
last_state->stats.promotion_count++;
last_state->stats.demotion_count = 0;
if (last_state->stats.promotion_count >= last_state->threshold.promotion_count) {
Expand All @@ -92,7 +98,7 @@ static int ladder_select_state(struct cpuidle_device *dev)
}

/* consider demotion */
if (last_idx > 0 &&
if (last_idx > CPUIDLE_DRIVER_STATE_START &&
last_residency < last_state->threshold.demotion_time) {
last_state->stats.demotion_count++;
last_state->stats.promotion_count = 0;
Expand All @@ -117,7 +123,7 @@ static int ladder_enable_device(struct cpuidle_device *dev)
struct ladder_device_state *lstate;
struct cpuidle_state *state;

ldev->last_state_idx = 0;
ldev->last_state_idx = CPUIDLE_DRIVER_STATE_START;

for (i = 0; i < dev->state_count; i++) {
state = &dev->states[i];
Expand Down
11 changes: 9 additions & 2 deletions drivers/cpuidle/governors/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,28 @@ static DEFINE_PER_CPU(struct menu_device, menu_devices);
static int menu_select(struct cpuidle_device *dev)
{
struct menu_device *data = &__get_cpu_var(menu_devices);
int latency_req = pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY);
int i;

/* Special case when user has set very strict latency requirement */
if (unlikely(latency_req == 0)) {
data->last_state_idx = 0;
return 0;
}

/* determine the expected residency time */
data->expected_us =
(u32) ktime_to_ns(tick_nohz_get_sleep_length()) / 1000;

/* find the deepest idle state that satisfies our constraints */
for (i = 1; i < dev->state_count; i++) {
for (i = CPUIDLE_DRIVER_STATE_START + 1; i < dev->state_count; i++) {
struct cpuidle_state *s = &dev->states[i];

if (s->target_residency > data->expected_us)
break;
if (s->target_residency > data->predicted_us)
break;
if (s->exit_latency > pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY))
if (s->exit_latency > latency_req)
break;
}

Expand Down

0 comments on commit a2bd920

Please sign in to comment.