Skip to contentSkip to conversation

MIPS: clear idle task mm pointer when hotplugging cpu

PATCH In review [email protected] 2 participants 2 messages Feb 9, 2011 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MIPS: clear idle task mm pointer when hotplugging cpu

From: Maksim Rayskiy <[email protected]>

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().

---
 arch/mips/kernel/smp.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
arch/mips/kernel/smp.c +5 -0
index 383aeb9..4593916 100644
@@ -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);
Signature · 1 line
1.7.3.2
#1 lore raw
Quoted 8 lines · On Tue, Feb 08, 2011 at 04:18:07PM -0800, [email protected] 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