Commit c415c3b47ea2754659d915cca387a20999044163
Committed by
Linus Torvalds
1 parent
880641bb9d
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
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>
Showing 3 changed files with 13 additions and 13 deletions Side-by-side Diff
fs/exec.c
... | ... | @@ -1915,7 +1915,6 @@ |
1915 | 1915 | { |
1916 | 1916 | struct task_struct *tsk = current; |
1917 | 1917 | struct mm_struct *mm = tsk->mm; |
1918 | - struct completion *vfork_done; | |
1919 | 1918 | int core_waiters = -EBUSY; |
1920 | 1919 | |
1921 | 1920 | init_completion(&core_state->startup); |
... | ... | @@ -1934,11 +1933,8 @@ |
1934 | 1933 | * Make sure nobody is waiting for us to release the VM, |
1935 | 1934 | * otherwise we can deadlock when we wait on each other |
1936 | 1935 | */ |
1937 | - vfork_done = tsk->vfork_done; | |
1938 | - if (vfork_done) { | |
1939 | - tsk->vfork_done = NULL; | |
1940 | - complete(vfork_done); | |
1941 | - } | |
1936 | + if (tsk->vfork_done) | |
1937 | + complete_vfork_done(tsk); | |
1942 | 1938 | |
1943 | 1939 | if (core_waiters) |
1944 | 1940 | wait_for_completion(&core_state->startup); |
include/linux/sched.h
... | ... | @@ -2291,6 +2291,7 @@ |
2291 | 2291 | const char __user * const __user *, |
2292 | 2292 | const char __user * const __user *, struct pt_regs *); |
2293 | 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 | 2295 | struct task_struct *fork_idle(int); |
2295 | 2296 | |
2296 | 2297 | extern void set_task_comm(struct task_struct *tsk, char *from); |
kernel/fork.c
... | ... | @@ -668,6 +668,14 @@ |
668 | 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 | 679 | /* Please note the differences between mmput and mm_release. |
672 | 680 | * mmput is called whenever we stop holding onto a mm_struct, |
673 | 681 | * error success whatever. |
... | ... | @@ -683,8 +691,6 @@ |
683 | 691 | */ |
684 | 692 | void mm_release(struct task_struct *tsk, struct mm_struct *mm) |
685 | 693 | { |
686 | - struct completion *vfork_done = tsk->vfork_done; | |
687 | - | |
688 | 694 | /* Get rid of any futexes when releasing the mm */ |
689 | 695 | #ifdef CONFIG_FUTEX |
690 | 696 | if (unlikely(tsk->robust_list)) { |
... | ... | @@ -704,11 +710,8 @@ |
704 | 710 | /* Get rid of any cached register state */ |
705 | 711 | deactivate_mm(tsk, mm); |
706 | 712 | |
707 | - /* notify parent sleeping on vfork() */ | |
708 | - if (vfork_done) { | |
709 | - tsk->vfork_done = NULL; | |
710 | - complete(vfork_done); | |
711 | - } | |
713 | + if (tsk->vfork_done) | |
714 | + complete_vfork_done(tsk); | |
712 | 715 | |
713 | 716 | /* |
714 | 717 | * If we're exiting normally, clear a user-space tid field if |