Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6815714rwr; Tue, 2 May 2023 06:04:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6U29oDFOd/l7SArm3bUezN3vifpfbuQdKNe3RXHNylIcJhojj8wXduaPzn/tRIz0VYfbFg X-Received: by 2002:a17:902:d3cc:b0:1a1:b172:5428 with SMTP id w12-20020a170902d3cc00b001a1b1725428mr15181192plb.18.1683032696840; Tue, 02 May 2023 06:04:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683032696; cv=none; d=google.com; s=arc-20160816; b=IzWCBISiExNj5h5uSHxyQUerUFE4yrPPGTt7A5elH2E8IvZCxJuhgnQSRXOJdq0RRl Ued4yJOk48qowNy2hV88B/nH38Eag/5eATJ6v/+n0+9tpx1rDey68xB6Dnkw8OGHtjLt U40XXk0Zf3DXk0e5ElPnZAoG3ebD+qvPdnQYWeQxXwteRDw4Ooc+eupHUYM49JX1ND0m 9bKa225KKKr5s1NyAm/4vTO3LpVxr2D1ABfCGF/4zGcb8iOogbkqlx34/enhrEwTGZo3 CLsYSvmBL58/t6q56GCoDHS0criEF62arQ4g9up8zPsS9g1l0Y9m6q1DEMoPNEB0AP/F Aw3A== 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=tgwBcf7DhZhRTBqFpSufVvlB/n4MHMrRDDLyfB3lDk8=; b=ejGnnCzlag3Uk5t5nM6b80NUZebBKJzhpfJAKehGXVRloj6ScOAZdH1GMXZ61h2qb7 dPsMLLAC6UHJ1uFq+17lzPQPHBg3cciHMLtIoV2XjAJoc9FVnHQ4JST8ajBOazyJQHLf xsChavWgChvIXz2PKES84kbqET/NjXB5lsb5ihJAyh5uIKD3YpVbsMba2B1iqidvdsoI bgtidHqk5xcvO9KOAaEqsHSCshi2mhp1MuPRU8mRWjVM5sS9zFh38pwRiG+36OvNSkDS lHVnvHp5/LexT6UAsBQhyYdC+V9PlBjB1jOkMxjnmNOEmxoV9ePqoyyc/wrwQUZgBG21 Y8Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=RTXVfHTQ; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z5-20020a170902d54500b001a6d9d4567esi30140770plf.328.2023.05.02.06.04.34; Tue, 02 May 2023 06:04:56 -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=@gmail.com header.s=20221208 header.b=RTXVfHTQ; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234253AbjEBMwY (ORCPT + 99 others); Tue, 2 May 2023 08:52:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233857AbjEBMwV (ORCPT ); Tue, 2 May 2023 08:52:21 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E99EE4D; Tue, 2 May 2023 05:52:20 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-2f40b891420so3612259f8f.0; Tue, 02 May 2023 05:52:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683031939; x=1685623939; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=tgwBcf7DhZhRTBqFpSufVvlB/n4MHMrRDDLyfB3lDk8=; b=RTXVfHTQcYWexO8uKN4oGh7/UbDzqHFdpYK9PCwoAdzgWP2NG/zuT+WQ8hBJxyxSal 7E2hDW9yo9dKRz4XU8FVvhKw8yM2AAZBPDBp8qGqBtkZ5yRt8nu5FxusbEUcYf3lTohH 1t4yl6qx5lbtlGON9lRmoX8dCRpqmIJGWFMTfivpxQ9kXIh5yORMdd96zBeDsJGtsg32 GFoR0TxTwX/BbYCOyy4PbKdzhFXOBKO7S7xFn4tJDGnJTnosOyQhvVJlzMsvmCtYZ+h0 sXTYLyAGSYxx38UKmxt9v/mQeBoxilLUFoqiLY9gtwa1ZIY6G7g+OfsfFgd3MtRhaahE jwNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683031939; x=1685623939; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=tgwBcf7DhZhRTBqFpSufVvlB/n4MHMrRDDLyfB3lDk8=; b=N06bS1S5DD70U5qBpn1PkygeklkNiZntrFwwEZH4KWXB2RNzR3K3vlcKh6P0vBwF9s aWh4M32ID27L2oYN7/tlnu0t+JXHYAT+GCXO2KG6/5tKbpEFuDNpW77av85XRwARdv6+ qoFUnsa9CclyKlPHLSKnUq28I6OCFHMgYpny/aOSJ0oMx1JMO57xVdkVwCUhegRazKmc jFn8NcdQMB2hVkqKhN4fyIxibULGpHUq18+Eg+CFsx1qZ6UUfwAUA3V+7AaqCCQm8qXd BCI2YiYG0XApZcc+8aIAWHXGlfQZCVJ5eBtU6ddDaGlnBDzqDsGB6PZDjkVMyr1YixE7 /j3A== X-Gm-Message-State: AC+VfDyoKhU3CZcHSiPXl3vmJR1cdhhVR3URyX6FrmxepUdRT+CpQGp9 hPDI66I5Rs3vEl1Q647/Uxo= X-Received: by 2002:adf:f491:0:b0:306:35d1:7a98 with SMTP id l17-20020adff491000000b0030635d17a98mr2068400wro.8.1683031938861; Tue, 02 May 2023 05:52:18 -0700 (PDT) Received: from localhost (host86-156-84-164.range86-156.btcentralplus.com. [86.156.84.164]) by smtp.gmail.com with ESMTPSA id f11-20020adffccb000000b002f90a75b843sm30912077wrs.117.2023.05.02.05.52.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 May 2023 05:52:17 -0700 (PDT) Date: Tue, 2 May 2023 13:52:17 +0100 From: Lorenzo Stoakes To: David Hildenbrand Cc: Peter Zijlstra , 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 , Paul McKenney Subject: Re: [PATCH v6 3/3] mm/gup: disallow FOLL_LONGTERM GUP-fast writing to file-backed mappings Message-ID: <4529b057-19ae-408b-8433-7d220f1871c0@lucifer.local> References: <20230502111334.GP1597476@hirez.programming.kicks-ass.net> <20230502120810.GD1597538@hirez.programming.kicks-ass.net> <20230502124058.GB1597602@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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:47:22PM +0200, David Hildenbrand wrote: > On 02.05.23 14:40, Peter Zijlstra wrote: > > 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(). > > Open-coding folio_test_anon() should not be required. We only care about > PAGE_MAPPING_FLAGS stored alongside folio->mapping, that will stick around > until the anon page was freed. > Ack, good point! > @Lorenzo, you might also want to special-case hugetlb directly using > folio_test_hugetlb(). > I already am :) I guess you mean when I respin along these lines? Will port that across to. > -- > Thanks, > > David / dhildenb >