Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6926454rwr; Tue, 2 May 2023 07:20:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5hFLOciPYSpUWL8EjOUQS72+2F1SecoL3eYTVJzr1fBXJkOZeheOhlNJbuvzKgPjXTA3un X-Received: by 2002:a05:6a00:23d5:b0:63b:8963:d952 with SMTP id g21-20020a056a0023d500b0063b8963d952mr19792401pfc.17.1683037205683; Tue, 02 May 2023 07:20:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683037205; cv=none; d=google.com; s=arc-20160816; b=iVSgMkFkxxHBB3U5F5wvEGSiiEFX3+UFpYfPIAjWXCf0LNifDAWv12xEl2K35MV8pi T99uRYFROVagSnBMQYBYZViwSyctMNummZ16ixJjlRCk6Ql7XaDAhjwGWlObpZHeS+5G tUNsElRxrVcoV5z5CuYLVaocC31hCTeK2G/9nHUGQMiVVWTilXV0bvG0N+OLQi6dITk0 zYE9g/FjofoShkGaZlt8kFSiefoWiXMi318LF9FvLLk0CrUtCUuKU11NrfTLkXLoV8gW itmIT9Oi5zlk+L46YdveEzzpBMIoofnnYg6QZLW7bO73X/JRmkQWWB1FShaTD1kFJEFt n/Vg== 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=eO6gdENCN2fXl+gir0RoO36SF1UR1xjrvPR5SmtqcoE=; b=iGItsh7lH3+//w2UZ3YVPkZ0hmGxaISIe/sHEU9yERv5iaAWB5IQ0e+omZZqIa2wks NhAtY0r5BPU9ibGk8Qu5hv04J9n+88B6ZKKz2Am8YfcMEqPujs+fWCwhnh3ZDlCU9XfH Pml+0+UTJz9OB8wgxnIYXKh+/FkfA/1J0yLGjYbJGNz2fdEbMw0j4YhG7K6pT0+h27wc JEse3MwM7TADrguUb4i2mlFyOFE9vUtiMWwLx7Z8UwnnggbPCbS3avuU5qywEd7By5FT 9CUPxn+4Luj9JmyqEasnf1H/xIbLko3r+7yhhWDgYz7WguZ0Gsj/syuSJS+GhDJ8jAML Wy8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RXJ1vpOS; 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 w68-20020a626247000000b0063b87f60f7bsi30529578pfb.48.2023.05.02.07.19.32; Tue, 02 May 2023 07:20:05 -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=RXJ1vpOS; 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 S234456AbjEBOQl (ORCPT + 99 others); Tue, 2 May 2023 10:16:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233990AbjEBOQX (ORCPT ); Tue, 2 May 2023 10:16:23 -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 51143197 for ; Tue, 2 May 2023 07:15:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683036923; 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=RXJ1vpOS4c1XXSdMCrufXJhxuwu3slWJ6WA3xbT5NChxp0Oxylrlvz8QujWRDK73DvPnK8 sMi2ZL33FpGNPCdTWvW8dWuuOh4UORRjXLw/rBmNUZ80+0ZjgUajFQODgDpYtbafd3ul/8 3vCZHlFoiDh8j6imE3I44bi9Kp4nebE= 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-167-mPUka34AOPmdN-JYHRyaxg-1; Tue, 02 May 2023 10:15:20 -0400 X-MC-Unique: mPUka34AOPmdN-JYHRyaxg-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3f250e9e090so12136015e9.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=SVFP2iK4OtaoaOoE46pvlhWy/R0EaaVPpV0wfC4nYlsb+keGEY1yajb7joyidoo5Jx nHPxk/OXh5KmAWDTFb6C53ZgSEFZOSSA1HKwSYCVu5I45VSt1xDDllx+N5BBl2jzvc/R HO2ZmtgH8X0bnaKbSWGlG84yZl0yEDA57C+ieASm60YWie/29RrpxHBOIW83P8+KLeVQ AqCadv+P7e7ZKAUJ3vElMh8TfDd9xhBmOwwm/fRRypr7Ea41xrtJe2S6y2j+vOh24Xr2 qVnihwrYwlUIloQDZ9Bp+C7JCEq84ApGAUim30U6oXjTF9WRLvHnZkIyabIB0IFeUYmU tvVQ== X-Gm-Message-State: AC+VfDwVUkbMzVpew0zkhibAYpLRAP4B5Kl4oCqPT+/MNBY88totQbdS gZyHVjzyoxr5AQ7s7Zsdu7sfJ42zVgLqX/2x9+ME5eE0P+QWby0a4R1ts22wwZN9owIn7dJHr7u s4Ct+UqDB/XnqokreM6gbOJ2y X-Received: by 2002:a05:600c:2183:b0:3ed:ec34:f1 with SMTP id e3-20020a05600c218300b003edec3400f1mr12040793wme.35.1683036919244; Tue, 02 May 2023 07:15:19 -0700 (PDT) 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 Content-Language: en-US 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: 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 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