Patchwork [V2] MIPS: Fix poweroff failure when HOTPLUG_CPU configured.

login
register
mail settings
Submitter Huacai Chen
Date Aug. 13, 2012, 12:52 p.m.
Message ID <1344862344-27434-1-git-send-email-chenhc@lemote.com>
Download mbox | patch
Permalink /patch/4211/
State Accepted
Delegated to: Ralf Baechle
Headers show

Comments

Huacai Chen - Aug. 13, 2012, 12:52 p.m.
When poweroff machine, kernel_power_off() call disable_nonboot_cpus().
And if we have HOTPLUG_CPU configured, disable_nonboot_cpus() is not an
empty function but attempt to actually disable the nonboot cpus. Since
system state is SYSTEM_POWER_OFF, play_dead() won't be called and thus
disable_nonboot_cpus() hangs. Therefore, we make this patch to avoid
poweroff failure.

V2:
Make the From: address the same as Signed-off-by address.

Signed-off-by: Huacai Chen <chenhc@lemote.com>
Signed-off-by: Hongliang Tao <taohl@lemote.com>
Signed-off-by: Hua Yan <yanh@lemote.com>
Cc: Yong Zhang <yong.zhang@windriver.com>
Cc: stable@vger.kernel.org
---
 arch/mips/kernel/process.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
root - Aug. 14, 2012, 11:48 a.m.
On Mon, Aug 13, 2012 at 08:52:24PM +0800, Huacai Chen wrote:

> When poweroff machine, kernel_power_off() call disable_nonboot_cpus().
> And if we have HOTPLUG_CPU configured, disable_nonboot_cpus() is not an
> empty function but attempt to actually disable the nonboot cpus. Since
> system state is SYSTEM_POWER_OFF, play_dead() won't be called and thus
> disable_nonboot_cpus() hangs. Therefore, we make this patch to avoid
> poweroff failure.

> diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
> index e9a5fd7..69b17a9 100644
> --- a/arch/mips/kernel/process.c
> +++ b/arch/mips/kernel/process.c
> @@ -72,9 +72,7 @@ void __noreturn cpu_idle(void)
>  			}
>  		}
>  #ifdef CONFIG_HOTPLUG_CPU
> -		if (!cpu_online(cpu) && !cpu_isset(cpu, cpu_callin_map) &&
> -		    (system_state == SYSTEM_RUNNING ||
> -		     system_state == SYSTEM_BOOTING))
> +		if (!cpu_online(cpu) && !cpu_isset(cpu, cpu_callin_map))

Looks good - but I'm wondering if the "!cpu_isset(cpu, cpu_callin_map)"
can be removed as well?

Also, which -stable branches is this patch applicable?

  Ralf
Huacai Chen - Aug. 14, 2012, 2:24 p.m.
On Tue, Aug 14, 2012 at 7:48 PM, Ralf Baechle <ralf@linux-mips.org> wrote:
> On Mon, Aug 13, 2012 at 08:52:24PM +0800, Huacai Chen wrote:
>
>> When poweroff machine, kernel_power_off() call disable_nonboot_cpus().
>> And if we have HOTPLUG_CPU configured, disable_nonboot_cpus() is not an
>> empty function but attempt to actually disable the nonboot cpus. Since
>> system state is SYSTEM_POWER_OFF, play_dead() won't be called and thus
>> disable_nonboot_cpus() hangs. Therefore, we make this patch to avoid
>> poweroff failure.
>
>> diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
>> index e9a5fd7..69b17a9 100644
>> --- a/arch/mips/kernel/process.c
>> +++ b/arch/mips/kernel/process.c
>> @@ -72,9 +72,7 @@ void __noreturn cpu_idle(void)
>>                       }
>>               }
>>  #ifdef CONFIG_HOTPLUG_CPU
>> -             if (!cpu_online(cpu) && !cpu_isset(cpu, cpu_callin_map) &&
>> -                 (system_state == SYSTEM_RUNNING ||
>> -                  system_state == SYSTEM_BOOTING))
>> +             if (!cpu_online(cpu) && !cpu_isset(cpu, cpu_callin_map))
>
> Looks good - but I'm wondering if the "!cpu_isset(cpu, cpu_callin_map)"
> can be removed as well?
For X86, IA64, ARM, SPARC64 and most other arch, "!cpu_online(cpu)" is
the only condition of play_dead(). I keep "!cpu_isset(cpu,
cpu_callin_map)" because this does't refuse poweroff and I don't know
why the old condition of play_dead() is so complex.

