From: Nathan Lynch <nathanl@austin.ibm.com>
To: Andrew Morton <akpm@osdl.org>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>,
Rusty Russell <rusty@rustcorp.com.au>,
paulus@au1.ibm.com, lkml <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@elte.hu>
Subject: [PATCH] introduce idle_task_exit
Date: Fri, 07 Jan 2005 15:43:09 -0600 [thread overview]
Message-ID: <1105134189.13391.6.camel@pants.austin.ibm.com> (raw)
In-Reply-To: <20050107114353.GA29779@elte.hu>
On Fri, 2005-01-07 at 05:43, Ingo Molnar wrote:
> * Nathan Lynch <nathanl@austin.ibm.com> wrote:
>
> > OK, how's this? I'll submit the sched and ppc64 bits separately if
> > there are no objections. I assume Heiko can take care of s390.
> >
> > Note that in the ppc64 cpu_die function we must call idle_task_exit
> > before calling ppc_md.cpu_die, because the latter does not return.
>
> Signed-off-by: Ingo Molnar <mingo@elte.hu>
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>
---
diff -puN kernel/sched.c~sched-idle_task_exit kernel/sched.c
--- linux-2.6.10-bk10/kernel/sched.c~sched-idle_task_exit 2005-01-07 15:23:35.000000000 -0600
+++ linux-2.6.10-bk10-nathanl/kernel/sched.c 2005-01-07 15:23:35.000000000 -0600
@@ -3996,6 +3996,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);
diff -puN include/linux/sched.h~sched-idle_task_exit include/linux/sched.h
--- linux-2.6.10-bk10/include/linux/sched.h~sched-idle_task_exit 2005-01-07 15:23:35.000000000 -0600
+++ linux-2.6.10-bk10-nathanl/include/linux/sched.h 2005-01-07 15:23:35.000000000 -0600
@@ -757,6 +757,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);
_
next prev parent reply other threads:[~2005-01-07 21:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-04 13:11 [BUG] mm_struct leak on cpu hotplug (s390/ppc64) Heiko Carstens
2005-01-05 2:41 ` Nathan Lynch
2005-01-05 11:08 ` Ingo Molnar
2005-01-05 14:22 ` Heiko Carstens
2005-01-05 15:44 ` Nathan Lynch
2005-01-07 11:43 ` Ingo Molnar
2005-01-07 21:43 ` Nathan Lynch [this message]
2005-01-07 21:44 ` [PATCH] ppc64: call idle_task_exit from cpu_die Nathan Lynch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1105134189.13391.6.camel@pants.austin.ibm.com \
--to=nathanl@austin.ibm.com \
--cc=akpm@osdl.org \
--cc=heiko.carstens@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@au1.ibm.com \
--cc=rusty@rustcorp.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).