Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6791977rwr; Tue, 2 May 2023 05:47:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4SM6X0gwZntsXAFsKBPjs2t2O3wYXHL39Pjd7kX+xugimwqhAhOzYl+80XR1hkWKMibAPK X-Received: by 2002:a05:6a20:6a28:b0:f0:471f:4aef with SMTP id p40-20020a056a206a2800b000f0471f4aefmr22765911pzk.49.1683031637704; Tue, 02 May 2023 05:47:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683031637; cv=none; d=google.com; s=arc-20160816; b=tL3cn7vQ6DesPAgFbOVFqBcIIBsY1kzi8DlXrLE4wcM3WSgdxcV+ZIj9LCCuNrgzFa SYotzaeSYyWQo0gPOn/3GmWAkt52U538ggx25jJPQEPGf6kC8GBIRKt2Mwnb/uCLRTt8 MtPoOx0QOpWVnA3BX0DN5hWBZcO3R1ADldG+R9y/PidXYMVr842LRGmwvF27qR/xEU5t SLJ6tGjpP09pfxGFrqytwUIDA6O/0LnOf65NWYBO7uboj3TwhYSOsH1QzuFhL8m9nw36 Tmrr3McWWc8WQa0QS02D5d8FdTAq9LlNeFyWCauWE2dI2PaV8h9Nw8t4LM1ZNw9aOWJl CrCA== 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=fgFCgKRt+dSv63SBQS0EqzIPjjsNgS5iABtgfP8KMvY=; b=fADBPNHrI1kFHORoGg+jN+cyt1WVRNAEajTxPRFnKF5jlzu1PttrjjuefpBu0zJaP4 TaEYmC7GymwrMT0/aM0iHb9magtcaBFQp7dlhBHX3j26QfhiGY4mI63iyU4WH47ZKY8G k8BM9iPs3jcF6Emxsphv95N/y2y3j2dNRfONfQb087YQ74KdfANOQGzYuJoYbHGHOK+B B/WBtKCFtW5e+vxZSNk+bxu5Sncb51i6TQLyRO+gT4nLA3Vfl6Azw+H7g+YYSHtYOUl3 V0wp6Ow8Sf86u3Amf/4eWPjhR4pXVK658rqgvwSQXHnLjIEi/E/QXFowb3bRPN/pnQBJ b7Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=Aptl0C9Y; 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 v30-20020aa799de000000b0063b52b9a8f5si29298213pfi.267.2023.05.02.05.47.05; Tue, 02 May 2023 05:47:17 -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=Aptl0C9Y; 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 S234153AbjEBMmJ (ORCPT + 99 others); Tue, 2 May 2023 08:42:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229533AbjEBMmI (ORCPT ); Tue, 2 May 2023 08:42:08 -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 30B8659CF; Tue, 2 May 2023 05:42:06 -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=fgFCgKRt+dSv63SBQS0EqzIPjjsNgS5iABtgfP8KMvY=; b=Aptl0C9YZtVHhIGcqwN9psA40r S+G1CNNeqHBhJQCPyxq8JTFXrIC20oKv3sunDSOsd9zMFsFzTHjtJ4CsBZ6fPZJ9Fw97dzhOQkR6+ sA6Qpx8UwumRQzMSrCbASWhI8qrfpguY0OMXsvQ70o9rTcpsAPZZjvbqrSSxvzgJPR1S4D4W0npH3 w4nNuBkWL7Q9i/HqJgT5Z3cz+f2PzWKV7TdovHV7w5pdECflKTwy6Al+2ErY/vOjCg3YGmjyh4os3 kpxblnvQPN/ZGuQQycvMxD3KXzI5YbnQ1+FGHmUmlZl+0aypr5sF9KDduv3PIftxymNZ2vLshSC+K /6KVXkHQ==; 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 1ptpJW-00GJ5B-34; Tue, 02 May 2023 12:41:04 +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 00898300237; Tue, 2 May 2023 14:40:58 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id BB0FB23C5C34C; Tue, 2 May 2023 14:40:58 +0200 (CEST) Date: Tue, 2 May 2023 14:40:58 +0200 From: Peter Zijlstra To: Lorenzo Stoakes Cc: 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 , David Hildenbrand , Dave Chinner , Theodore Ts'o , Peter Xu , Paul McKenney Subject: Re: [PATCH v6 3/3] mm/gup: disallow FOLL_LONGTERM GUP-fast writing to file-backed mappings Message-ID: <20230502124058.GB1597602@hirez.programming.kicks-ass.net> References: <20230502111334.GP1597476@hirez.programming.kicks-ass.net> <20230502120810.GD1597538@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230502120810.GD1597538@hirez.programming.kicks-ass.net> 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=ham 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 02:08:10PM +0200, Peter Zijlstra wrote: > > > > > > > > > if (folio_test_anon(folio)) > > > return true; > > > > This relies on the mapping so belongs below the lockdep assert imo. > > Oh, right you are. > > > > > > > /* > > > * Having IRQs disabled (as per GUP-fast) also inhibits RCU > > > * grace periods from making progress, IOW. they imply > > > * rcu_read_lock(). > > > */ > > > lockdep_assert_irqs_disabled(); > > > > > > /* > > > * Inodes and thus address_space are RCU freed and thus safe to > > > * access at this point. > > > */ > > > mapping = folio_mapping(folio); > > > if (mapping && shmem_mapping(mapping)) > > > return true; > > > > > > return false; > > > > > > > +} So arguably you should do *one* READ_ONCE() load of mapping and consistently use that, this means open-coding both folio_test_anon() and folio_mapping().