Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7112049rwr; Tue, 2 May 2023 09:36:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7HGUELJs4ipCSP2y5M/OtlVGxKvUMM1OSWuL23sNtG/xkqyFK/9ZYQrizqeWnX7pFuiko8 X-Received: by 2002:a17:90b:f89:b0:24e:2759:8dbe with SMTP id ft9-20020a17090b0f8900b0024e27598dbemr3507880pjb.7.1683045381269; Tue, 02 May 2023 09:36:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683045381; cv=none; d=google.com; s=arc-20160816; b=kCbOzz7dWC0SNOy6QyBiXcbBrCK8eXGroR714yAbZMCSw5dyDO4QyqEaCT0uN5eatZ ZV3Cs1YGdCGqhCtQ7eZl9XsBhRU/GwvZamapVMYaRTg2gw6Au8V3MdGVkb1Ms69zp35U GHi0QS/IBTWUejgyQk5g7WUxuOSplBRnVKxr15XgnU2SmANGc19u5xnIh4+NQ4L+ioPw E1/ZR+rx3Ie2ceFjI+1nMKRXt/BpNV/nC32XLJRWZWdubINYsF+0MRopQQAcRnWYHAdo o6ccduU7/7xMM7/2RdLJ2tfZgQVjTAPJeV+10c3y224B1DSMSHjz4429dd7RKr/5QWL+ wiMA== 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=9eeDMuJZPu6ODufcZPGNKxI5KHuttnVPRF879rkqTz8=; b=oOKoPqYVhuwf8559F95zbJauoGI32rphsss2dwMATX0y34euxbtQGE46JkGEIND+YP v3RFyfjXAQiQxNcOuPJEC6uyb+2/atrpFUeoX80I35Nwo+oE09GRhhUq2MxUJwtLiWs9 RuKh441o6P2ZFUpZkqS079Jh7lNPDBY0E9a/atwsFk2YbEZXDdoXgY3Xpz4mK0z4lpel XuwL9SRVH3iK3THh8TGRBzL82FUkeXUbG2rs0/KaHhYQ5qzdtWIeBPSlUpgkPDDp4mq/ s6/zip1Q7ygbBRjMyuEogwjhjMdHRe/K4l4ldeDGfM+zdSNRtfK0i4RxmCr1TVZXrhhE ts+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VhD6y6yI; 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 on5-20020a17090b1d0500b0024c045f6bf7si15630110pjb.84.2023.05.02.09.36.07; Tue, 02 May 2023 09:36:21 -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=VhD6y6yI; 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 S233705AbjEBQNg (ORCPT + 99 others); Tue, 2 May 2023 12:13:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233610AbjEBQNd (ORCPT ); Tue, 2 May 2023 12:13:33 -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 C0E812D79 for ; Tue, 2 May 2023 09:12:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683043967; 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=9eeDMuJZPu6ODufcZPGNKxI5KHuttnVPRF879rkqTz8=; b=VhD6y6yIwtFP8OZUTOCI/B43qyHuu9G6nF4AaW59BNEOr0BoANdmcAuSgnmflkbLeKazgy WONx8ezbXXU/l2ScMycBR/2I0TxlCSQAn4+P/uHL8yzo+D3PBNxxgs+zQGXcJZ91coIk70 7vwdBuTclD37+TQN4mrR3fB6wO0MaMs= 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-212-dbLBM22SPFagDYA4owN5vg-1; Tue, 02 May 2023 12:12:44 -0400 X-MC-Unique: dbLBM22SPFagDYA4owN5vg-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-3f3157128b4so109558175e9.0 for ; Tue, 02 May 2023 09:12:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683043963; x=1685635963; 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=9eeDMuJZPu6ODufcZPGNKxI5KHuttnVPRF879rkqTz8=; b=G03bxrcB5e1uZtgUiQ1hNnSlVugbwi4Ryp4vUw4ZBE7LCYidTlg7Vm9dELM0NyXcP7 cTQklSuLlgmmFrC1o+FugfIo/Ed3SJWjqSIgBa5QjjcS4rSn8FL1/BjEnuPWUp6vqcE5 EskE3CuQZa4YEEA4POt141UlVIsiq+NLEqOqO23d3Z1PdrHACgOFM3PFfuGXVEzIcC0q Xf8vZ+7GFx8jUs3SZAM9EBzHxQfhYWgsG4BS0C6ATVb+3iXP7LX9I+9aTRpHrAEDO7K6 BZ5nZ0RjgWqixiMQLZcSp/Fb4i99U2aJvURPI4I5lhpZXaRRUZjmp6XEKOgxW986CyDo Yl/g== X-Gm-Message-State: AC+VfDy3l4jm5FcKttvMGXl5YSKpIZn4hf0x/xV+G7COfiUeF3clWiFR 2GW2mwOtddz66nb7UFnE18/wzScGB0y43hPDSd/vnFWoVTO9ovmpYF5n6nl2/oAiCzat2WDArF5 6p2vSp3SP6XVqkqWqhBuY1ha+ X-Received: by 2002:adf:e911:0:b0:2f6:661:c03c with SMTP id f17-20020adfe911000000b002f60661c03cmr13759793wrm.28.1683043963191; Tue, 02 May 2023 09:12:43 -0700 (PDT) X-Received: by 2002:adf:e911:0:b0:2f6:661:c03c with SMTP id f17-20020adfe911000000b002f60661c03cmr13759744wrm.28.1683043962801; Tue, 02 May 2023 09:12:42 -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 v3-20020adfedc3000000b003062c0ef959sm6522031wro.69.2023.05.02.09.12.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 May 2023 09:12:42 -0700 (PDT) Message-ID: <1f29fe90-1482-7435-96bd-687e991a4e5b@redhat.com> Date: Tue, 2 May 2023 18:12:39 +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: Jason Gunthorpe Cc: Peter Xu , Matthew Rosato , Christian Borntraeger , Lorenzo Stoakes , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Jens Axboe , Matthew Wilcox , Dennis Dalessandro , Leon Romanovsky , Christian Benvenuti , Nelson Escobar , Bernard Metzler , Peter Zijlstra , 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 , John Hubbard , Jan Kara , "Kirill A . Shutemov" , Pavel Begunkov , Mika Penttila , Dave Chinner , Theodore Ts'o References: <1ffbbfb7-6bca-0ab0-1a96-9ca81d5fa373@redhat.com> <3c17e07a-a7f9-18fc-fa99-fa55a5920803@linux.ibm.com> <4fd5f74f-3739-f469-fd8a-ad0ea22ec966@redhat.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: 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 18:06, Jason Gunthorpe wrote: > On Tue, May 02, 2023 at 05:45:40PM +0200, David Hildenbrand wrote: >> On 02.05.23 17:36, Jason Gunthorpe wrote: >>> On Tue, May 02, 2023 at 11:32:57AM -0400, Peter Xu wrote: >>>>> How does s390 avoid mmu notifiers without having lots of problems?? It >>>>> is not really optional to hook the invalidations if you need to build >>>>> a shadow page table.. >>>> >>>> Totally no idea on s390 details, but.. per my read above, if the firmware >>>> needs to make sure the page is always available (so no way to fault it in >>>> on demand), which means a longterm pinning seems appropriate here. >>>> >>>> Then if pinned a must, there's no need for mmu notifiers (as the page will >>>> simply not be invalidated anyway)? >>> >>> And what if someone deliberately changes the mapping? memory hotplug >>> in the VM, or whatever? >> >> Besides s390 not supporting memory hotplug in VMs (yet): if the guest wants >> a different guest physical address, I guess that's the problem of the guest, >> and it can update it: >> >> KVM_S390_ZPCIOP_REG_AEN is triggered from QEMU via >> s390_pci_kvm_aif_enable(), triggered by the guest via a special instruction. >> >> If the hypervisor changes the mapping, it's just the same thing as mixing >> e.g. MADV_DONTNEED with longterm pinning in vfio: don't do it. And if you do >> it, you get to keep the mess you created for your VM. >> >> Linux will make sure to not change the mapping: for example, page migration >> of a pinned page will fail. >> >> But maybe I am missing something important here. > > It missses the general architectural point why we have all these > shootdown mechanims in other places - plares are not supposed to make > these kinds of assumptions. When the userspace unplugs the memory from > KVM or unmaps it from VFIO it is not still being accessed by the > kernel. Yes. Like having memory in a vfio iommu v1 and doing the same (mremap, munmap, MADV_DONTNEED, ...). Which is why we disable MADV_DONTNEED (e.g., virtio-balloon) in QEMU with vfio. > > Functional bug or not, it is inconsistent with how this is designed to > work. Sorry to say, I *really* don't see how that is supposed to work with a page that *cannot* be faulted back in on demand. -- Thanks, David / dhildenb