Skip to content

Commit f7505d6

Browse files
koct9itorvalds
authored andcommitted
fork: call complete_vfork_done() after clearing child_tid and flushing rss-counters
Child should wake up the parent from vfork() only after finishing all operations with shared mm. There is no sense in using CLONE_CHILD_CLEARTID together with CLONE_VFORK, but it looks more accurate now. Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Hugh Dickins <hughd@google.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Konstantin Khlebnikov <khlebnikov@openvz.org> Cc: Markus Trippelsdorf <markus@trippelsdorf.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent bca1554 commit f7505d6

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎kernel/fork.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -787,9 +787,6 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm)
787787
/* Get rid of any cached register state */
788788
deactivate_mm(tsk, mm);
789789

790-
if (tsk->vfork_done)
791-
complete_vfork_done(tsk);
792-
793790
/*
794791
* If we're exiting normally, clear a user-space tid field if
795792
* requested. We leave this alone when dying by signal, to leave
@@ -810,6 +807,13 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm)
810807
}
811808
tsk->clear_child_tid = NULL;
812809
}
810+
811+
/*
812+
* All done, finally we can wake up parent and return this mm to him.
813+
* Also kthread_stop() uses this completion for synchronization.
814+
*/
815+
if (tsk->vfork_done)
816+
complete_vfork_done(tsk);
813817
}
814818

815819
/*

0 commit comments

Comments
 (0)