vfork: introduce complete_vfork_done()

No functional changes.

Move the clear-and-complete-vfork_done code into the new trivial helper,
complete_vfork_done().

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Oleg Nesterov 2012-03-05 14:59:13 -08:00 коммит произвёл Linus Torvalds
Родитель 880641bb9d
Коммит c415c3b47e
3 изменённых файлов: 13 добавлений и 13 удалений

Просмотреть файл

@ -1915,7 +1915,6 @@ static int coredump_wait(int exit_code, struct core_state *core_state)
{ {
struct task_struct *tsk = current; struct task_struct *tsk = current;
struct mm_struct *mm = tsk->mm; struct mm_struct *mm = tsk->mm;
struct completion *vfork_done;
int core_waiters = -EBUSY; int core_waiters = -EBUSY;
init_completion(&core_state->startup); init_completion(&core_state->startup);
@ -1934,11 +1933,8 @@ static int coredump_wait(int exit_code, struct core_state *core_state)
* Make sure nobody is waiting for us to release the VM, * Make sure nobody is waiting for us to release the VM,
* otherwise we can deadlock when we wait on each other * otherwise we can deadlock when we wait on each other
*/ */
vfork_done = tsk->vfork_done; if (tsk->vfork_done)
if (vfork_done) { complete_vfork_done(tsk);
tsk->vfork_done = NULL;
complete(vfork_done);
}
if (core_waiters) if (core_waiters)
wait_for_completion(&core_state->startup); wait_for_completion(&core_state->startup);

Просмотреть файл

@ -2291,6 +2291,7 @@ extern int do_execve(const char *,
const char __user * const __user *, const char __user * const __user *,
const char __user * const __user *, struct pt_regs *); const char __user * const __user *, struct pt_regs *);
extern long do_fork(unsigned long, unsigned long, struct pt_regs *, unsigned long, int __user *, int __user *); extern long do_fork(unsigned long, unsigned long, struct pt_regs *, unsigned long, int __user *, int __user *);
extern void complete_vfork_done(struct task_struct *tsk);
struct task_struct *fork_idle(int); struct task_struct *fork_idle(int);
extern void set_task_comm(struct task_struct *tsk, char *from); extern void set_task_comm(struct task_struct *tsk, char *from);

Просмотреть файл

@ -668,6 +668,14 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
return mm; return mm;
} }
void complete_vfork_done(struct task_struct *tsk)
{
struct completion *vfork_done = tsk->vfork_done;
tsk->vfork_done = NULL;
complete(vfork_done);
}
/* Please note the differences between mmput and mm_release. /* Please note the differences between mmput and mm_release.
* mmput is called whenever we stop holding onto a mm_struct, * mmput is called whenever we stop holding onto a mm_struct,
* error success whatever. * error success whatever.
@ -683,8 +691,6 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
*/ */
void mm_release(struct task_struct *tsk, struct mm_struct *mm) void mm_release(struct task_struct *tsk, struct mm_struct *mm)
{ {
struct completion *vfork_done = tsk->vfork_done;
/* Get rid of any futexes when releasing the mm */ /* Get rid of any futexes when releasing the mm */
#ifdef CONFIG_FUTEX #ifdef CONFIG_FUTEX
if (unlikely(tsk->robust_list)) { if (unlikely(tsk->robust_list)) {
@ -704,11 +710,8 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm)
/* Get rid of any cached register state */ /* Get rid of any cached register state */
deactivate_mm(tsk, mm); deactivate_mm(tsk, mm);
/* notify parent sleeping on vfork() */ if (tsk->vfork_done)
if (vfork_done) { complete_vfork_done(tsk);
tsk->vfork_done = NULL;
complete(vfork_done);
}
/* /*
* If we're exiting normally, clear a user-space tid field if * If we're exiting normally, clear a user-space tid field if