Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6794386rwr; Tue, 2 May 2023 05:49:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ51K9BWfH2Zbyzbvm/z5pwhDqoQ4fyNhLMmSNMCkpae2AKqapTtXhkYVWvnaIJnVJoe5dNW X-Received: by 2002:a05:6a20:4420:b0:f3:4da0:a25d with SMTP id ce32-20020a056a20442000b000f34da0a25dmr23352962pzb.13.1683031770296; Tue, 02 May 2023 05:49:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683031770; cv=none; d=google.com; s=arc-20160816; b=sX4Sqgz9HI8tTjww62f1JUEnuZ+gZkphZzLSE370aoIVX0RgWR8r3Ekll89hSa24pZ 4lNbFqAk1VSLvHElJDweRiMwgKbgrIG7Y2NmpVXz+rX9aT2oFJkE4LMzV0aADOmolEsg Dwzq1+waxQU52GZczAoENHHWfxE/6bCLWfsk7ihWUQnYPec3qJkZI5T/Oo1kHtamUm4o KFw5/bdWKQQVHccK0bC5rdAuG71AvOZelpsbNnZDQAOyQYIlZI68RNPqypMsIplUcFP+ ExiKMQHww3x3cypcU854xLInFVr7WOYCDop6Rt5JA/mvN1YzBcQnsjS2CoDA27vqfF1t 4K4w== 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=noovJtisV3i3/mJ6ypDDQD/CpIY5Kq1JwfcpAQCR0K0=; b=YdcFl+GbOV9SgP0rlximiCmrYOFkAjVqOVGq3LuAk/fO+8Z4sA/AnoNgihLkN1psKd Vk3SYFmHE5K/ixR2tPdgax1+Mkx7Rjnh8Izkzf72cSirwv7hgVAwEELpauaCgiAWxy38 +zJYhEUPT/Bxy6ak+26Klb91HbwBmVbA7Z9QMmolZeJwJyxotUimsRs72y7Ax5kQOxk9 o1fcaF6UORuH2jrTIjLd+J6UDHdovIevdwcAU7yQpXupq28fxBq6KlgbtS40hvqU5Fa7 6kf547OtkCg0djz5sjPGHZfhayHZ710SzFzEjuBFOqTGfS1K5dal9YvCQ8zCVEwABEoM 61oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="f24/9+EW"; 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 85-20020a630258000000b00528c16e9278si10379324pgc.93.2023.05.02.05.49.17; Tue, 02 May 2023 05:49:30 -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="f24/9+EW"; 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 S234224AbjEBMsd (ORCPT + 99 others); Tue, 2 May 2023 08:48:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233846AbjEBMsZ (ORCPT ); Tue, 2 May 2023 08:48:25 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EED4E52 for ; Tue, 2 May 2023 05:47:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683031648; 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=noovJtisV3i3/mJ6ypDDQD/CpIY5Kq1JwfcpAQCR0K0=; b=f24/9+EW8TfpivyXYHYw7+4FosRT3YVIdb1qL7PeBu9fvxfB/gvFsuMeb/Ppyd6SL6heGi nCIki0zH6IT9aVQmbPGuS3Awvnx3hF5dqXpl7EA+oX+EFJARK8YYSoIR9vzEAuY9Lb0cXG xyzEUGaPcdAvqNOtIQT4SC1Hi54QoRk= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-634-IN6_-ZmHNQKIDtmlQUqlpw-1; Tue, 02 May 2023 08:47:27 -0400 X-MC-Unique: IN6_-ZmHNQKIDtmlQUqlpw-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-3f348182ffcso3001915e9.3 for ; Tue, 02 May 2023 05:47:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683031646; x=1685623646; 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=noovJtisV3i3/mJ6ypDDQD/CpIY5Kq1JwfcpAQCR0K0=; b=LQzLmC7byMXtZ6XWR2TB5L7SqLR//FwBgM96Ci1xPxJxLXCAMzmfSkVxzTB2sgzq5g 2NuiC6cX1PTE2W7o3bQjUX23taOiCMGp8Vc350KTdn5T41Mzxag2tBclPnsCySjAsiPj cgWPhpaVyGoP9GUlSnFO7c9H0S9WrZtukeyhzXzhjIjELKRoHcyjTQMLpZkaM5poKzp0 WHBwncNNk8zfnYgg10LfCuufttO1pRTuiIpsIg6guyScdWxlzHuhH4Lz5EIMEck7ZNqn ICdwTM76/8B2mzPrl3QBRD5xYAjhnowE40JV9pLbpBQsTXmSdtNvYikypiZDHO1dI+1g SWiA== X-Gm-Message-State: AC+VfDynJ3TmPVnVOQaRByBZUg/kbpxzUXRIMBVrls/hXXUNsKTlvoxM 09/OHLXblFyNMLnLs+HgeS/NfXr/nRjz0rJAMZjzLKe6lIQG3Ax9BOGmRYakuzintsBEaNW6pAt /4dOsijG1ymmsVqtzyzLjG2hu X-Received: by 2002:a05:600c:2248:b0:3f1:6fb4:44cf with SMTP id a8-20020a05600c224800b003f16fb444cfmr12040746wmm.28.1683031645994; Tue, 02 May 2023 05:47:25 -0700 (PDT) X-Received: by 2002:a05:600c:2248:b0:3f1:6fb4:44cf with SMTP id a8-20020a05600c224800b003f16fb444cfmr12040725wmm.28.1683031645619; Tue, 02 May 2023 05:47:25 -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 e14-20020adfef0e000000b003063938bf7bsm1389765wro.86.2023.05.02.05.47.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 May 2023 05:47:25 -0700 (PDT) Message-ID: Date: Tue, 2 May 2023 14:47:22 +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: Peter Zijlstra , 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 , 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> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20230502124058.GB1597602@hirez.programming.kicks-ass.net> 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=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 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. @Lorenzo, you might also want to special-case hugetlb directly using folio_test_hugetlb(). -- Thanks, David / dhildenb