From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91C83C77B7E for ; Tue, 2 May 2023 15:28:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2969F6B009B; Tue, 2 May 2023 11:28:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2470A6B009C; Tue, 2 May 2023 11:28:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 10F87900002; Tue, 2 May 2023 11:28:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by kanga.kvack.org (Postfix) with ESMTP id EC7956B009B for ; Tue, 2 May 2023 11:28:27 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683041307; 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=eO6gdENCN2fXl+gir0RoO36SF1UR1xjrvPR5SmtqcoE=; b=WSpmOPHlVLV8Qjg47gRcqROx0AAF9sqNXwP/CLl0p2FFVSQWkrOzyg6EY2RNQHmNS/LJPa fPQFYtl+Zr7Ei/m20nVM0/ihUpJCobl1oZJXBUiIlZcYtKyONuM3I5xQDK8peTQ9rk4jri ALUZqyIrVXyMiddiqGvdeEhmyDp5cBE= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-214-TMzbmMH_NheMkhXAlP0g3g-1; Tue, 02 May 2023 10:15:20 -0400 X-MC-Unique: TMzbmMH_NheMkhXAlP0g3g-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3f250e9e090so12135995e9.0 for ; Tue, 02 May 2023 07:15:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683036919; x=1685628919; 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=eO6gdENCN2fXl+gir0RoO36SF1UR1xjrvPR5SmtqcoE=; b=geFUfTCPg3dlRgyhT/3geHlVBKJtVcXMOyIpsYHjqLyVDNSbJDaCNAbxtzZKGODUul PQqAZMn1/IfieN45S8ZLf4kHeQeF0Dz+MJLJsU8hgpmOqDwmcfIg0ZNgInKXmARjRiHV SKNo1P2hT9S4xdF3hCq7JXwgsCd9dACdNTbl1d0wlxsGEnhdcuXQ5+2dEqOFCKhNyJTS hcaG5yhJ9v3LPlPVFFAaBGuJR5A5WZT2Yf49u8oQVE52zNSW0RP6RmdWjW5LYellFWqf EC+3NAl2IUM3xzFvcJrl67c6pjxe7+S7KnT2I4GerJ1+6LqeT+oIoSZNchUlVMjG/hdm p/Sg== X-Gm-Message-State: AC+VfDzoL4yXMtLDHY0KcXtAIjB1KShfKGLTKIvb4Oq8qTNoWRBfNOuy NXu6NWw46y/iQHYL2CIBPx7Bzs3ZjEPRrnH73p0uUvAoOI3t1hFuASSTb/Zk3IkHMEOAP7WdCyv fi0R+0RCXtrs= X-Received: by 2002:a05:600c:2183:b0:3ed:ec34:f1 with SMTP id e3-20020a05600c218300b003edec3400f1mr12040808wme.35.1683036919246; Tue, 02 May 2023 07:15:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7b/XcsbsQnzRZmP99SuxpW9CijxoRkII9q7oYHBTDMbDugyRQH6OJnCz/4C+NcU01RLhcYbw== X-Received: by 2002:a05:600c:2183:b0:3ed:ec34:f1 with SMTP id e3-20020a05600c218300b003edec3400f1mr12040766wme.35.1683036918841; Tue, 02 May 2023 07:15:18 -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 v11-20020a1cf70b000000b003f25b40fc24sm21090046wmh.6.2023.05.02.07.15.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 May 2023 07:15:17 -0700 (PDT) Message-ID: Date: Tue, 2 May 2023 16:15:15 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 To: Jason Gunthorpe Cc: 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 , Peter Xu References: <7d56b424-ba79-4b21-b02c-c89705533852@lucifer.local> <1ffbbfb7-6bca-0ab0-1a96-9ca81d5fa373@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: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 02.05.23 16:04, Jason Gunthorpe wrote: > On Tue, May 02, 2023 at 03:57:30PM +0200, David Hildenbrand wrote: >> On 02.05.23 15:50, Jason Gunthorpe wrote: >>> On Tue, May 02, 2023 at 03:47:43PM +0200, David Hildenbrand wrote: >>>>> Eventually we want to implement a mechanism where we can dynamically pin in response to RPCIT. >>>> >>>> Okay, so IIRC we'll fail starting the domain early, that's good. And if we >>>> pin all guest memory (instead of small pieces dynamically), there is little >>>> existing use for file-backed RAM in such zPCI configurations (because memory >>>> cannot be reclaimed either way if it's all pinned), so likely there are no >>>> real existing users. >>> >>> Right, this is VFIO, the physical HW can't tolerate not having pinned >>> memory, so something somewhere is always pinning it. >>> >>> Which, again, makes it weird/wrong that this KVM code is pinning it >>> again :\ >> >> IIUC, that pinning is not for ordinary IOMMU / KVM memory access. It's for >> passthrough of (adapter) interrupts. >> >> I have to speculate, but I guess for hardware to forward interrupts to the >> VM, it has to pin the special guest memory page that will receive the >> indications, to then configure (interrupt) hardware to target the interrupt >> indications to that special guest page (using a host physical address). > > Either the emulated access is "CPU" based happening through the KVM > page table so it should use mmu_notifier locking. > > Or it is "DMA" and should go through an IOVA through iommufd pinning > and locking. > > There is no other ground, nothing in KVM should be inventing its own > access methodology. I might be wrong, but this seems to be a bit different. It cannot tolerate page faults (needs a host physical address), so memory notifiers don't really apply. (as a side note, KVM on s390x does not use mmu notifiers as we know them) It's kind-of like DMA, but it's not really DMA. It's the CPU delivering interrupts for a specific device. So we're configuring the interrupt controller I guess to target a guest memory page. But I have way too little knowledge about zPCI and the code in question here. And if it could be converted to iommufd (and if that's really the right mechanism to use here). Hopefully Matthew knows the details and if this really needs to be special :) -- Thanks, David / dhildenb