diff options
author | Deepthi Dharwar <deepthi@linux.vnet.ibm.com> | 2012-10-03 14:42:26 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2012-10-17 19:57:25 -0400 |
commit | 83dac59409387789b88bed40b1be86a8abc572be (patch) | |
tree | 75ed7170694cea5959bbd7ea62ed1e3e8944323e /arch | |
parent | 8ea959a17fe6e27f7954dddad5b17b0e33f0d7ee (diff) |
cpuidle/powerpc: Fix snooze state problem in the cpuidle design on pseries.
Earlier without cpuidle framework on pseries, the native arch
idle routine comprised of both snooze and nap
states. smt_snooze_delay variable was used to delay
the idle process entry to deeper idle state like nap.
With the coming of cpuidle, this arch specific idle was replaced
by two different idle routines, one for supporting snooze and other
for nap. This enabled addition of more
low level idle states on pseries in the future.
On adopting the generic cpuidle framework for POWER systems,
the decision of which idle state to choose from, given a predicted
idle time is taken by the menu governor based on
target_residency and exit_latency of the idle states.
target_residency is the minimum time to be resident in that idle state.
Exit_latency is time taken to exit out of idle state.
Deeper the idle state, both the target residency and exit latency
would be higher.
In the current design, smt_snooze_delay is used as target_residency
for the snooze state which is incorrect, as it is not the
minimum but the maximum duration to be in snooze state.
This would result in the governor in taking bad decision,
as presently target_residency of nap < target_residency of snooze
inspite of nap being deeper idle state.
This patch aims to fix this problem by replacing the smt_snooze_delay loop
in snooze state, with the need_resched() as the governor is aware of
entry and exit of various idle transitions based on which
next idle time prediction.
The governor is intelligent enough to determine the idle state the needs to
be transitioned to and maintains a whole of heuristics including
io load, previous idle states predictions etc for the same, based on
which idle state entry decision is taken.
With this fix, of setting target_residency of snooze to 0
nap to smt_snooze_delay
if the predicted idle time is less
than smt_snooze_delay (target_residency of nap)
value governor would pick snooze state, else nap. This adhers to the
previous native idle design.
Signed-off-by: Deepthi Dharwar <deepthi@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/platforms/pseries/processor_idle.c | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/arch/powerpc/platforms/pseries/processor_idle.c b/arch/powerpc/platforms/pseries/processor_idle.c index a32d56d1f854..45d00e5fe14d 100644 --- a/arch/powerpc/platforms/pseries/processor_idle.c +++ b/arch/powerpc/platforms/pseries/processor_idle.c | |||
@@ -59,32 +59,22 @@ static int snooze_loop(struct cpuidle_device *dev, | |||
59 | { | 59 | { |
60 | unsigned long in_purr; | 60 | unsigned long in_purr; |
61 | ktime_t kt_before; | 61 | ktime_t kt_before; |
62 | unsigned long start_snooze; | 62 | int cpu = dev->cpu; |
63 | long snooze = drv->states[0].target_residency; | ||
64 | 63 | ||
65 | idle_loop_prolog(&in_purr, &kt_before); | 64 | idle_loop_prolog(&in_purr, &kt_before); |
65 | local_irq_enable(); | ||
66 | set_thread_flag(TIF_POLLING_NRFLAG); | ||
66 | 67 | ||
67 | if (snooze) { | 68 | while ((!need_resched()) && cpu_online(cpu)) { |
68 | start_snooze = get_tb() + snooze * tb_ticks_per_usec; | 69 | ppc64_runlatch_off(); |
69 | local_irq_enable(); | 70 | HMT_low(); |
70 | set_thread_flag(TIF_POLLING_NRFLAG); | 71 | HMT_very_low(); |
71 | |||
72 | while ((snooze < 0) || (get_tb() < start_snooze)) { | ||
73 | if (need_resched() || cpu_is_offline(dev->cpu)) | ||
74 | goto out; | ||
75 | ppc64_runlatch_off(); | ||
76 | HMT_low(); | ||
77 | HMT_very_low(); | ||
78 | } | ||
79 | |||
80 | HMT_medium(); | ||
81 | clear_thread_flag(TIF_POLLING_NRFLAG); | ||
82 | smp_mb(); | ||
83 | local_irq_disable(); | ||
84 | } | 72 | } |
85 | 73 | ||
86 | out: | ||
87 | HMT_medium(); | 74 | HMT_medium(); |
75 | clear_thread_flag(TIF_POLLING_NRFLAG); | ||
76 | smp_mb(); | ||
77 | |||
88 | dev->last_residency = | 78 | dev->last_residency = |
89 | (int)idle_loop_epilog(in_purr, kt_before); | 79 | (int)idle_loop_epilog(in_purr, kt_before); |
90 | return index; | 80 | return index; |
@@ -165,8 +155,8 @@ static struct cpuidle_state dedicated_states[MAX_IDLE_STATE_COUNT] = { | |||
165 | .name = "CEDE", | 155 | .name = "CEDE", |
166 | .desc = "CEDE", | 156 | .desc = "CEDE", |
167 | .flags = CPUIDLE_FLAG_TIME_VALID, | 157 | .flags = CPUIDLE_FLAG_TIME_VALID, |
168 | .exit_latency = 1, | 158 | .exit_latency = 10, |
169 | .target_residency = 10, | 159 | .target_residency = 100, |
170 | .enter = &dedicated_cede_loop }, | 160 | .enter = &dedicated_cede_loop }, |
171 | }; | 161 | }; |
172 | 162 | ||
@@ -197,7 +187,7 @@ void update_smt_snooze_delay(int cpu, int residency) | |||
197 | dev->states_usage[1].disable = 1; | 187 | dev->states_usage[1].disable = 1; |
198 | } else | 188 | } else |
199 | if (drv) | 189 | if (drv) |
200 | drv->states[0].target_residency = residency; | 190 | drv->states[1].target_residency = residency; |
201 | } | 191 | } |
202 | 192 | ||
203 | static int pseries_cpuidle_add_cpu_notifier(struct notifier_block *n, | 193 | static int pseries_cpuidle_add_cpu_notifier(struct notifier_block *n, |