From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) (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 64BA9370AE0 for ; Thu, 27 Aug 2026 20:54:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.200 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787864045; cv=none; b=ZHRz22PJKh+CJNXPknZQJV2ILCHX04km0MGqynndT7Tqf1vj1UvtBNELVKcRfBqsm/IPt+Oo1uwUeJ+irbZt+pcleRokpFp2OQ+9LWBvRQdBoFZXwCH9sLmpzbRPG2c9hl48xgYGS/ZnVJ5u8pitfPMQB+GUdqN6RNymppPBQTU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787864045; c=relaxed/simple; bh=584T2Fi+jYdHnPMPryAzdeyBmBsauq81+2zQRXO51LQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ufhrbj9vvAITT7fv/zPQRn82RE4PVOCNZMgbVyxjpUCfd5WRCDCrQ4LnfkYCCD+y+Z/Sd2A3g/y4oq2EVsnPQlVfNAkzyHWskzZGIUw9C4iuhIJwDdZx2YBJNT9buBrNHzHjZbFnZGCOGHJD+QuPDahGEwEyu/oZqKDhvE1doWE= 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=NDhHjzQU; arc=none smtp.client-ip=209.85.210.200 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="NDhHjzQU" Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-85602449126so742424b3a.0 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=vger.kernel.org; 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=NDhHjzQUvh3ExnAjwNkVIJFwsPZcmuA2IniGkFO/nza1s9PQ7UM+5SBSybByx8jfzC 9H76VzzIzoNit3xu/+s7pMEmDNzD/0TaoOmS3lzHmaCl3jnT0cx350Cy2zY2AKZARIdx UuaaQUkt10uQ2St3MJ7eZcVmDbXDw+4NTJFh8pjHVBgXnTfepFdpYbWWoX0PWX9/asJN Fq+Bvtpe7qZpck9RIc+q76+2w3yqqe5rKZsboxBBolUEN2/nSmQjxLRV6Iv0be9wYMUH FAx9lcKQxR5EtlqPw+mnJ4X/uuVyLHwt7LvL7KWV7uzVe5Cu4MOsoGK6wumcbonDoEFQ Sq8Q== 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=MaIXWD9PkD8EJz7UUmnBC20yoL9VHPj9Y5Z98p9qbInYyZjj25tWLxQzK3aOF7I5Uj 0U0jbPTy45zWOe/L/crmiq4olXckBzM0+WGaDsg5vW3Hr1IbJgysTSk4rT4RsWnlByr9 3T+prG9IEZMiGRSisedS6f6m47CD9YxRGnnbTgf36K6YeuVhUtkkROP5USNzmMBzVLgg IcdOa6RHLg+gDolFVRQ9wCAZP/61gcK3WB35bpTRFxz9TleHUKucMp2qQS9ac7swvBJg 8SLuI4DGldzqgWgq35C0qvh6dH65DwdCHKyffrsZHkiCZnHiHtJAqGd7rIEp93iLAMQw kiug== X-Forwarded-Encrypted: i=1; AHgh+Ro7M741heUQGYXCCkkx4WMYB9xpaVT1nEBJ2RZyhP8HQXaU1k0JU2nsfyvIvFZrAE87khpiHkjVUryPLYA=@vger.kernel.org X-Gm-Message-State: AFuF++mtmB8rZMe3/H10EHqt5z8fJt8+7KJATnttxz2xXP5ZycC08Kh0 09ukf1xvHFDihUgRzzbETQqlvowXdXJWvxF4aYqeInu7X33UOz9sGfWO7JuyJ2XsUC4Um5aAvpi BU6uyhw== 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-kernel@vger.kernel.org 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).