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 37BDCC7EE25 for ; Tue, 2 May 2023 14:40:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3BF2A6B007D; Tue, 2 May 2023 10:40:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A9146B007E; Tue, 2 May 2023 10:40:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0AD5A6B0080; Tue, 2 May 2023 10:40:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by kanga.kvack.org (Postfix) with ESMTP id D46186B007D for ; Tue, 2 May 2023 10:40:15 -0400 (EDT) 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-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 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().