Commit b83f8c40 authored by Paul Mackerras's avatar Paul Mackerras Committed by Linus Torvalds

[PATCH] ppc64: fix idle loop for offline cpu

In the default_idle and dedicated_idle loops, there are some inner loops
out of which we should break if the cpu is marked offline.  Otherwise, it
is possible for the cpu to get stuck and never actually go offline.
shared_idle is unaffected.
Signed-off-by: default avatarNathan Lynch <nathanl@austin.ibm.com>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 8861f2cb
...@@ -132,6 +132,7 @@ int iSeries_idle(void) ...@@ -132,6 +132,7 @@ int iSeries_idle(void)
int default_idle(void) int default_idle(void)
{ {
long oldval; long oldval;
unsigned int cpu = smp_processor_id();
while (1) { while (1) {
oldval = test_and_clear_thread_flag(TIF_NEED_RESCHED); oldval = test_and_clear_thread_flag(TIF_NEED_RESCHED);
...@@ -139,7 +140,7 @@ int default_idle(void) ...@@ -139,7 +140,7 @@ int default_idle(void)
if (!oldval) { if (!oldval) {
set_thread_flag(TIF_POLLING_NRFLAG); set_thread_flag(TIF_POLLING_NRFLAG);
while (!need_resched()) { while (!need_resched() && !cpu_is_offline(cpu)) {
barrier(); barrier();
HMT_low(); HMT_low();
} }
...@@ -151,8 +152,7 @@ int default_idle(void) ...@@ -151,8 +152,7 @@ int default_idle(void)
} }
schedule(); schedule();
if (cpu_is_offline(smp_processor_id()) && if (cpu_is_offline(cpu) && system_state == SYSTEM_RUNNING)
system_state == SYSTEM_RUNNING)
cpu_die(); cpu_die();
} }
...@@ -169,8 +169,9 @@ int dedicated_idle(void) ...@@ -169,8 +169,9 @@ int dedicated_idle(void)
struct paca_struct *lpaca = get_paca(), *ppaca; struct paca_struct *lpaca = get_paca(), *ppaca;
unsigned long start_snooze; unsigned long start_snooze;
unsigned long *smt_snooze_delay = &__get_cpu_var(smt_snooze_delay); unsigned long *smt_snooze_delay = &__get_cpu_var(smt_snooze_delay);
unsigned int cpu = smp_processor_id();
ppaca = &paca[smp_processor_id() ^ 1]; ppaca = &paca[cpu ^ 1];
while (1) { while (1) {
/* Indicate to the HV that we are idle. Now would be /* Indicate to the HV that we are idle. Now would be
...@@ -182,7 +183,7 @@ int dedicated_idle(void) ...@@ -182,7 +183,7 @@ int dedicated_idle(void)
set_thread_flag(TIF_POLLING_NRFLAG); set_thread_flag(TIF_POLLING_NRFLAG);
start_snooze = __get_tb() + start_snooze = __get_tb() +
*smt_snooze_delay * tb_ticks_per_usec; *smt_snooze_delay * tb_ticks_per_usec;
while (!need_resched()) { while (!need_resched() && !cpu_is_offline(cpu)) {
/* need_resched could be 1 or 0 at this /* need_resched could be 1 or 0 at this
* point. If it is 0, set it to 0, so * point. If it is 0, set it to 0, so
* an IPI/Prod is sent. If it is 1, keep * an IPI/Prod is sent. If it is 1, keep
...@@ -241,8 +242,7 @@ int dedicated_idle(void) ...@@ -241,8 +242,7 @@ int dedicated_idle(void)
HMT_medium(); HMT_medium();
lpaca->lppaca.xIdle = 0; lpaca->lppaca.xIdle = 0;
schedule(); schedule();
if (cpu_is_offline(smp_processor_id()) && if (cpu_is_offline(cpu) && system_state == SYSTEM_RUNNING)
system_state == SYSTEM_RUNNING)
cpu_die(); cpu_die();
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment