From mboxrd@z Thu Jan 1 00:00:00 1970 From: Till Smejkal Subject: [RFC PATCH 08/13] kernel/fork: Define explicitly which mm_struct to duplicate during fork Date: Mon, 13 Mar 2017 15:14:10 -0700 Message-ID: <20170313221415.9375-9-till.smejkal@gmail.com> References: <20170313221415.9375-1-till.smejkal@gmail.com> Return-path: In-Reply-To: <20170313221415.9375-1-till.smejkal@gmail.com> Sender: owner-linux-aio@kvack.org To: Richard Henderson , Ivan Kokshaysky , Matt Turner , Vineet Gupta , Russell King , Catalin Marinas , Will Deacon , Steven Miao , Richard Kuo , Tony Luck , Fenghua Yu , James Hogan , Ralf Baechle , "James E.J. Bottomley" , Helge Deller , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Martin Schwidefsky , Heiko Carstens , Yoshinori Sato , Rich Felker , "David S. Miller" Cc: linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, adi-buildroot-devel@lists.sourceforge.net, linux-hexagon@vger.kernel.org, linux-ia64@vger.kernel.org, linux-metag@vger.kernel.org, linux-mips@linux-mips.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-media@vger.kernel.org, linux-mtd@lists.infradead.org, linux-usb@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, linux-mm@kvack.org, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, alsa-devel@alsa-project.org List-Id: linux-api@vger.kernel.org The dup_mm-function used during 'do_fork' to duplicate the current task's mm_struct for the newly forked task always implicitly uses current->mm for this purpose. However, during copy_mm it was already decided which mm_struct to copy/duplicate. So pass this mm_struct to dup_mm instead of again deciding which mm_struct to use. Signed-off-by: Till Smejkal --- kernel/fork.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index 9209f6d5d7c0..d3087d870855 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1158,9 +1158,10 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm) * Allocate a new mm structure and copy contents from the * mm structure of the passed in task structure. */ -static struct mm_struct *dup_mm(struct task_struct *tsk) +static struct mm_struct *dup_mm(struct task_struct *tsk, + struct mm_struct *oldmm) { - struct mm_struct *mm, *oldmm = current->mm; + struct mm_struct *mm; int err; mm = allocate_mm(); @@ -1226,7 +1227,7 @@ static int copy_mm(unsigned long clone_flags, struct task_struct *tsk) } retval = -ENOMEM; - mm = dup_mm(tsk); + mm = dup_mm(tsk, oldmm); if (!mm) goto fail_nomem; -- 2.12.0 -- To unsubscribe, send a message with 'unsubscribe linux-aio' in the body to majordomo@kvack.org. For more info on Linux AIO, see: http://www.kvack.org/aio/ Don't email: aart@kvack.org