All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] MIPS: clear idle task mm pointer when hotplugging cpu
@ 2011-02-09  0:18 maksim.rayskiy
  2011-02-09 12:02 ` Ralf Baechle
  0 siblings, 1 reply; 2+ messages in thread
From: maksim.rayskiy @ 2011-02-09  0:18 UTC (permalink / raw)
  To: linux-mips, ralf; +Cc: Maksim Rayskiy

From: Maksim Rayskiy <mrayskiy@broadcom.com>

If kernel starts with maxcpus= option which does not bring all
available cpus online at boot time, idle tasks for offline cpus
are not created. If later offline cpus are hotplugged through sysfs,
__cpu_up is called in the context of the user task, and fork_idle
copies its non-zero mm pointer.  This causes BUG() in per_cpu_trap_init.

To avoid this, release mm for idle task and reset the pointer after
fork_idle().

Signed-off-by: Maksim Rayskiy <mrayskiy@broadcom.com>
---
 arch/mips/kernel/smp.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index 383aeb9..4593916 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -208,6 +208,11 @@ int __cpuinit __cpu_up(unsigned int cpu)
 
 		if (IS_ERR(idle))
 			panic(KERN_ERR "Fork failed for CPU %d", cpu);
+
+		if (idle->mm) {
+			mmput(idle->mm);
+			idle->mm = NULL;
+		}
 	} else {
 		idle = cpu_idle_thread[cpu];
 		init_idle(idle, cpu);
-- 
1.7.3.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] MIPS: clear idle task mm pointer when hotplugging cpu
  2011-02-09  0:18 [PATCH] MIPS: clear idle task mm pointer when hotplugging cpu maksim.rayskiy
@ 2011-02-09 12:02 ` Ralf Baechle
  0 siblings, 0 replies; 2+ messages in thread
From: Ralf Baechle @ 2011-02-09 12:02 UTC (permalink / raw)
  To: maksim.rayskiy; +Cc: linux-mips, Maksim Rayskiy

On Tue, Feb 08, 2011 at 04:18:07PM -0800, maksim.rayskiy@gmail.com wrote:

> If kernel starts with maxcpus= option which does not bring all
> available cpus online at boot time, idle tasks for offline cpus
> are not created. If later offline cpus are hotplugged through sysfs,
> __cpu_up is called in the context of the user task, and fork_idle
> copies its non-zero mm pointer.  This causes BUG() in per_cpu_trap_init.
> 
> To avoid this, release mm for idle task and reset the pointer after
> fork_idle().

Nice catch, applied.

x86 avoid this problem by forking the idle threads in a worker thread which
also avoids other potencial issues; we probably should take the same
path.

  Ralf

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-02-09 12:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-09  0:18 [PATCH] MIPS: clear idle task mm pointer when hotplugging cpu maksim.rayskiy
2011-02-09 12:02 ` Ralf Baechle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.