summaryrefslogtreecommitdiff
path: root/kernel/exit.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@tv-sign.ru>2008-07-25 01:47:44 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-25 10:53:40 -0700
commitb564daf806d492dd4f7afe9b6c83b8d35d137669 (patch)
treefbd6d186035b9a0a270fca97887da5d6b106a60c /kernel/exit.c
parent9d5b327bf198d2720666de958dcc2ae219d86952 (diff)
downloadlwn-b564daf806d492dd4f7afe9b6c83b8d35d137669.tar.gz
lwn-b564daf806d492dd4f7afe9b6c83b8d35d137669.zip
coredump: construct the list of coredumping threads at startup time
binfmt->core_dump() has to iterate over the all threads in system in order to find the coredumping threads and construct the list using the GFP_ATOMIC allocations. With this patch each thread allocates the list node on exit_mm()'s stack and adds itself to the list. This allows us to do further changes: - simplify ->core_dump() - change exit_mm() to clear ->mm first, then wait for ->core_done. this makes the coredumping process visible to oom_kill - kill mm->core_done Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Acked-by: Roland McGrath <roland@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/exit.c')
-rw-r--r--kernel/exit.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index 63d82957baae..b66f0d55c791 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -664,6 +664,7 @@ assign_new_owner:
static void exit_mm(struct task_struct * tsk)
{
struct mm_struct *mm = tsk->mm;
+ struct core_state *core_state;
mm_release(tsk, mm);
if (!mm)
@@ -676,11 +677,19 @@ static void exit_mm(struct task_struct * tsk)
* group with ->mm != NULL.
*/
down_read(&mm->mmap_sem);
- if (mm->core_state) {
+ core_state = mm->core_state;
+ if (core_state) {
+ struct core_thread self;
up_read(&mm->mmap_sem);
- if (atomic_dec_and_test(&mm->core_state->nr_threads))
- complete(&mm->core_state->startup);
+ self.task = tsk;
+ self.next = xchg(&core_state->dumper.next, &self);
+ /*
+ * Implies mb(), the result of xchg() must be visible
+ * to core_state->dumper.
+ */
+ if (atomic_dec_and_test(&core_state->nr_threads))
+ complete(&core_state->startup);
wait_for_completion(&mm->core_done);
down_read(&mm->mmap_sem);