Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7276789rwr; Tue, 2 May 2023 12:05:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ73ia1Sl6goJpRRG88vgjKTOvLuS/EUBbYYxznuWNj5+2JYwVeTzeYCcUnh+eBwZCuA9fKw X-Received: by 2002:aa7:888f:0:b0:63d:254a:3900 with SMTP id z15-20020aa7888f000000b0063d254a3900mr23674465pfe.5.1683054316953; Tue, 02 May 2023 12:05:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683054316; cv=none; d=google.com; s=arc-20160816; b=op4SRBd/UPMnWq9pZ6g0xU1QrkL9HQTLfng3sWDZSjnT+MtvTRhdcB7awTlzo3MUJ3 ctOP+4rUYjh2LlW7xAUYyaO0jCh1/0I/aTwMtLy4KgUUpNyxrN/kG1nKAMVzYvxVidxg lDIwtnSxXj+3amyvJrQldqeByupOWqqPuKUs+teq/7CiPXeKiwC+W2//4W9xFNLdds3J ghh/T/mykXciZ+VoTpHpP6bhNNUhQQcMzemxYsdPpssT+lbfiv2j+Idcad5Jnb17ES3b 97ydIKLa9xAI+vjXVwCBGRAPyTa89Ete1To56JjYzpZ8ysj0mTrxldNu5cRXXrfJ5dmm 9r8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=FvSMqnwpZ7YArJ7yAdLPKVO6ucbLedkU0RVbReJGMsg=; b=ivUIxj5manCCymV0+lK1HBDrEQ7SwMTBL+fCoTe7brwYOs35rO2BwDhBQUFXeLxsga vJKsj9nypBs2cx1r6J8R0InHpHjXANsLRPb4u7OSMjD17mdWj8nDrlfmuVqL5q2Z3Viw 2W1N7lP2VFvdAQs69+fLa/iXpJ9qEA6+anBq0osIu10HVfr01khZYezq4/g0NodaK1qb doYC6/IG3vmD6n/A7uetBju/5nDkAuUhMuEjhUxyYCfaAvxJD4gS3LugbqKKD97CMc1l WEXWCfcrvNHdAm80Ggffn91WYCmNZZ9SoNIGc+xE6a6JmNJ+SqrqorymYCLurKni1F9M I2WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=im1a3K9i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i26-20020a056a00005a00b0063b1421d10fsi32562184pfk.222.2023.05.02.12.04.53; Tue, 02 May 2023 12:05:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=im1a3K9i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229600AbjEBTAR (ORCPT + 99 others); Tue, 2 May 2023 15:00:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229511AbjEBTAQ (ORCPT ); Tue, 2 May 2023 15:00:16 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0628510C6; Tue, 2 May 2023 12:00:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=FvSMqnwpZ7YArJ7yAdLPKVO6ucbLedkU0RVbReJGMsg=; b=im1a3K9i2SW/qcYQ+dg7YIx54R rqscrI7KXcuedVTnRv1n+NvojKZ8Pv7yJ66Rw4J7w1GUOIvGxdWPY9o3J6bSmaNY7WypGTY5kFX6G 4fAfplgI0bffu7hYgq9CahhkRrCxbsclQIK0NDDndRSlyyUcZZxo9ce1rrzb39UXaHz7f6VHQkyd+ 2VKyz/QNJklZieaviHL5Uyk4p3FjzNvnl7ThlhtDQz+BPdeiJgIfAxCyJ8VO2dSMCh+JoOem2ypc/ hrxIhdofIBgvBLxhoYyV+nXLl3JnIPGV/t1H3b7ZLcslLCefANRiKQdnNwSgfeH9Q6kKGwHrq/haU 8dIy61iw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1ptvDl-00GOxe-0W; Tue, 02 May 2023 18:59:29 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id D0D723033A5; Tue, 2 May 2023 20:59:26 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 89DBC241B3FAB; Tue, 2 May 2023 20:59:26 +0200 (CEST) Date: Tue, 2 May 2023 20:59:26 +0200 From: Peter Zijlstra To: David Hildenbrand Cc: Lorenzo Stoakes , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Jason Gunthorpe , Jens Axboe , Matthew Wilcox , Dennis Dalessandro , Leon Romanovsky , Christian Benvenuti , Nelson Escobar , Bernard Metzler , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Bjorn Topel , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christian Brauner , Richard Cochran , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , linux-fsdevel@vger.kernel.org, linux-perf-users@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, Oleg Nesterov , Jason Gunthorpe , John Hubbard , Jan Kara , "Kirill A . Shutemov" , Pavel Begunkov , Mika Penttila , Dave Chinner , Theodore Ts'o , Peter Xu , Matthew Rosato , "Paul E . McKenney" , Christian Borntraeger , Mike Rapoport Subject: Re: [PATCH v7 3/3] mm/gup: disallow FOLL_LONGTERM GUP-fast writing to file-backed mappings Message-ID: <20230502185926.GE4253@hirez.programming.kicks-ass.net> References: <1691115d-dba4-636b-d736-6a20359a67c3@redhat.com> <20230502172231.GH1597538@hirez.programming.kicks-ass.net> <406fd43a-a051-5fbe-6f66-a43f5e7e7573@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <406fd43a-a051-5fbe-6f66-a43f5e7e7573@redhat.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 02, 2023 at 07:34:06PM +0200, David Hildenbrand wrote: > Now, if we read folio->mapping after checking if the page we pinned is still > mapped (PTE unchanged), at least the page we pinned cannot be reused in the > meantime. I suspect that we can still read "NULL" on the second read. But > whatever we dereference from the first read should still be valid, even if > the second read would have returned NULL ("rcu freeing"). Right, but given it's the compiler adding loads we're not sure what if anything it uses and it gets very hard to reason about the code. This is where READ_ONCE() helps, we instruct the compiler to only do a single load and we can still reason about the code.