[PATCH 2/8] vfork: introduce clone_vfork_finish()

Oleg Nesterov
2011-07-27T16:35:45Z

No functional changes.

Move the wait-for-vfork_done code from do_wait() into the new
helper, clone_vfork_finish().

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---

kernel/fork.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)

--- 3.1/kernel/fork.c~2_wait_for_vfork_done 2011-07-26 17:52:25.000000000 +0200
+++ 3.1/kernel/fork.c 2011-07-26 17:52:59.000000000 +0200
@@ -1449,6 +1449,17 @@ void complete_vfork_done(struct task_str
complete(vfork_done);
}

+static long clone_vfork_finish(struct task_struct *child,
+ struct completion *vfork_done, long pid)
+{
+ freezer_do_not_count();
+ wait_for_completion(vfork_done);
+ freezer_count();
+
+ ptrace_event(PTRACE_EVENT_VFORK_DONE, pid);
+ return pid;
+}
+
/*
* Ok, this is the main fork-routine.
*
@@ -1536,12 +1547,8 @@ long do_fork(unsigned long clone_flags,
if (unlikely(trace))
ptrace_event(trace, nr);

- if (clone_flags & CLONE_VFORK) {
- freezer_do_not_count();
- wait_for_completion(&vfork);
- freezer_count();
- ptrace_event(PTRACE_EVENT_VFORK_DONE, nr);
- }
+ if (clone_flags & CLONE_VFORK)
+ nr = clone_vfork_finish(p, &vfork, nr);
} else {
nr = PTR_ERR(p);
}