Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7115956rwr; Tue, 2 May 2023 09:39:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5YaZAqUKclohYYiy8sdW+7Jzbq1hxcXshqST9kzx3XO1Zb/PDP8hGUbJV1/9zSgarPM58r X-Received: by 2002:a17:90a:fa01:b0:24e:32db:9862 with SMTP id cm1-20020a17090afa0100b0024e32db9862mr1789052pjb.0.1683045580894; Tue, 02 May 2023 09:39:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683045580; cv=none; d=google.com; s=arc-20160816; b=VFeVmmqqWPzkuR6Zug99lWt8lsM5yPDnpkIp3PSax1jPj+Ff1ut+iFFhHDT25JY698 kYZENB5dpjK+x/+TqOVw8Jsd/l/0l3bTX6PP9yYbJCJlAUKxxL2QjTKdhgB3Wqw9AXer jR6T6OCQ2T+X6Jtr2hn5gkLpI80L7wXM64DDV9tYLFLAYvrbP5YpIPAAXWiNLgfHGrrQ j2/C0g+stJzG8HT2m4qSDIo8QzC44xogEcKNMfqPqXVEg6o8IBjZFrhY2B313jRwbM2m 6wJQeaTUy3vuJ5TGTR6gb3SCfv1eXVvsF2Dau3nldUiF/TcOT4jCw57WxBXrolNwnfbw FWDA== 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:subject :organization:from:references:cc:to:content-language:user-agent :mime-version:date:message-id:dkim-signature; bh=r1Y9ZHlSDmHQJFAVnELAl0311AMMIMNb4a19zH7pdjw=; b=jJPk3IW4cpXDtcgKv4GxhqDkV4EykOv02nU8dhWYMDR7NHaMFBcnSwXzJ4g8sV3+F2 Zu6p6mVfzRyd2d3PaYt+0teCD2Zi4okCfTVndSB89VbnWqUH22XU//53bIDnZ6QvLT01 yAIYTf+JWMpRXBoSTYrrw2LF8Fa/wZRIhQ91Mh4bAQwi0CwlAsSB3EWvVPC5M9TJbrMw w4VeGbIBZ8Kl4yFtI+PWCexNZu8K0551EEHbsMQ8Wt2Y27xuMP2IY2BhA8FPzNKEYIxN xCUU1q/lJjAcTCLkFp73kLeYv3HXp5wDkmP1Icnj6EotHhpHbj1PCARRXNbINfEie//T IeUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dDham+9X; 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 mi2-20020a17090b4b4200b002469436d3a8si12642866pjb.6.2023.05.02.09.39.27; Tue, 02 May 2023 09:39:40 -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=dDham+9X; 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 S233743AbjEBQdS (ORCPT + 99 others); Tue, 2 May 2023 12:33:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234042AbjEBQdQ (ORCPT ); Tue, 2 May 2023 12:33:16 -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 046AC1BD6 for ; Tue, 2 May 2023 09:32:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683045149; 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=r1Y9ZHlSDmHQJFAVnELAl0311AMMIMNb4a19zH7pdjw=; b=dDham+9XI17xYA3sgv7XlxWUWmE8eqTWi2COMao/YJuCKF949TSXAcIqRfoTEm+5Sz94eZ uVOVKSY5tkWKIL+tnVYMzxyGso7tQpZ4AZhabmaAiPo8MYhXjid9MUWB87DHvM9/olFbs3 nfor2wJuAPPWfszY2ZpA5rppAS1q1mw= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-19-aBHCMtVJPlSQcpx7m99qag-1; Tue, 02 May 2023 12:32:27 -0400 X-MC-Unique: aBHCMtVJPlSQcpx7m99qag-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3f1745d08b5so14434945e9.1 for ; Tue, 02 May 2023 09:32:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683045146; x=1685637146; h=content-transfer-encoding:in-reply-to:subject:organization:from :references:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=r1Y9ZHlSDmHQJFAVnELAl0311AMMIMNb4a19zH7pdjw=; b=aE1XHOVeBRCcchTmo7ieEZcVy3WwdOLhiRilMonOWVBTRy4lLBrZbHx2ka8Zu8MY2S yx1gSWS+WtT3lehjgIsyHCRqwoOW4eYvfWQvzeqzyUy4gqzZvAeZPkL2YBmfqWTPDaCp YSQIl0Wi+3i4TBBj+FD9hVR9iKDAyxq18WKPZUcD9azuqeEhItJNXsxmNgpvGpFTnx+n XLDTmgjFJqiH2eihwB6bXB2Zj4dq0dQGKMuLxORn6j3kPm4rXGYc2dw8b6f/iEZCwoOl 9hPD36osdos3NGiUktkS1ONtn5H8C6lJP9FqL12Pqle3/3IcEvk6VE+HmCiROp+sJX4G g3Aw== X-Gm-Message-State: AC+VfDwAFKxaAKW1omBfcvGzOlh6S0m4mqPh8s9/D3iGllSa6MHMroUv M/2Ymh7KvPoiqq9C9d0R+PNqKdtgmYfuy+L5BTX26Mw0hZUR8LCjBP1ZCldsvts2n2DDrBIUhvD KrlYWcPfO8a9Bbv0ZxVl0e1FS X-Received: by 2002:a1c:ed13:0:b0:3f1:70a2:ceb5 with SMTP id l19-20020a1ced13000000b003f170a2ceb5mr12419700wmh.13.1683045146468; Tue, 02 May 2023 09:32:26 -0700 (PDT) X-Received: by 2002:a1c:ed13:0:b0:3f1:70a2:ceb5 with SMTP id l19-20020a1ced13000000b003f170a2ceb5mr12419652wmh.13.1683045146112; Tue, 02 May 2023 09:32:26 -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 m36-20020a05600c3b2400b003edc4788fa0sm40176251wms.2.2023.05.02.09.32.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 May 2023 09:32:25 -0700 (PDT) Message-ID: <6681789f-f70e-820d-a185-a17e638dfa53@redhat.com> Date: Tue, 2 May 2023 18:32:23 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 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> <1f29fe90-1482-7435-96bd-687e991a4e5b@redhat.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v6 3/3] mm/gup: disallow FOLL_LONGTERM GUP-fast writing to file-backed mappings 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:19, Jason Gunthorpe wrote: > On Tue, May 02, 2023 at 06:12:39PM +0200, David Hildenbrand wrote: > >>> 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. > > That is different, VFIO has it's own contract how it consumes the > memory from the MM and VFIO breaks all this stuff. > > But when you tell VFIO to unmap the memory it doesn't keep accessing > it in the background like this does. To me, this is similar to when QEMU (user space) triggers KVM_S390_ZPCIOP_DEREG_AEN, to tell KVM to disable AIF and stop using the page (1) When triggered by the guest explicitly (2) when resetting the VM (3) when resetting the virtual PCI device / configuration. Interrupt gets unregistered from HW (which stops using the page), the pages get unpinned. Pages get no longer used. I guess I am still missing (a) how this is fundamentally different (b) how it could be done differently. I'd really be happy to learn how a better approach would look like that does not use longterm pinnings. I don't see an easy way to not use longterm pinnings. When using mmu notifiers and getting notified about unmapping of a page (for whatever reason ... migration, swapout, unmap), you'd have to disable aif. But when to reenable it (maybe there would be a way)? Also, I'm not sure if this could even be visible by the guest, if it's suddenly no longer enabled. Something for the s390x people to explore ... if HW would be providing a way to deal with that somehow. -- Thanks, David / dhildenb