From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C995392C21 for ; Thu, 27 Aug 2026 20:54:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787864046; cv=none; b=omM30cwfKZtG77BtJEVpRYVHlfALrhotG9uzaYkaRDP6v2JHa/3R70a5ft02LAH9b3RCzbo9df9NhM7ozJsEu4ctqEtciTF/dQZuQdhGwcfPfxXhuvmamQBFRoWrsCVbe2HkvTEAFMYVZ4174n3wxa3MicniLOaRoMFFhfRkfeE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787864046; c=relaxed/simple; bh=584T2Fi+jYdHnPMPryAzdeyBmBsauq81+2zQRXO51LQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=cm1SxGAzJwq5P8A0M04VU5He8MsZpXIISY3QEAYhbJU+Qk2CQgF8KhBvLSAerBj33uGUg6Ho8Cxpdu3cFYPtLe0zmLercKRxIN41UGkfmh3WabsUtxGMdiTcy1CwyNZxDsoG5ZUGkYY4L3TKNNqHPE+eZ7MssLpiFNkaNZQ0xic= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=XbrP1xh0; arc=none smtp.client-ip=209.85.210.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="XbrP1xh0" Received: by mail-pf1-f199.google.com with SMTP id d2e1a72fcca58-84e024d2129so571664b3a.2 for ; Thu, 27 Aug 2026 13:54:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1787864044; x=1788468844; darn=lists.linux.dev; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ZEfQxTOKQyDG0uZqNyCVnRw0wmiuuoqTc9XyRDn+pn0=; b=XbrP1xh0gOc6HrfUf8frLpGd9I+xzAcnYcZMn34NWAHCfASaIKqQiA5eqfI1D2iTgr Tjtm6AZed9fL+4hagekAeozT4+pwJEU1emyXIO3L9S9eusvpgiQE1B7qoIP8YsPf2R46 /04x4ZZ8d6hq034bOM1rV0CPZ5tgC+p6XSVqsRwXz8IpUqa/SPXxQ5hxLEFLMwaS7oI2 d3vODZTQrwTKtO62E7PWg1OglJZHO0MTDInM3Pkx3GXtIc7s4yP2ZnkrbJD3FBufwyda pM8Ajwy3yRsGvFN7g+F+ECSUiii8ruVMVIUYKSY4zCSeGmV2YoWEf9mLANDXl/1pRBPr 5sRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787864044; x=1788468844; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ZEfQxTOKQyDG0uZqNyCVnRw0wmiuuoqTc9XyRDn+pn0=; b=gYxcGJcosVXYDP7zfavUvBuiaT7CChVEYWWZoq5b8KY1oC0SPe/jub24b6ihoCpIBj /UIGJk6uf8HaBztrlhtXteTHRHytZPfPTGaSnb5jL+PUv0lxJu28JkqCkvV5PALjg9Og 6fIRTsndmdvXLFZVZXd4+0+28B4f412CGAqs1+Q0u8v07ik78n+EdbkExFtNkR4AJIff HlfDpcSuG9GZvv5uGFTK0tWwR7UOHIeIbOuzXObDULlktg1b2JabTLZgdydr8H1vAmw+ 5ZmOWO6gr03Sq5cprKehz6plz+edoxRJ5JziVmJwr9ktweCJtnmgjIrgvxPCQIwAJA8E WlAQ== X-Forwarded-Encrypted: i=1; AHgh+Rq4bT8r73q62KzKC/d7Xa75ayQeRp0cJ7ddME6eGVKxb4wZqO54CMt2Po6cqOLxrCTQXsPrPv1j8Ipz@lists.linux.dev X-Gm-Message-State: AFuF++kx53UbdD39bP5baraPDY/shUXM3HbRg208zPotUHVDnTisf/lr IdzTJtcnCJt0CGkP/L+hqx5MARbuIlei2AgyBye5FG/N2bxomyTb7Zbn94RPCKgJjNLHvdEU9sw 7thPOwA== X-Received: from pfbkr16.prod.google.com ([2002:a05:6a00:4b50:b0:848:5480:9ac7]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:e09:b0:851:fb36:a702 with SMTP id d2e1a72fcca58-85629f09cc5mr4062708b3a.9.1787864043380; Thu, 27 Aug 2026 13:54:03 -0700 (PDT) Date: Thu, 27 Aug 2026 13:54:02 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260826-gmem-inplace-conversion-v11-0-0a15d8a799aa@google.com> <20260826-gmem-inplace-conversion-v11-15-0a15d8a799aa@google.com> Message-ID: Subject: Re: [PATCH v11 15/46] KVM: guest_memfd: Call arch make_shared callback for to-shared conversion From: Sean Christopherson To: Michael Roth Cc: Ackerley Tng , aik@amd.com, andrew.jones@linux.dev, binbin.wu@linux.intel.com, brauner@kernel.org, chao.p.peng@linux.intel.com, david@kernel.org, jmattson@google.com, jthoughton@google.com, oupton@kernel.org, pankaj.gupta@amd.com, qperret@google.com, rick.p.edgecombe@intel.com, rientjes@google.com, shivankg@amd.com, steven.price@arm.com, willy@infradead.org, wyihan@google.com, yan.y.zhao@intel.com, forkloop@google.com, pratyush@kernel.org, suzuki.poulose@arm.com, aneesh.kumar@kernel.org, liam@infradead.org, Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet , Shuah Khan , Shuah Khan , Vishal Annapurve , Andrew Morton , Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Youngjun Park , Qi Zheng , Shakeel Butt , Kiryl Shutsemau , Baoquan He , Jason Gunthorpe , John Hubbard , Peter Xu , tarunsahu@google.com, Fuad Tabba , Vlastimil Babka , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev Content-Type: text/plain; charset="us-ascii" On Wed, Aug 26, 2026, Michael Roth wrote: > On Wed, Aug 26, 2026 at 03:33:43PM -0700, Sean Christopherson wrote: > > > So there's real performance differences here but it's sort of been > > > addressed through a solution that offers additional performance > > > benefits on top so there's no longer as much to be gained here I think. > > > > Or another way to look at it, eager conversion would allow QEMU to drop its > > workaround. > > True, for SNP at least, but pre-map is nice too, and not really gmem's > place, so most likely KVM_PRE_FAULT_MEMORY would remain regardless. Hmm, good point. And as below, we can't sanely avoid the check in kvm_gmem_get_pfn() without reintroducing the preparation tracking, so the lazy approach is probably the best option at this point. > > To be clear, I'm a-ok with the code as-is, I just want to make sure we document > > exactly why we're choosing this implementation. > > Agreed. My understanding of the current design choice is basically that > it doesn't *need* to happen here, since kvm_gmem_get_pfn() will already > trigger it on-demand when it is actually needed (or not), and that tends > to happen at fault time when other platforms like TDX handle it. Oh, this jogged my memory. For out-of-place conversion, waiting until kvm_gmem_get_pfn() to update the RMP makes sense because KVM doesn't know whether or not the SHARED backing as been allocated, and can't easily get at it in the first place. > To handle it differently would be to go out of our way to make SNP special in > this flow in exchange for performance, Not really? We'd still need kvm_gmem_get_pfn() to update the RMP to handle PFNs that were never explicitly converted. Either that or KVM would have to preallocate everything (ewww).