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 X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B76D6C4363A for ; Tue, 27 Oct 2020 00:14:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1A31320754 for ; Tue, 27 Oct 2020 00:14:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="Kka79kbJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1A31320754 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4E0BD6B005C; Mon, 26 Oct 2020 20:14:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 490666B005D; Mon, 26 Oct 2020 20:14:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 37FF56B0062; Mon, 26 Oct 2020 20:14:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0063.hostedemail.com [216.40.44.63]) by kanga.kvack.org (Postfix) with ESMTP id 09C6B6B005C for ; Mon, 26 Oct 2020 20:14:55 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id A8EBF181AEF00 for ; Tue, 27 Oct 2020 00:14:55 +0000 (UTC) X-FDA: 77415784950.12.stamp02_631178a27277 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 89B85180101EE for ; Tue, 27 Oct 2020 00:14:55 +0000 (UTC) X-HE-Tag: stamp02_631178a27277 X-Filterd-Recvd-Size: 4561 Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by imf26.hostedemail.com (Postfix) with ESMTP for ; Tue, 27 Oct 2020 00:14:55 +0000 (UTC) Received: by mail-lj1-f195.google.com with SMTP id i2so12605556ljg.4 for ; Mon, 26 Oct 2020 17:14:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8pq1ZiLJCFcmgBv0JcKGMbgbJxC9bbLjRkNwBgcJh0Q=; b=Kka79kbJMSIegb0otW5XpEZGBA5SvJVApuOIDNwAYEJudE5IEDU8uS9xOVp8VPCJd7 b6SXjLkGUDOsdUxN6GxdMaer4vbcu+m0lMCl4yUVEtnWOLc2Gy49/vh4f/10qgVdNAuy U7v/pMBYIdx1aSuJTLPA4PxgXktFn6T53RTT0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8pq1ZiLJCFcmgBv0JcKGMbgbJxC9bbLjRkNwBgcJh0Q=; b=DWvcO01634+0EQa9Zmez+5yDKD71UqVVUa2CjLIy09glShRpLRrLihgr4rdAvTScN+ l8ynOd62NEpyReti3kgUm+3vatAdjdguYMZFuuv066LYlouJpjvNeVRuVUv6h/mKfLQ+ XDYEalGoRYGx7Ofd5fqn+/0r/WuONVakt4maMqY35kgVb4OK2lhbJkR1rpDG8D5VmVIB ynm3dXK8m/qXyOR12BwWm8vu6Va7w82qWHpgF8UQ8wd9uECcgZLL8LocIo38W2eyrc63 3yaEF1ydfdH2Lt36nfx9V/QRr5c2xQj7A7xcL06kqh6Y5A47Oa/oWOHpOHz3DVETPEiV 5LkA== X-Gm-Message-State: AOAM530Wh+/fNJvg/+cII5S4yBUBTeI4doXq0Uy2BOhsYjsTmdXhz3AM rQatLkMZa1rN+VHs0T//5yVuRt9mu8vE3g== X-Google-Smtp-Source: ABdhPJxbtAalyP9qv4D7I3XysGlKXQBcMx0SSw4mZKaROv3eisKwaPr127JTTYkvoeLbDwqpTyg0VA== X-Received: by 2002:a05:651c:336:: with SMTP id b22mr7530631ljp.75.1603757693097; Mon, 26 Oct 2020 17:14:53 -0700 (PDT) Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com. [209.85.167.47]) by smtp.gmail.com with ESMTPSA id a7sm1196896lfo.18.2020.10.26.17.14.51 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Oct 2020 17:14:51 -0700 (PDT) Received: by mail-lf1-f47.google.com with SMTP id h6so14798442lfj.3 for ; Mon, 26 Oct 2020 17:14:51 -0700 (PDT) X-Received: by 2002:a19:cbcb:: with SMTP id b194mr6627878lfg.133.1603757691217; Mon, 26 Oct 2020 17:14:51 -0700 (PDT) MIME-Version: 1.0 References: <2-v1-281e425c752f+2df-gup_fork_jgg@nvidia.com> <32a38d92-6ecc-243b-77be-8f1ea0792334@nvidia.com> <20201026234952.GD1523783@nvidia.com> In-Reply-To: <20201026234952.GD1523783@nvidia.com> From: Linus Torvalds Date: Mon, 26 Oct 2020 17:14:35 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/2] mm: prevent gup_fast from racing with COW during fork To: Jason Gunthorpe Cc: John Hubbard , Linux Kernel Mailing List , Andrea Arcangeli , Andrew Morton , "Aneesh Kumar K.V" , Christoph Hellwig , Hugh Dickins , Jan Kara , Jann Horn , Kirill Shutemov , Kirill Tkhai , Leon Romanovsky , Linux-MM , Michal Hocko , Oleg Nesterov , Peter Xu Content-Type: text/plain; charset="UTF-8" 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: On Mon, Oct 26, 2020 at 4:50 PM Jason Gunthorpe wrote: > > Right, it isn't a "seqcount" because the read side doesn't spin. Not all readers spin for seqcount either. Sure, it's the *common* case, but look at name resolution - it will basically fail on a seqcount failure in RCU mode, and go to the "slow and safe" version: if (unlikely(read_seqcount_retry(&d->d_seq, nd->seq))) return -ECHILD; Exactly like gup_fast vs fork, in fact. So no, you don't need to retry for seqcount failures, doing seq = seqcount_begin(..); ... optimistic fast case ... if (!read_seqcount_retry(.., seq)) return 0; // success .. do slow case ... is valid and happens. Linus