Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 105944
b: refs/heads/master
c: a94e2d4
h: refs/heads/master
v: v3
  • Loading branch information
Oleg Nesterov authored and Linus Torvalds committed Jul 25, 2008
1 parent f7deec4 commit 2111cf8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 182c515fd2a942623aed4e4e0e0b37fe96571b05
refs/heads/master: a94e2d408eaedbd85aae259621d46fafc10479a2
25 changes: 22 additions & 3 deletions trunk/fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,6 @@ static int coredump_wait(int exit_code, struct core_state *core_state)
struct completion *vfork_done;
int core_waiters;

init_completion(&mm->core_done);
init_completion(&core_state->startup);
core_state->dumper.task = tsk;
core_state->dumper.next = NULL;
Expand All @@ -1628,6 +1627,27 @@ static int coredump_wait(int exit_code, struct core_state *core_state)
return core_waiters;
}

static void coredump_finish(struct mm_struct *mm)
{
struct core_thread *curr, *next;
struct task_struct *task;

next = mm->core_state->dumper.next;
while ((curr = next) != NULL) {
next = curr->next;
task = curr->task;
/*
* see exit_mm(), curr->task must not see
* ->task == NULL before we read ->next.
*/
smp_mb();
curr->task = NULL;
wake_up_process(task);
}

mm->core_state = NULL;
}

/*
* set_dumpable converts traditional three-value dumpable to two flags and
* stores them into mm->flags. It modifies lower two bits of mm->flags, but
Expand Down Expand Up @@ -1812,8 +1832,7 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)
argv_free(helper_argv);

current->fsuid = fsuid;
complete_all(&mm->core_done);
mm->core_state = NULL;
coredump_finish(mm);
fail:
return retval;
}
4 changes: 1 addition & 3 deletions trunk/include/linux/mm_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,7 @@ struct mm_struct {

unsigned long flags; /* Must use atomic bitops to access the bits */

/* coredumping support */
struct core_state *core_state;
struct completion core_done;
struct core_state *core_state; /* coredumping support */

/* aio bits */
rwlock_t ioctx_list_lock; /* aio lock */
Expand Down
8 changes: 7 additions & 1 deletion trunk/kernel/exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,13 @@ static void exit_mm(struct task_struct * tsk)
if (atomic_dec_and_test(&core_state->nr_threads))
complete(&core_state->startup);

wait_for_completion(&mm->core_done);
for (;;) {
set_task_state(tsk, TASK_UNINTERRUPTIBLE);
if (!self.task) /* see coredump_finish() */
break;
schedule();
}
__set_task_state(tsk, TASK_RUNNING);
down_read(&mm->mmap_sem);
}
atomic_inc(&mm->mm_count);
Expand Down

0 comments on commit 2111cf8

Please sign in to comment.