Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6811914rwr; Tue, 2 May 2023 06:03:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ54QHXPTcnpqfyJ+tilPfWklmRYcDz+j/Nrh9cpTHV43kUgkMt4rT0nTQyy+vZkTx+sQCMj X-Received: by 2002:a05:6a20:3d8e:b0:f2:1a72:2a8d with SMTP id s14-20020a056a203d8e00b000f21a722a8dmr21027801pzi.14.1683032582613; Tue, 02 May 2023 06:03:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683032582; cv=none; d=google.com; s=arc-20160816; b=LOoLZkFCViX6VHXWxaamuaj44B9HIKtaZF1j1vPCQ62vETUSsAwjYR1VHwpHWVuNNh YnMBPTUwY8r439Z4JQ48tlBJQH3O75RqxuJQWsJdeASLU1Vv+cOoJJwkKblRpd+NotNw GBCuC3voT5KoGRyQgX8B78AQGmngMvUZ1LyxzcOdH1CTXpuiD0kt0tRL7Zi0QzXhKFiz 15Ye6H0uhIAzqHHUJMxFhfucCKtnyYT5XuBqIMjFAPN4qtj22PK/n7x/dWi/tWslN2g3 rDXzhmS1SHE/1VIF1bQQjTEdcjZyxXKpYqKqO2NDie31GtpgZey9l0wPsN/efFyTV59k T+vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=X2TPQPGBRapYWkLRNRk6kGJOLk5A8AsKc2WUiv6CjPA=; b=O61bDrneCOHnwQ1lyKqwljM/lfaNqozFlxst7mHoWK3pXPLntHdR69WoxLx/204x6E njyVO4cCMgV4LyKvAjB1sG1HoRbu6v67InYsaeEBILdci/ZR9XBZFCwETYV0mRaImJqy O92fVJijUQdml02v+vR9VcYrmHGrAkAF3F1bH8iaczz9FMM6luyAbnahNbcS2E03CzIR fD62xoUBP8jq/2fc1jdOFnoMTmi2PIYIc8Z4CfOdb+ynYr57PguGOjIQ8rs/HeAWh9sn pET89epQE67D3cBcQyCAjb4FSEYMb4iZG0iRHgZRYwdX8lV5rvRcUnV89DcauRlsKNAQ WEOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ElRw7vqW; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g5-20020a63dd45000000b0052c242b0231si4531879pgj.146.2023.05.02.06.02.38; Tue, 02 May 2023 06:03:02 -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=@redhat.com header.s=mimecast20190719 header.b=ElRw7vqW; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234188AbjEBMyU (ORCPT + 99 others); Tue, 2 May 2023 08:54:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233513AbjEBMyS (ORCPT ); Tue, 2 May 2023 08:54:18 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 983CD5FF4 for ; Tue, 2 May 2023 05:53:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683032005; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X2TPQPGBRapYWkLRNRk6kGJOLk5A8AsKc2WUiv6CjPA=; b=ElRw7vqWGmeaDmBIJm+L5gnzuh+lFwUUFqA1MRclkMZ6vfZ58jY9vPLmmUOa5onl8nq7qu V+d9fQOXk9A5p/rvZ6fEORBJr8jSe729f40YtyJ3IQRnGl9jwkPHcosHKZ01I6nPX34frh dhN/cquyIPpS3G5KEr9D+z25p6gsr30= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-663-WLXVnmOXMzis9Pk1F9HH0Q-1; Tue, 02 May 2023 08:53:24 -0400 X-MC-Unique: WLXVnmOXMzis9Pk1F9HH0Q-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-306281812d6so997373f8f.2 for ; Tue, 02 May 2023 05:53:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683032003; x=1685624003; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=X2TPQPGBRapYWkLRNRk6kGJOLk5A8AsKc2WUiv6CjPA=; b=Zpfi2TLIoSt4nuty/33lWgdSyTKGpeW+Xunp4Y1fCQ/MF7Y7AULm3jBu9f+RpOYY0t VIAUTlXbOwayg+gWXRqbPeRGKeOkkrPeH92YeHm+QvRBb6HJFSeXBql64hnLAh0k9M4/ 1MxlT9JDWhISQIgUjrtmD+5E+1WRx3HqF6+l78Mf0lQocUGJXqSx1uY2Wz8zZ2GKNbXn S1mDqiJPgEWH8Ur49nu6077VwjR8YMbr+dyxwKBo8Es3vKhL5T/PReRHKfflZ6tih5DG H+Lw+af+mbB4yrwK6ljNgQYjJiLgiXFjBQd9CR+cla7NfyvVhZGlRQM24vf8bTnQvdQf XWHw== X-Gm-Message-State: AC+VfDzSCnmcxkiPXKWpp3cVbeDkqMfLjaUGWFQVi67KaFuv3eCKAGKp 08PKxzvObScCnandDHz83tkeW8nOn8JBUiq/cAI+Pg++Q+Qa9soeDSm6KdxCHakNAYGD17svtQI hyK4ivsLy9b+NMYoDyZO3l3xE X-Received: by 2002:adf:ef52:0:b0:306:b48:3fc4 with SMTP id c18-20020adfef52000000b003060b483fc4mr8043887wrp.31.1683032003225; Tue, 02 May 2023 05:53:23 -0700 (PDT) X-Received: by 2002:adf:ef52:0:b0:306:b48:3fc4 with SMTP id c18-20020adfef52000000b003060b483fc4mr8043814wrp.31.1683032002215; Tue, 02 May 2023 05:53:22 -0700 (PDT) Received: from ?IPV6:2003:cb:c700:2400:6b79:2aa:9602:7016? (p200300cbc70024006b7902aa96027016.dip0.t-ipconnect.de. [2003:cb:c700:2400:6b79:2aa:9602:7016]) by smtp.gmail.com with ESMTPSA id u12-20020adfdd4c000000b0030635735a57sm2320577wrm.60.2023.05.02.05.53.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 May 2023 05:53:21 -0700 (PDT) Message-ID: <482f0c6e-ca5f-d0c2-1d99-ca26f70565df@redhat.com> Date: Tue, 2 May 2023 14:53:19 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v6 3/3] mm/gup: disallow FOLL_LONGTERM GUP-fast writing to file-backed mappings Content-Language: en-US To: Lorenzo Stoakes 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 References: <20230502111334.GP1597476@hirez.programming.kicks-ass.net> <20230502120810.GD1597538@hirez.programming.kicks-ass.net> <20230502124058.GB1597602@hirez.programming.kicks-ass.net> <4529b057-19ae-408b-8433-7d220f1871c0@lucifer.local> From: David Hildenbrand Organization: Red Hat In-Reply-To: <4529b057-19ae-408b-8433-7d220f1871c0@lucifer.local> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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 02.05.23 14:52, Lorenzo Stoakes wrote: > 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. Ha, I only stared at that reply, good! :) -- Thanks, David / dhildenb