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 63A0BC6FA8B for ; Thu, 8 Sep 2022 23:57:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D85FB8D0003; Thu, 8 Sep 2022 19:57:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D35378D0001; Thu, 8 Sep 2022 19:57:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BFD3D8D0003; Thu, 8 Sep 2022 19:57:30 -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 B007F8D0001 for ; Thu, 8 Sep 2022 19:57:30 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 80EE1A0386 for ; Thu, 8 Sep 2022 23:57:30 +0000 (UTC) X-FDA: 79890582660.16.3336684 Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) by imf03.hostedemail.com (Postfix) with ESMTP id 174EE20072 for ; Thu, 8 Sep 2022 23:57:29 +0000 (UTC) Received: by mail-yb1-f178.google.com with SMTP id 11so414335ybu.0 for ; Thu, 08 Sep 2022 16:57:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date; bh=fjRx/Lr4rWG8FdNjepWfPwinvttFV+7WLgO00cFoqzc=; b=eex6cV74s4M8HeKkMm8twe1wMmlZy8xPylfXxTCwczLvM6rjy9aZnLRWAV94lwFweL wAYpV8vwszuecJPQnwFpuZcAWGq+gpGawG4NDhdV/gC5fkudZU59f9HbpteQ+lQOcY0I GAuQhYX7csyCScbjD5jgdN/lxX0hV5690Tcj8OCWTWHOdxz1phA0WKGeiTCECkVAzaLw sEfntZDZ1/grg22e7rWeAYxWauW5E1ZRZA2dGh5d7M8MUfKjS+PoLz8YplH1AxLv4mjU xBy4gnrkKgV0FDBrrfwV2xX69XGlTUWccShysi4f6ykbn3u/y4iOr6sGj4cHuPbiwDv6 bZNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date; bh=fjRx/Lr4rWG8FdNjepWfPwinvttFV+7WLgO00cFoqzc=; b=I44y2mecTX1DN7kI1twjGxfiCYqtblp8HnTc8r9HzcztC2eUvLi9VVP+xGVkA/qbxy 80LGzf9r84R15IxKO7+y3rqKI0LoqUadQ/qfIqV999cRsARKtIQo38cb1+u6owc7Tsun 4pa8RDwIAg6HT8hvA0AIiP/qSBJgjop1qNgfsvOIjbAMc8Bny8h7FV/jNPLP9ChDAu6T 4eiApYiEcri5TPS4JHeqEzWa3DERwN1J2WV0hPZ7EmHA8WfpCiB66n1RDPF6o6t25q9V rav6W864Pb36/1I3LxqTchhdvMxyBEgsKxny6t5K8s+KbIS79Smh+ndiA+TobAfKcgGN sKcQ== X-Gm-Message-State: ACgBeo1Ar4+pGe0vtDJXf3EHJt8y9BepBJdWsMn5mqZe+Xy/C2Y5CwXn xPoNvJaeNROR1Gv/5MHd5hxN6Zof82W7z9XrH/PKyw== X-Google-Smtp-Source: AA6agR5z3AebbL5Azy4sNoMfTt0gW01VpIp+qr6/rNEQLn3rNpaHhq14wg8Eeh+706sD3nPJeGD6bnyLQT+FGI+FElY= X-Received: by 2002:a05:6902:2d0:b0:694:d257:4c4b with SMTP id w16-20020a05690202d000b00694d2574c4bmr9669475ybh.316.1662681449064; Thu, 08 Sep 2022 16:57:29 -0700 (PDT) MIME-Version: 1.0 References: <20220901173516.702122-1-surenb@google.com> <20220901173516.702122-8-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Thu, 8 Sep 2022 16:57:17 -0700 Message-ID: Subject: Re: [RFC PATCH RESEND 07/28] kernel/fork: mark VMAs as locked before copying pages during fork To: Laurent Dufour 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662681450; a=rsa-sha256; cv=none; b=C0XTxKEpgC8mYyRZefvGOkXXDphgXudt7WeWP0yKgA8Zzu3wmNCmO+EgeCLHDsgXKuuAh1 ws4PQpHdvzr8VCcHs8QVNz14L7IevbpBjpzOi9Rgm26+675D//boDz9LozDKFABD2NmLQ/ x7JMb0VEtN0xYqFgGvvDd0kFabKIxV8= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=eex6cV74; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf03.hostedemail.com: domain of surenb@google.com designates 209.85.219.178 as permitted sender) smtp.mailfrom=surenb@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662681450; 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=fjRx/Lr4rWG8FdNjepWfPwinvttFV+7WLgO00cFoqzc=; b=Bm8H/kgtmgzGvMdr2hOnT8BWa/9SiZ6ul7Rswj947wvY2yGI30iOw84/Yv/qYLwkSP+8/d K+lQbuuLp5fCFChEsTc5to1p01QLMR2F9OByXyBwFL9EugnuIup8XkVZkFkHUfSZyf7gvO yvfpALryAj5MuElgQNP7LCU64JrOFe4= X-Rspam-User: X-Rspamd-Server: rspam05 Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=eex6cV74; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf03.hostedemail.com: domain of surenb@google.com designates 209.85.219.178 as permitted sender) smtp.mailfrom=surenb@google.com X-Stat-Signature: 3f4ip8eui3m9fe5htsdcdojx5ktfmihh X-Rspamd-Queue-Id: 174EE20072 X-HE-Tag: 1662681449-996094 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000113, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Sep 6, 2022 at 7:38 AM Laurent Dufour wrote= : > > Le 01/09/2022 =C3=A0 19:34, Suren Baghdasaryan a =C3=A9crit : > > 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 handl= ing. 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? > I should have miss something because I can't see any need to mark the loc= k > 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_str= uct *mm, > > rb_parent =3D &tmp->vm_rb; > > > > mm->map_count++; > > - if (!(tmp->vm_flags & VM_WIPEONFORK)) > > + if (!(tmp->vm_flags & VM_WIPEONFORK)) { > > + vma_mark_locked(mpnt); > > retval =3D copy_page_range(tmp, mpnt); > > + } > > > > if (tmp->vm_ops && tmp->vm_ops->open) > > tmp->vm_ops->open(tmp); >