>
> Also, which -stable branches is this patch applicable?
3.3, 3.4 and 3.5 branch can use it, 3.2 and earlier kernels should do
some small changes.

>
>   Ralf
>
Huacai Chen - Aug. 16, 2012, 3:47 a.m.
On Tue, Aug 14, 2012 at 7:48 PM, Ralf Baechle <ralf@linux-mips.org> wrote:
> On Mon, Aug 13, 2012 at 08:52:24PM +0800, Huacai Chen wrote:
>
>> When poweroff machine, kernel_power_off() call disable_nonboot_cpus().
>> And if we have HOTPLUG_CPU configured, disable_nonboot_cpus() is not an
>> empty function but attempt to actually disable the nonboot cpus. Since
>> system state is SYSTEM_POWER_OFF, play_dead() won't be called and thus
>> disable_nonboot_cpus() hangs. Therefore, we make this patch to avoid
>> poweroff failure.
>
>> diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
>> index e9a5fd7..69b17a9 100644
>> --- a/arch/mips/kernel/process.c
>> +++ b/arch/mips/kernel/process.c
>> @@ -72,9 +72,7 @@ void __noreturn cpu_idle(void)
>>                       }
>>               }
>>  #ifdef CONFIG_HOTPLUG_CPU
>> -             if (!cpu_online(cpu) && !cpu_isset(cpu, cpu_callin_map) &&
>> -                 (system_state == SYSTEM_RUNNING ||
>> -                  system_state == SYSTEM_BOOTING))
>> +             if (!cpu_online(cpu) && !cpu_isset(cpu, cpu_callin_map))
>
> Looks good - but I'm wondering if the "!cpu_isset(cpu, cpu_callin_map)"
> can be removed as well?
I removed "!cpu_isset(cpu, cpu_callin_map)" and it works well on
Loongson, but I don't know whether it will affect cavium-octeon...

>
> Also, which -stable branches is this patch applicable?
>
>   Ralf
>
Kevin Cernekee - Aug. 18, 2012, 5:50 p.m.
On Mon, Aug 13, 2012 at 5:52 AM, Huacai Chen <chenhc@lemote.com> wrote:
> When poweroff machine, kernel_power_off() call disable_nonboot_cpus().
> And if we have HOTPLUG_CPU configured, disable_nonboot_cpus() is not an
> empty function but attempt to actually disable the nonboot cpus. Since
> system state is SYSTEM_POWER_OFF, play_dead() won't be called and thus
> disable_nonboot_cpus() hangs. Therefore, we make this patch to avoid
> poweroff failure.

I have seen the same problem; sometimes it causes a kernel oops too.

>  #ifdef CONFIG_HOTPLUG_CPU
> -               if (!cpu_online(cpu) && !cpu_isset(cpu, cpu_callin_map) &&
> -                   (system_state == SYSTEM_RUNNING ||
> -                    system_state == SYSTEM_BOOTING))
> +               if (!cpu_online(cpu) && !cpu_isset(cpu, cpu_callin_map))
>                         play_dead();

This fix works for me.

Acked-by: Kevin Cernekee <cernekee@gmail.com>

I do see SMP boot problems ("Attempted to kill the idle task!" panic)
on a 4-way box if the !cpu_isset() check is removed.

Patch

diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index e9a5fd7..69b17a9 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -72,9 +72,7 @@  void __noreturn cpu_idle(void)
 			}
 		}
 #ifdef CONFIG_HOTPLUG_CPU
-		if (!cpu_online(cpu) && !cpu_isset(cpu, cpu_callin_map) &&
-		    (system_state == SYSTEM_RUNNING ||
-		     system_state == SYSTEM_BOOTING))
+		if (!cpu_online(cpu) && !cpu_isset(cpu, cpu_callin_map))
 			play_dead();
 #endif
 		rcu_idle_exit();