Skip to content

Commit

Permalink
cpuidle: powernv/pseries: Auto-promotion of snooze to deeper idle state
Browse files Browse the repository at this point in the history
The idle cpus which stay in snooze for a long period can degrade the
perfomance of the sibling cpus. If the cpu stays in snooze for more
than target residency of the next available idle state, then exit from
snooze. This gives a chance to the cpuidle governor to re-evaluate the
last idle state of the cpu to promote it to deeper idle states.

Signed-off-by: Shilpasri G Bhat <[email protected]>
Reviewed-by: Preeti U Murthy <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
  • Loading branch information
shilpasri authored and rafaeljw committed Jun 22, 2015
1 parent 7d51d97 commit 78eaa10
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/cpuidle/cpuidle-powernv.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,25 @@ struct cpuidle_driver powernv_idle_driver = {

static int max_idle_state;
static struct cpuidle_state *cpuidle_state_table;
static u64 snooze_timeout;
static bool snooze_timeout_en;

static int snooze_loop(struct cpuidle_device *dev,
struct cpuidle_driver *drv,
int index)
{
u64 snooze_exit_time;

local_irq_enable();
set_thread_flag(TIF_POLLING_NRFLAG);

snooze_exit_time = get_tb() + snooze_timeout;
ppc64_runlatch_off();
while (!need_resched()) {
HMT_low();
HMT_very_low();
if (snooze_timeout_en && get_tb() > snooze_exit_time)
break;
}

HMT_medium();
Expand Down Expand Up @@ -252,6 +259,11 @@ static int powernv_idle_probe(void)
cpuidle_state_table = powernv_states;
/* Device tree can indicate more idle states */
max_idle_state = powernv_add_idle_states();
if (max_idle_state > 1) {
snooze_timeout_en = true;
snooze_timeout = powernv_states[1].target_residency *
tb_ticks_per_usec;
}
} else
return -ENODEV;

Expand Down
11 changes: 11 additions & 0 deletions drivers/cpuidle/cpuidle-pseries.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ struct cpuidle_driver pseries_idle_driver = {

static int max_idle_state;
static struct cpuidle_state *cpuidle_state_table;
static u64 snooze_timeout;
static bool snooze_timeout_en;

static inline void idle_loop_prolog(unsigned long *in_purr)
{
Expand Down Expand Up @@ -58,14 +60,18 @@ static int snooze_loop(struct cpuidle_device *dev,
int index)
{
unsigned long in_purr;
u64 snooze_exit_time;

idle_loop_prolog(&in_purr);
local_irq_enable();
set_thread_flag(TIF_POLLING_NRFLAG);
snooze_exit_time = get_tb() + snooze_timeout;

while (!need_resched()) {
HMT_low();
HMT_very_low();
if (snooze_timeout_en && get_tb() > snooze_exit_time)
break;
}

HMT_medium();
Expand Down Expand Up @@ -244,6 +250,11 @@ static int pseries_idle_probe(void)
} else
return -ENODEV;

if (max_idle_state > 1) {
snooze_timeout_en = true;
snooze_timeout = cpuidle_state_table[1].target_residency *
tb_ticks_per_usec;
}
return 0;
}

Expand Down

0 comments on commit 78eaa10

Please sign in to comment.