From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0D83BECAAD3 for ; Fri, 9 Sep 2022 13:29:02 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4MPGzd1k2nz3bsK for ; Fri, 9 Sep 2022 23:29:01 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=Oc2dEpgx; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=ldufour@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=Oc2dEpgx; dkim-atps=neutral Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4MPGyn5rGJz2xJD for ; Fri, 9 Sep 2022 23:28:17 +1000 (AEST) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 289DC0J7020496; Fri, 9 Sep 2022 13:27:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=xGWZBcP7Vjjt0ne0dV570vSeEqDuHKwNy1/7aKUyKxk=; b=Oc2dEpgxnslVIg0nuXQJTu0mYsSNNfCZdEPdgqnf44ZzwNFf5rfyGVSJJ4lfiVOQ+hDb r2BwmVUe0lsGbIwUDN5sGlpSA/vfWO85w7P5pIEnJdB6IJE26i1yKWa8u41SG99gEE70 HhX0foDFQMIYn6ZaPrWI8W4y5LcEz5bQpK60sxw9GhnpCJHsc/HhH1oVFMqnEQbgNhjJ N2z8IbFkOoTcR1f8Pa7IbC+o7HekL8a43AwEalRa6TwVuD0BwSoKUlCqWgUheNfB7CaU VTVRrsFG9LDLGf9tubkJKlGH5EgtKs/QItlSA8ggvXEteKsKcwkw3FriHYyP6dAFKzAl Zw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jg65j0gfy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Sep 2022 13:27:38 +0000 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 289DCiY4026580; Fri, 9 Sep 2022 13:27:37 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jg65j0gec-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Sep 2022 13:27:37 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 289DKFtx009042; Fri, 9 Sep 2022 13:27:34 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma04ams.nl.ibm.com with ESMTP id 3jbxj901mt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Sep 2022 13:27:34 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 289DRW1Z40501602 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 9 Sep 2022 13:27:32 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 22BB742045; Fri, 9 Sep 2022 13:27:32 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A234742041; Fri, 9 Sep 2022 13:27:30 +0000 (GMT) Received: from [9.145.83.17] (unknown [9.145.83.17]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 9 Sep 2022 13:27:30 +0000 (GMT) Message-ID: Date: Fri, 9 Sep 2022 15:27:30 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: Re: [RFC PATCH RESEND 07/28] kernel/fork: mark VMAs as locked before copying pages during fork Content-Language: fr To: Suren Baghdasaryan References: <20220901173516.702122-1-surenb@google.com> <20220901173516.702122-8-surenb@google.com> From: Laurent Dufour In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: AKENId9QRksp4m3H-lE_THCmMHniIzD8 X-Proofpoint-GUID: CFGeekGWSpIQRCVQ4AE9GyYndL5KhzSD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-09_08,2022-09-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 adultscore=0 clxscore=1015 priorityscore=1501 mlxlogscore=999 spamscore=0 phishscore=0 impostorscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209090045 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: michel@lespinasse.org, joelaf@google.com, songliubraving@fb.com, mhocko@suse.com, david@redhat.com, peterz@infradead.org, bigeasy@linutronix.de, peterx@redhat.com, dhowells@redhat.com, linux-mm@kvack.org, jglisse@google.com, dave@stgolabs.net, minchan@google.com, x86@kernel.org, hughd@google.com, willy@infradead.org, laurent.dufour@fr.ibm.com, mgorman@suse.de, rientjes@google.com, axelrasmussen@google.com, kernel-team@android.com, paulmck@kernel.org, liam.howlett@oracle.com, luto@kernel.org, vbabka@suse.cz, linux-arm-kernel@lists.infradead.org, kent.overstreet@linux.dev, linux-kernel@vger.kernel.org, hannes@cmpxchg.org, akpm@linux-foundation.org, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Le 09/09/2022 à 01:57, Suren Baghdasaryan a écrit : > On Tue, Sep 6, 2022 at 7:38 AM Laurent Dufour wrote: >> >> Le 01/09/2022 à 19:34, Suren Baghdasaryan a écrit : >>> Protect VMAs from concurrent page fault handler while performing >>> copy_page_range for VMAs having VM_WIPEONFORK flag set. >> >> I'm wondering why is that necessary. >> The copied mm is write locked, and the destination one is not reachable. >> If any other readers are using the VMA, this is only for page fault handling. > > Correct, this is done to prevent page faulting in the VMA being > duplicated. I assume we want to prevent the pages in that VMA from > changing when we are calling copy_page_range(). Am I wrong? If a page is faulted while copy_page_range() is in progress, the page may not be backed on the child side (PTE lock should protect the copy, isn't it). Is that a real problem? It will be backed later if accessed on the child side. Maybe the per process pages accounting could be incorrect... > >> I should have miss something because I can't see any need to mark the lock >> VMA here. >> >>> Signed-off-by: Suren Baghdasaryan >>> --- >>> kernel/fork.c | 4 +++- >>> 1 file changed, 3 insertions(+), 1 deletion(-) >>> >>> diff --git a/kernel/fork.c b/kernel/fork.c >>> index bfab31ecd11e..1872ad549fed 100644 >>> --- a/kernel/fork.c >>> +++ b/kernel/fork.c >>> @@ -709,8 +709,10 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm, >>> rb_parent = &tmp->vm_rb; >>> >>> mm->map_count++; >>> - if (!(tmp->vm_flags & VM_WIPEONFORK)) >>> + if (!(tmp->vm_flags & VM_WIPEONFORK)) { >>> + vma_mark_locked(mpnt); >>> retval = copy_page_range(tmp, mpnt); >>> + } >>> >>> if (tmp->vm_ops && tmp->vm_ops->open) >>> tmp->vm_ops->open(tmp); >> From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 10F30ECAAA1 for ; Fri, 9 Sep 2022 13:29:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IrBAP7weErp2wmp8+M0of8v1H8GSxv6UL2YTqbOT0cs=; b=gQLcAr1rLzTw37 moOvlO2X4MaIdrNENlJB7Fgs4W3sh98qTnCKC4QTsm1CD7vqsE3VBEpVfiRmxsOgUmVNv8KJ3vRxG ZtK/7U8RneS2g1qwMFx1wnG4u+q+0tg5RGis9LwZokZAFdly+q6xLFo+aXxbaJUtyHru5b7ZoY+7L WSFNgKt6U9zmsIgBUqRO5HB8+MnyFasupQrzChrCBwZs6Di3jQSUwZsUwRDmBpS25sp7xBnaSnUiS 8tkqXPkDGtM+kmA3M07TwC6fMCNRrwF3g4u3a7IXVtX6XdZTclOjCr2gQxxTjcuBcRLus9n1WbQ+c KbIeUj0cZXI2K7afsYjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oWe3M-00GKC6-Uk; Fri, 09 Sep 2022 13:28:17 +0000 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oWe3J-00GKBK-DR for linux-arm-kernel@lists.infradead.org; Fri, 09 Sep 2022 13:28:14 +0000 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 289DC0J7020496; Fri, 9 Sep 2022 13:27:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=xGWZBcP7Vjjt0ne0dV570vSeEqDuHKwNy1/7aKUyKxk=; b=Oc2dEpgxnslVIg0nuXQJTu0mYsSNNfCZdEPdgqnf44ZzwNFf5rfyGVSJJ4lfiVOQ+hDb r2BwmVUe0lsGbIwUDN5sGlpSA/vfWO85w7P5pIEnJdB6IJE26i1yKWa8u41SG99gEE70 HhX0foDFQMIYn6ZaPrWI8W4y5LcEz5bQpK60sxw9GhnpCJHsc/HhH1oVFMqnEQbgNhjJ N2z8IbFkOoTcR1f8Pa7IbC+o7HekL8a43AwEalRa6TwVuD0BwSoKUlCqWgUheNfB7CaU VTVRrsFG9LDLGf9tubkJKlGH5EgtKs/QItlSA8ggvXEteKsKcwkw3FriHYyP6dAFKzAl Zw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jg65j0gfy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Sep 2022 13:27:38 +0000 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 289DCiY4026580; Fri, 9 Sep 2022 13:27:37 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jg65j0gec-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Sep 2022 13:27:37 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 289DKFtx009042; Fri, 9 Sep 2022 13:27:34 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma04ams.nl.ibm.com with ESMTP id 3jbxj901mt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Sep 2022 13:27:34 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 289DRW1Z40501602 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 9 Sep 2022 13:27:32 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 22BB742045; Fri, 9 Sep 2022 13:27:32 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A234742041; Fri, 9 Sep 2022 13:27:30 +0000 (GMT) Received: from [9.145.83.17] (unknown [9.145.83.17]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 9 Sep 2022 13:27:30 +0000 (GMT) Message-ID: Date: Fri, 9 Sep 2022 15:27:30 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: Re: [RFC PATCH RESEND 07/28] kernel/fork: mark VMAs as locked before copying pages during fork Content-Language: fr To: Suren Baghdasaryan Cc: akpm@linux-foundation.org, michel@lespinasse.org, jglisse@google.com, mhocko@suse.com, vbabka@suse.cz, hannes@cmpxchg.org, mgorman@suse.de, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, peterz@infradead.org, laurent.dufour@fr.ibm.com, paulmck@kernel.org, luto@kernel.org, songliubraving@fb.com, peterx@redhat.com, david@redhat.com, dhowells@redhat.com, hughd@google.com, bigeasy@linutronix.de, kent.overstreet@linux.dev, rientjes@google.com, axelrasmussen@google.com, joelaf@google.com, minchan@google.com, kernel-team@android.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-kernel@vger.kernel.org References: <20220901173516.702122-1-surenb@google.com> <20220901173516.702122-8-surenb@google.com> From: Laurent Dufour In-Reply-To: X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: AKENId9QRksp4m3H-lE_THCmMHniIzD8 X-Proofpoint-GUID: CFGeekGWSpIQRCVQ4AE9GyYndL5KhzSD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-09_08,2022-09-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 adultscore=0 clxscore=1015 priorityscore=1501 mlxlogscore=999 spamscore=0 phishscore=0 impostorscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209090045 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220909_062813_465802_9A3EA020 X-CRM114-Status: GOOD ( 24.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org TGUgMDkvMDkvMjAyMiDDoCAwMTo1NywgU3VyZW4gQmFnaGRhc2FyeWFuIGEgw6ljcml0wqA6Cj4g T24gVHVlLCBTZXAgNiwgMjAyMiBhdCA3OjM4IEFNIExhdXJlbnQgRHVmb3VyIDxsZHVmb3VyQGxp bnV4LmlibS5jb20+IHdyb3RlOgo+Pgo+PiBMZSAwMS8wOS8yMDIyIMOgIDE5OjM0LCBTdXJlbiBC YWdoZGFzYXJ5YW4gYSDDqWNyaXQgOgo+Pj4gUHJvdGVjdCBWTUFzIGZyb20gY29uY3VycmVudCBw YWdlIGZhdWx0IGhhbmRsZXIgd2hpbGUgcGVyZm9ybWluZwo+Pj4gY29weV9wYWdlX3JhbmdlIGZv ciBWTUFzIGhhdmluZyBWTV9XSVBFT05GT1JLIGZsYWcgc2V0Lgo+Pgo+PiBJJ20gd29uZGVyaW5n IHdoeSBpcyB0aGF0IG5lY2Vzc2FyeS4KPj4gVGhlIGNvcGllZCBtbSB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uZWwg bWFpbGluZyBsaXN0CmxpbnV4LWFybS1rZXJuZWxAbGlzdHMuaW5mcmFkZWFkLm9yZwpodHRwOi8v bGlzdHMuaW5mcmFkZWFkLm9yZy9tYWlsbWFuL2xpc3RpbmZvL2xpbnV4LWFybS1rZXJuZWwK From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5021AECAAA1 for ; Fri, 9 Sep 2022 13:27:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B0D0C6B0071; Fri, 9 Sep 2022 09:27:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A95DE6B0072; Fri, 9 Sep 2022 09:27:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 90F128D0001; Fri, 9 Sep 2022 09:27:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 7BB966B0071 for ; Fri, 9 Sep 2022 09:27:49 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4ADA2AB5CC for ; Fri, 9 Sep 2022 13:27:49 +0000 (UTC) X-FDA: 79892624658.03.C4BA9E5 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf29.hostedemail.com (Postfix) with ESMTP id 82EFD1200C1 for ; Fri, 9 Sep 2022 13:27:48 +0000 (UTC) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 289DC0J7020496; Fri, 9 Sep 2022 13:27:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=xGWZBcP7Vjjt0ne0dV570vSeEqDuHKwNy1/7aKUyKxk=; b=Oc2dEpgxnslVIg0nuXQJTu0mYsSNNfCZdEPdgqnf44ZzwNFf5rfyGVSJJ4lfiVOQ+hDb r2BwmVUe0lsGbIwUDN5sGlpSA/vfWO85w7P5pIEnJdB6IJE26i1yKWa8u41SG99gEE70 HhX0foDFQMIYn6ZaPrWI8W4y5LcEz5bQpK60sxw9GhnpCJHsc/HhH1oVFMqnEQbgNhjJ N2z8IbFkOoTcR1f8Pa7IbC+o7HekL8a43AwEalRa6TwVuD0BwSoKUlCqWgUheNfB7CaU VTVRrsFG9LDLGf9tubkJKlGH5EgtKs/QItlSA8ggvXEteKsKcwkw3FriHYyP6dAFKzAl Zw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jg65j0gfy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Sep 2022 13:27:38 +0000 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 289DCiY4026580; Fri, 9 Sep 2022 13:27:37 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jg65j0gec-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Sep 2022 13:27:37 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 289DKFtx009042; Fri, 9 Sep 2022 13:27:34 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma04ams.nl.ibm.com with ESMTP id 3jbxj901mt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Sep 2022 13:27:34 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 289DRW1Z40501602 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 9 Sep 2022 13:27:32 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 22BB742045; Fri, 9 Sep 2022 13:27:32 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A234742041; Fri, 9 Sep 2022 13:27:30 +0000 (GMT) Received: from [9.145.83.17] (unknown [9.145.83.17]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 9 Sep 2022 13:27:30 +0000 (GMT) Message-ID: Date: Fri, 9 Sep 2022 15:27:30 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: Re: [RFC PATCH RESEND 07/28] kernel/fork: mark VMAs as locked before copying pages during fork Content-Language: fr To: Suren Baghdasaryan Cc: akpm@linux-foundation.org, michel@lespinasse.org, jglisse@google.com, mhocko@suse.com, vbabka@suse.cz, hannes@cmpxchg.org, mgorman@suse.de, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, peterz@infradead.org, laurent.dufour@fr.ibm.com, paulmck@kernel.org, luto@kernel.org, songliubraving@fb.com, peterx@redhat.com, david@redhat.com, dhowells@redhat.com, hughd@google.com, bigeasy@linutronix.de, kent.overstreet@linux.dev, rientjes@google.com, axelrasmussen@google.com, joelaf@google.com, minchan@google.com, kernel-team@android.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-kernel@vger.kernel.org References: <20220901173516.702122-1-surenb@google.com> <20220901173516.702122-8-surenb@google.com> From: Laurent Dufour In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: AKENId9QRksp4m3H-lE_THCmMHniIzD8 X-Proofpoint-GUID: CFGeekGWSpIQRCVQ4AE9GyYndL5KhzSD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-09_08,2022-09-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 adultscore=0 clxscore=1015 priorityscore=1501 mlxlogscore=999 spamscore=0 phishscore=0 impostorscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209090045 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662730068; a=rsa-sha256; cv=none; b=LfeWQggM7fHWreL67KMLLxg5ZwobqxIItnU49y0om+dIvRugCxgRZ5snV0nIGRWeakQTfL tgKwd+jM+ppgmi4qCGCHZg2g2j+9IiCZRTZNXD16TqMdaHPtP6csV9tMs+lHKSa52OkBmH 6eWSNombQJdTLgU7tNFcX719grHuoXk= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=Oc2dEpgx; spf=pass (imf29.hostedemail.com: domain of ldufour@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=ldufour@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662730068; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xGWZBcP7Vjjt0ne0dV570vSeEqDuHKwNy1/7aKUyKxk=; b=vfftjqg1gBiEefuiejzAu4W+f/qtb4kwd7VBrg/r+V6muTqiFU4/OBr0z0pFJwLaYX5Jy4 ENJc8BpIXi+0okWiWIJz8Vu38XREkxki7ThpuWqCG4wmzAuO3wPaesg1S/0BRJkwmumuFw uSDIzGJoqlhD78IPYygj1sqAj4773L0= X-Rspamd-Queue-Id: 82EFD1200C1 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=Oc2dEpgx; spf=pass (imf29.hostedemail.com: domain of ldufour@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=ldufour@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com X-Rspam-User: X-Rspamd-Server: rspam06 X-Stat-Signature: ex9fcaxkykaatfefgne8xjpjt7zm16cw X-HE-Tag: 1662730068-25869 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Le 09/09/2022 à 01:57, Suren Baghdasaryan a écrit : > On Tue, Sep 6, 2022 at 7:38 AM Laurent Dufour wrote: >> >> Le 01/09/2022 à 19:34, Suren Baghdasaryan a écrit : >>> Protect VMAs from concurrent page fault handler while performing >>> copy_page_range for VMAs having VM_WIPEONFORK flag set. >> >> I'm wondering why is that necessary. >> The copied mm is write locked, and the destination one is not reachable. >> If any other readers are using the VMA, this is only for page fault handling. > > Correct, this is done to prevent page faulting in the VMA being > duplicated. I assume we want to prevent the pages in that VMA from > changing when we are calling copy_page_range(). Am I wrong? If a page is faulted while copy_page_range() is in progress, the page may not be backed on the child side (PTE lock should protect the copy, isn't it). Is that a real problem? It will be backed later if accessed on the child side. Maybe the per process pages accounting could be incorrect... > >> I should have miss something because I can't see any need to mark the lock >> VMA here. >> >>> Signed-off-by: Suren Baghdasaryan >>> --- >>> kernel/fork.c | 4 +++- >>> 1 file changed, 3 insertions(+), 1 deletion(-) >>> >>> diff --git a/kernel/fork.c b/kernel/fork.c >>> index bfab31ecd11e..1872ad549fed 100644 >>> --- a/kernel/fork.c >>> +++ b/kernel/fork.c >>> @@ -709,8 +709,10 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm, >>> rb_parent = &tmp->vm_rb; >>> >>> mm->map_count++; >>> - if (!(tmp->vm_flags & VM_WIPEONFORK)) >>> + if (!(tmp->vm_flags & VM_WIPEONFORK)) { >>> + vma_mark_locked(mpnt); >>> retval = copy_page_range(tmp, mpnt); >>> + } >>> >>> if (tmp->vm_ops && tmp->vm_ops->open) >>> tmp->vm_ops->open(tmp); >>