MIPS: clear idle task mm pointer when hotplugging cpu
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
@@ -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
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_upis called in the context of the user task, andfork_idlecopies its non-zero mm pointer. This causesBUG()inper_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