]> git.hungrycats.org Git - linux/commitdiff
[PATCH] introduce idle_task_exit
authorNathan Lynch <nathanl@austin.ibm.com>
Sat, 8 Jan 2005 05:48:27 +0000 (21:48 -0800)
committerLinus Torvalds <torvalds@evo.osdl.org>
Sat, 8 Jan 2005 05:48:27 +0000 (21:48 -0800)
Heiko Carstens figured out that offlining a cpu can leak mm_structs because
the dying cpu's idle task fails to switch to init_mm and mmdrop its
active_mm before the cpu is down.  This patch introduces idle_task_exit,
which allows the idle task to do this as Ingo suggested.

I will follow this up with a patch for ppc64 which calls idle_task_exit
from cpu_die.

Signed-off-by: Nathan Lynch <nathanl@austin.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
include/linux/sched.h
kernel/sched.c

index 30648d7668ed0d526f90cc53d1a73040cc8b9b87..26ee93b76485270fe98e608bc7b450457c05bbc5 100644 (file)
@@ -756,6 +756,7 @@ extern void sched_exec(void);
 #endif
 
 extern void sched_idle_next(void);
+extern void idle_task_exit(void);
 extern void set_user_nice(task_t *p, long nice);
 extern int task_prio(const task_t *p);
 extern int task_nice(const task_t *p);
index 48892437de4b3ba4fa72856106f7cf87d15c477f..25393c06c0639b28dafab7a03f0d1935e4615d4c 100644 (file)
@@ -3976,6 +3976,20 @@ void sched_idle_next(void)
        spin_unlock_irqrestore(&rq->lock, flags);
 }
 
+/* Ensures that the idle task is using init_mm right before its cpu goes
+ * offline.
+ */
+void idle_task_exit(void)
+{
+       struct mm_struct *mm = current->active_mm;
+
+       BUG_ON(cpu_online(smp_processor_id()));
+
+       if (mm != &init_mm)
+               switch_mm(mm, &init_mm, current);
+       mmdrop(mm);
+}
+
 static void migrate_dead(unsigned int dead_cpu, task_t *tsk)
 {
        struct runqueue *rq = cpu_rq(dead_cpu);