]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
introduce complete_vfork_done()
authorOleg Nesterov <oleg@redhat.com>
Mon, 22 Aug 2011 12:56:12 +0000 (14:56 +0200)
committerOleg Nesterov <oleg@redhat.com>
Mon, 22 Aug 2011 13:24:00 +0000 (15:24 +0200)
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>
fs/exec.c
include/linux/sched.h
kernel/fork.c

index 25dcbe5fc35664d6f389ce48f051d6528d607014..9bcc161c29830bf2ec214f54f54ed39cacf64d00 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1914,7 +1914,6 @@ static int coredump_wait(int exit_code, struct core_state *core_state)
 {
        struct task_struct *tsk = current;
        struct mm_struct *mm = tsk->mm;
-       struct completion *vfork_done;
        int core_waiters = -EBUSY;
 
        init_completion(&core_state->startup);
@@ -1933,11 +1932,8 @@ static int coredump_wait(int exit_code, struct core_state *core_state)
         * Make sure nobody is waiting for us to release the VM,
         * otherwise we can deadlock when we wait on each other
         */
-       vfork_done = tsk->vfork_done;
-       if (vfork_done) {
-               tsk->vfork_done = NULL;
-               complete(vfork_done);
-       }
+       if (tsk->vfork_done)
+               complete_vfork_done(tsk);
 
        if (core_waiters)
                wait_for_completion(&core_state->startup);
index 4ac2c0578e0ff9133c4c761fcf3291879ae646d4..5c4559f67dd22dc738b6acd23dd6985e1bc9672b 100644 (file)
@@ -2254,6 +2254,7 @@ extern int do_execve(const char *,
                     const char __user * const __user *,
                     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 void complete_vfork_done(struct task_struct *tsk);
 struct task_struct *fork_idle(int);
 
 extern void set_task_comm(struct task_struct *tsk, char *from);
index 8e6b6f4fb272ba498a4acdbcb6a29c8f7e6c87dd..a305563193f66948fff1b503c4a0ad9d71d34dfe 100644 (file)
@@ -650,6 +650,14 @@ struct mm_struct *get_task_mm(struct task_struct *task)
 }
 EXPORT_SYMBOL_GPL(get_task_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.
  * mmput is called whenever we stop holding onto a mm_struct,
  * error success whatever.
@@ -665,8 +673,6 @@ EXPORT_SYMBOL_GPL(get_task_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 */
 #ifdef CONFIG_FUTEX
        if (unlikely(tsk->robust_list)) {
@@ -686,11 +692,8 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm)
        /* Get rid of any cached register state */
        deactivate_mm(tsk, mm);
 
-       /* notify parent sleeping on vfork() */
-       if (vfork_done) {
-               tsk->vfork_done = NULL;
-               complete(vfork_done);
-       }
+       if (tsk->vfork_done)
+               complete_vfork_done(tsk);
 
        /*
         * If we're exiting normally, clear a user-space tid field if