Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Konstantin Khlebnikov and committed by
Linus Torvalds
f7505d64 bca15543

+7 -3
+7 -3
kernel/fork.c
··· 787 787 /* Get rid of any cached register state */ 788 788 deactivate_mm(tsk, mm); 789 789 790 - if (tsk->vfork_done) 791 - complete_vfork_done(tsk); 792 - 793 790 /* 794 791 * If we're exiting normally, clear a user-space tid field if 795 792 * requested. We leave this alone when dying by signal, to leave ··· 807 810 } 808 811 tsk->clear_child_tid = NULL; 809 812 } 813 + 814 + /* 815 + * All done, finally we can wake up parent and return this mm to him. 816 + * Also kthread_stop() uses this completion for synchronization. 817 + */ 818 + if (tsk->vfork_done) 819 + complete_vfork_done(tsk); 810 820 } 811 821 812 822 /*