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 C4E1EECAAA1 for ; Tue, 6 Sep 2022 14:38:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D86A80292; Tue, 6 Sep 2022 10:38:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2881480224; Tue, 6 Sep 2022 10:38:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 128B880292; Tue, 6 Sep 2022 10:38:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 02ED380224 for ; Tue, 6 Sep 2022 10:38:45 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C28F5C1973 for ; Tue, 6 Sep 2022 14:38:44 +0000 (UTC) X-FDA: 79881916968.01.E38C99F Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf24.hostedemail.com (Postfix) with ESMTP id 48000180099 for ; Tue, 6 Sep 2022 14:38:44 +0000 (UTC) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 286EbI5C029842; Tue, 6 Sep 2022 14:38:36 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=gi2ZlfxV5Hgfo9RiYLHxLSZPMR7vam++rfIqtzjSQY4=; b=mWqExy/Wiz6255uGl+9653onJ3O580ccHYf0IL43u1mZ7zV9CLcDMSbgUwb8gCI8n8Aw eS2/17X5PiZ17Hq/ow9fVrD9QvpYr+RwSlr1h6OcEiTXg3GDS+VdWfsn8tXvqJ9bz2zE o4kaSQPTl5UDEPOd2ysadJQ/2gO2o8lbnMeq/l74yIGQ5Vi9iVlF9m6eiNAnUr2sJZiL Sdc/QWf7Z6EzKGK8HMZ/dNBh6DmRDLT+zTcgUmvwKfB3Izxw8AuhMBBdukY2ju2IBKCZ R0c7LqdoQNV2Jdy8vqYCbddtuTW1yjEZon9Jbd08putGzvH2KUyRfPQj9fk0T1/FKePp WQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3je7ersyy9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Sep 2022 14:38:35 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 286EbGCN029698; Tue, 6 Sep 2022 14:37:59 GMT Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3je7erswh9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Sep 2022 14:37:58 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 286EaZkN020454; Tue, 6 Sep 2022 14:37:35 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma06fra.de.ibm.com with ESMTP id 3jbx6htvcp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Sep 2022 14:37:35 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 286EY4CG40632812 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 6 Sep 2022 14:34:04 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2103CA405F; Tue, 6 Sep 2022 14:37:33 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F1783A4054; Tue, 6 Sep 2022 14:37:31 +0000 (GMT) Received: from [9.101.4.33] (unknown [9.101.4.33]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 6 Sep 2022 14:37:31 +0000 (GMT) Message-ID: Date: Tue, 6 Sep 2022 16:37:31 +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.0 Subject: Re: [RFC PATCH RESEND 07/28] kernel/fork: mark VMAs as locked before copying pages during fork Content-Language: fr To: Suren Baghdasaryan , akpm@linux-foundation.org Cc: 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: <20220901173516.702122-8-surenb@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: mfguNNVm0_tm7y6g6IsvzoVzzb6lC0DJ X-Proofpoint-ORIG-GUID: KUCBt6EYsH8QfRM1q5ERagYwC0h9nhBV 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-06_07,2022-09-06_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 adultscore=0 mlxscore=0 impostorscore=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 spamscore=0 phishscore=0 mlxlogscore=956 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209060070 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662475124; a=rsa-sha256; cv=none; b=ZzznFx0/8FeWftD5IYCorfafmYL1njYIUdJhxRRDy0dlXiFZREch6PvE2t+UytJ3hnaUF8 lAgnRWyeDiJwYwETZP8FADn4SPb/kuesJrUGX3EGTTj9ZVk8MnJe9wESODsR7lRTdfbWd6 vxOiTlmhwKNE2dpsLmllkkt3hvcNk/4= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="mWqExy/W"; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf24.hostedemail.com: domain of ldufour@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=ldufour@linux.ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662475124; 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=gi2ZlfxV5Hgfo9RiYLHxLSZPMR7vam++rfIqtzjSQY4=; b=VCo9IborDEJ6wumZrFA4Pe5qdsCZwKlP+hM6Hlgwsy9QWuOhWaD2iL6vqysLJpNI4oXIXZ OAuqvum52oHunDluPrmb397xLD6GuD/xOEUv3guJeTBbam/oSIGdyMS/fbq2lUlL0aPCV4 9h0mVtHRDzGK7qbzwenqJQJe8e0Ivi0= X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: pbbwpx19idiqryc963oxyyjxo1gijjai Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b="mWqExy/W"; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf24.hostedemail.com: domain of ldufour@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=ldufour@linux.ibm.com X-Rspamd-Queue-Id: 48000180099 X-HE-Tag: 1662475124-834737 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 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. 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);