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 AD197C77B73 for ; Tue, 2 May 2023 14:43:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2F6B26B0075; Tue, 2 May 2023 10:43:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 280636B0078; Tue, 2 May 2023 10:43:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0FA196B007B; Tue, 2 May 2023 10:43:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) by kanga.kvack.org (Postfix) with ESMTP id AA8176B0075 for ; Tue, 2 May 2023 10:43:10 -0400 (EDT) Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-50b383222f7so5112433a12.3 for ; Tue, 02 May 2023 07:43:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683038590; x=1685630590; 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=J+/5086jsVPWslGylBI+h1BWl4b4cW16e+2fuLG/twS3CZYX1DrJNADgm1k+XgjjVB 3DFOOtZPJUyg4l5PZGIe6ga8CrLtrwFLOEd9St9/32cRXEddYKb1BOBuacofF7osNCby p/5a7OTlKRGAgN03O189JWQ6933wxglPd1I8NA2cKvTF//0s/QpcDEY3zkhuQyknLIyC lyjV9ncovghmv8HravslhkY7wbM+7E95iJaLjYXlchYSle9P9bdDDJG4bBJi840Yb1Fa RNsuERnjgebDy9LAdMveRB/HTCRe+H76zYNva9xGySTlRh7nK1WFOifbBivODF8rUtr4 3KFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683038590; x=1685630590; 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=JFNQDIyAZTW/vP+Lr3yh+k1q/lUQQA7Oa+EV/m30Y89yKpQeU1EVK7snnFeA/ixGci Ydi8y7+AW/vRgFMUtUlf8eW1byPso1es/i4nqRsynDWRo4WJaievwflqpFYsXNo8ShF5 qUx6rubOH4JYgub/eZ7eY7gxfsUYrpYypQ9gbB6fJ8W6AYpoMtBOJIkcOhxL7FE0aSZ7 066TTPfz8mpyC/UgA8wYs+H/GDYX/P1P83qCAbG0fAjS754MSiIZW1rnfPHoJdkY/N6j 2xOwVieNTR74cmxJXNlSlbri6+8rI3m8TbYuPxRsZifdvd6q6En/bKDxNTBe5qPLqwY/ BCTA== X-Gm-Message-State: AC+VfDwN6PK6cS8jKmY3thi9N7YnmYLd2DZRKGCLeWUjGOMBBAP76vP5 Qxx5RuwecSKloUT6yGOyT+l4HtIWxZwLGA== X-Google-Smtp-Source: ACHHUZ5JpfJxILvMgYMoFZ7s8DTGKSLgm5Nh7/7J6kRKyFAC3eUsj7RlfYPNnWakTy//xgA4VId9Qw== 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-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: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 >