Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7282295rwr; Tue, 2 May 2023 12:09:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4xX4UTb6RnZc1LuXtAmo9ZYVZIGOlmUKVJZrpnWGcAWyvqHr/nlqIBeATmNMsPkGzDgjnR X-Received: by 2002:a05:6a00:124f:b0:63b:7954:9881 with SMTP id u15-20020a056a00124f00b0063b79549881mr25654758pfi.28.1683054592948; Tue, 02 May 2023 12:09:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683054592; cv=none; d=google.com; s=arc-20160816; b=z47xNkM9PfhY4J1LUas/Z6b0X5HQ87ptBtnW0h7pNeBvdQv4evdqLeIH/7cWa4MbyX Sz9iwmqTRk3lGkpUGfEPrc+2Kp33PSnFstxsP3eWxNaceAcdV+EVQMWQhItoLaKEKUE7 NbcQJcv7E58IdcoxMNBCurmUkbV50IdzF58WC6x28YENUHuAcyoKsN1PUqKokcauAFhE OwohBWXLzE/FJPWjPNwnAC9XpIVA9ir1zTYjvVpgUuMuFH2gn/JRGvBqHW5eoZA4MlJc ULKRxyXg9sTquga58Lb2ksEtjlI+e1HPA9yD2usBr8mTArJR/ssWOzLxsJSYaUV6sBjX IX3g== 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=0S2yc+ZTNRgoAH3fjxIMA+gbVtscqyIDdigzY2/OjVg=; b=Vwf9s1X0ZChz0fwixn70rGeYaYhN+G5RWREkfE2K9jIl99Hm6MQDmxHbxH1SiwxziU Pk0YgT/4NUPsW8BotGc5wueJ30uuulwz3V7xoCJikBChpH7hVdNnsmhuyo2zBJ3NRU95 o0e8n1uANV8R2uKZOEnzn7XwqQxS7OlIVwF9idtbXIi5djcunD7Lgf5zsj8xPbjWe3LO CGtF0Wq0SigKOQRKtH8LtOkxJyBY8WYbBT78SBuIj2J0oJN4ehk/k3gapz7CkHxG9XYX VEujIdd4qnjD2yRS2IDktAxMQjccR0KAwZU5mZtC0f5nHZ0Fy+pKWLliJMBVo9eDN6g/ CVxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BQtucOow; 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 f12-20020aa79d8c000000b0063b5f25dd95si25290822pfq.391.2023.05.02.12.09.40; Tue, 02 May 2023 12:09:52 -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=BQtucOow; 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 S229569AbjEBTG1 (ORCPT + 99 others); Tue, 2 May 2023 15:06:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229564AbjEBTG0 (ORCPT ); Tue, 2 May 2023 15:06:26 -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 43C581BFA for ; Tue, 2 May 2023 12:05:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683054339; 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=0S2yc+ZTNRgoAH3fjxIMA+gbVtscqyIDdigzY2/OjVg=; b=BQtucOow/NB6b+E1AFZQh+3bsrk7sJhsl6zms7CS9TNTkqXMibkOifWskjDlVcSUTr6fzt n2OHNby94I5WJFCiKoM22duZYCzOwexSssWdxU+TxVcY8XqdE46bO29ed+vf+XssiRhpnU xsAIC5lXI/7Pe6CFDf5t6ha861n7C0o= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-628-b7BEwRygO-KqWj4H5zgscA-1; Tue, 02 May 2023 15:05:30 -0400 X-MC-Unique: b7BEwRygO-KqWj4H5zgscA-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3f1793d6363so12863345e9.1 for ; Tue, 02 May 2023 12:05:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683054328; x=1685646328; 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=0S2yc+ZTNRgoAH3fjxIMA+gbVtscqyIDdigzY2/OjVg=; b=U83ec7QdlrgdXyynSYXsS+hZmznsLgsON5o2k7n7fNScUq2b0t4HcTahWbi9OXza38 GnSMhQbBdmsHvk0ttiAMTjobSnEw/QnQMnyuYQhV1kMAOuOmFLDW6mmAe/QagfW5wFc5 XhKAAjqIjRrlYU8FCe0J5dUMVLGEWcO5XyUYOozWGyN16hAWgKh8so8/jgsfjWns92iB QgzX4MIgLP7SHaoK+nNo7K3I/znHNfndGtzjAb20GbS3MHNhoCb4xg5atzzUZBfcM0t1 0+Eaetr5PoWf8iQIVGVlBle8HHDpf51UDrRSXc+nS90o8lVv8P9voVVyPm5SM1wUdS7Z W/wg== X-Gm-Message-State: AC+VfDy2SKtSy32hMveqxjxoj6wIvhiE7R7zHp1mE17XQvXh6KokMBeI 6+/ZleOsZ02lYx1zjaazM1dtYP3WAJHMWJB0Ub+RfoDSQMpYB7hbs4r1bZsEPUTSvj2lD5RUEnh fCnY+djyLMFgGRWC1lZqFukYM X-Received: by 2002:a7b:c015:0:b0:3f1:662a:93d0 with SMTP id c21-20020a7bc015000000b003f1662a93d0mr13370017wmb.15.1683054328798; Tue, 02 May 2023 12:05:28 -0700 (PDT) X-Received: by 2002:a7b:c015:0:b0:3f1:662a:93d0 with SMTP id c21-20020a7bc015000000b003f1662a93d0mr13369974wmb.15.1683054328421; Tue, 02 May 2023 12:05:28 -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 m9-20020a7bce09000000b003f049a42689sm36193382wmc.25.2023.05.02.12.05.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 May 2023 12:05:27 -0700 (PDT) Message-ID: <82368bae-b2cc-5d55-6de6-e3283cef063b@redhat.com> Date: Tue, 2 May 2023 21:05:25 +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 v7 3/3] mm/gup: disallow FOLL_LONGTERM GUP-fast writing to file-backed mappings Content-Language: en-US To: Peter Zijlstra Cc: Lorenzo Stoakes , 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 , Matthew Rosato , "Paul E . McKenney" , Christian Borntraeger , Mike Rapoport References: <1691115d-dba4-636b-d736-6a20359a67c3@redhat.com> <20230502172231.GH1597538@hirez.programming.kicks-ass.net> <406fd43a-a051-5fbe-6f66-a43f5e7e7573@redhat.com> <20230502185926.GE4253@hirez.programming.kicks-ass.net> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20230502185926.GE4253@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=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 20:59, Peter Zijlstra wrote: > On Tue, May 02, 2023 at 07:34:06PM +0200, David Hildenbrand wrote: >> Now, if we read folio->mapping after checking if the page we pinned is still >> mapped (PTE unchanged), at least the page we pinned cannot be reused in the >> meantime. I suspect that we can still read "NULL" on the second read. But >> whatever we dereference from the first read should still be valid, even if >> the second read would have returned NULL ("rcu freeing"). > > Right, but given it's the compiler adding loads we're not sure what if > anything it uses and it gets very hard to reason about the code. > > This is where READ_ONCE() helps, we instruct the compiler to only do a > single load and we can still reason about the code. I completely agree, and I think we should fix that in page_is_secretmem() as well. -- Thanks, David / dhildenb