diff options
author | Oleg Nesterov <oleg@redhat.com> | 2012-03-05 17:59:13 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-05 18:49:42 -0500 |
commit | c415c3b47ea2754659d915cca387a20999044163 (patch) | |
tree | c2cb1134f139702e06ade8aecbeff70be7ea727c | |
parent | 880641bb9da2473e9ecf6c708d993b29928c1b3c (diff) |
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>
-rw-r--r-- | fs/exec.c | 8 | ||||
-rw-r--r-- | include/linux/sched.h | 1 | ||||
-rw-r--r-- | kernel/fork.c | 17 |
3 files changed, 13 insertions, 13 deletions
@@ -1915,7 +1915,6 @@ static int coredump_wait(int exit_code, struct core_state *core_state) | |||
1915 | { | 1915 | { |
1916 | struct task_struct *tsk = current; | 1916 | struct task_struct *tsk = current; |
1917 | struct mm_struct *mm = tsk->mm; | 1917 | struct mm_struct *mm = tsk->mm; |
1918 | struct completion *vfork_done; | ||
1919 | int core_waiters = -EBUSY; | 1918 | int core_waiters = -EBUSY; |
1920 | 1919 | ||
1921 | init_completion(&core_state->startup); | 1920 | init_completion(&core_state->startup); |
@@ -1934,11 +1933,8 @@ static int coredump_wait(int exit_code, struct core_state *core_state) | |||
1934 | * Make sure nobody is waiting for us to release the VM, | 1933 | * Make sure nobody is waiting for us to release the VM, |
1935 | * otherwise we can deadlock when we wait on each other | 1934 | * otherwise we can deadlock when we wait on each other |
1936 | */ | 1935 | */ |
1937 | vfork_done = tsk->vfork_done; | 1936 | if (tsk->vfork_done) |
1938 | if (vfork_done) { | 1937 | complete_vfork_done(tsk); |
1939 | tsk->vfork_done = NULL; | ||
1940 | complete(vfork_done); | ||
1941 | } | ||
1942 | 1938 | ||
1943 | if (core_waiters) | 1939 | if (core_waiters) |
1944 | wait_for_completion(&core_state->startup); | 1940 | wait_for_completion(&core_state->startup); |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 7d379a6bfd88..1b25a37f2aee 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -2291,6 +2291,7 @@ extern int do_execve(const char *, | |||
2291 | const char __user * const __user *, | 2291 | const char __user * const __user *, |
2292 | const char __user * const __user *, struct pt_regs *); | 2292 | const char __user * const __user *, struct pt_regs *); |
2293 | extern long do_fork(unsigned long, unsigned long, struct pt_regs *, unsigned long, int __user *, int __user *); | 2293 | extern long do_fork(unsigned long, unsigned long, struct pt_regs *, unsigned long, int __user *, int __user *); |
2294 | extern void complete_vfork_done(struct task_struct *tsk); | ||
2294 | struct task_struct *fork_idle(int); | 2295 | struct task_struct *fork_idle(int); |
2295 | 2296 | ||
2296 | extern void set_task_comm(struct task_struct *tsk, char *from); | 2297 | extern void set_task_comm(struct task_struct *tsk, char *from); |
diff --git a/kernel/fork.c b/kernel/fork.c index e2cd3e2a5ae8..cf3d96379608 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -668,6 +668,14 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode) | |||
668 | return mm; | 668 | return mm; |
669 | } | 669 | } |
670 | 670 | ||
671 | void complete_vfork_done(struct task_struct *tsk) | ||
672 | { | ||
673 | struct completion *vfork_done = tsk->vfork_done; | ||
674 | |||
675 | tsk->vfork_done = NULL; | ||
676 | complete(vfork_done); | ||
677 | } | ||
678 | |||
671 | /* Please note the differences between mmput and mm_release. | 679 | /* Please note the differences between mmput and mm_release. |
672 | * mmput is called whenever we stop holding onto a mm_struct, | 680 | * mmput is called whenever we stop holding onto a mm_struct, |
673 | * error success whatever. | 681 | * error success whatever. |
@@ -683,8 +691,6 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode) | |||
683 | */ | 691 | */ |
684 | void mm_release(struct task_struct *tsk, struct mm_struct *mm) | 692 | void mm_release(struct task_struct *tsk, struct mm_struct *mm) |
685 | { | 693 | { |
686 | struct completion *vfork_done = tsk->vfork_done; | ||
687 | |||
688 | /* Get rid of any futexes when releasing the mm */ | 694 | /* Get rid of any futexes when releasing the mm */ |
689 | #ifdef CONFIG_FUTEX | 695 | #ifdef CONFIG_FUTEX |
690 | if (unlikely(tsk->robust_list)) { | 696 | if (unlikely(tsk->robust_list)) { |
@@ -704,11 +710,8 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm) | |||
704 | /* Get rid of any cached register state */ | 710 | /* Get rid of any cached register state */ |
705 | deactivate_mm(tsk, mm); | 711 | deactivate_mm(tsk, mm); |
706 | 712 | ||
707 | /* notify parent sleeping on vfork() */ | 713 | if (tsk->vfork_done) |
708 | if (vfork_done) { | 714 | complete_vfork_done(tsk); |
709 | tsk->vfork_done = NULL; | ||
710 | complete(vfork_done); | ||
711 | } | ||
712 | 715 | ||
713 | /* | 716 | /* |
714 | * If we're exiting normally, clear a user-space tid field if | 717 | * If we're exiting normally, clear a user-space tid field if |