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 C848BC2D0CD for ; Fri, 16 May 2025 00:58:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8EC0C6B009A; Thu, 15 May 2025 20:58:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 89A486B009C; Thu, 15 May 2025 20:58:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 73AFE6B009D; Thu, 15 May 2025 20:58:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 5384B6B009A for ; Thu, 15 May 2025 20:58:02 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4D5E11409FB for ; Fri, 16 May 2025 00:58:02 +0000 (UTC) X-FDA: 83446959204.29.B3076CD Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) by imf27.hostedemail.com (Postfix) with ESMTP id 7595F40002 for ; Fri, 16 May 2025 00:58:00 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=Uq4PjZfU; spf=pass (imf27.hostedemail.com: domain of 3lo0maAYKCJMF1xA6z3BB381.zB985AHK-997Ixz7.BE3@flex--seanjc.bounces.google.com designates 209.85.216.74 as permitted sender) smtp.mailfrom=3lo0maAYKCJMF1xA6z3BB381.zB985AHK-997Ixz7.BE3@flex--seanjc.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1747357080; h=from:from:sender: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:dkim-signature; bh=T8/qY0LTEjs6FgRExW+zZPRu+s+HGdicfzCVV2cwKQ8=; b=UtUHT6LLgrWXDfITl4YgYYswhkNWBxi6itDMPe/kTBzbwZsOSkbmeDIZhGEikfNBndetcu GaCBsymFLAsoP2RdOFSeHv0If+r0THuriEbEIKblvf1vPp0WpmPAaVbU8G4r1EBzasWtp+ 05Qn1rRVK5FzrjrdrlGWYRrjiq2N7xs= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=Uq4PjZfU; spf=pass (imf27.hostedemail.com: domain of 3lo0maAYKCJMF1xA6z3BB381.zB985AHK-997Ixz7.BE3@flex--seanjc.bounces.google.com designates 209.85.216.74 as permitted sender) smtp.mailfrom=3lo0maAYKCJMF1xA6z3BB381.zB985AHK-997Ixz7.BE3@flex--seanjc.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1747357080; a=rsa-sha256; cv=none; b=IK0luQmse3QM0bCTQtSRvtMoXRzkN+RyEYrjQUrwCM3MF41GWbAhM+G104i2itEzcUFkEy +HR/41tQoKn6nEqrLzoGaE23Fn/6EiIuAe/EMkKXKpJ/VrtZw4fG4tKyQ370i79Ny+9Gmd u1neALF0x1iPxi4msYlgOstUQgc2Rw8= Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-30ab4d56096so1865773a91.0 for ; Thu, 15 May 2025 17:58:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1747357079; x=1747961879; darn=kvack.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=T8/qY0LTEjs6FgRExW+zZPRu+s+HGdicfzCVV2cwKQ8=; b=Uq4PjZfUlMbiUtSjU2q4/ZVbpYf3DnDMY0kw3s3czOiwQR3cP98OCSHS4UcOR98tIi z9y0AeA3fBjK6LLsFCRIs5IJmfFPzsO4uKbZ2qznaxaFTj8GA+D17c0zwsCxoft8mAku iUFivfaa9Trbo6pWlkOb4TiqQWYOQC+r9eoz0oMyOF+/CwdhgFoLslLc4tO8xeBKxXew piDPRtE+ypjvPY8bZ0mxiNeO5gh7VsQ5o09HPppm6TBN8IC7+ozqFUjQu/q26JRcdGJj oA4LCrwSDnyH5oi6em79kFr1GG8pJBOWjoipKOnsFLXdRyNoNtjDB9fzNAThtaqAJRDY YNoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747357079; x=1747961879; h=content-transfer-encoding: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; bh=T8/qY0LTEjs6FgRExW+zZPRu+s+HGdicfzCVV2cwKQ8=; b=mScehRFIxhsBd19f4Xtjr1gxYlcTDX1rgUkjkwkCgbEITfikeoWUDWk+SQTrd2Jx0H B+nwRU78YWfzp84xjXeDY7adhFYwzccZdqiUkI/0zoz4SLV+7J3adI9wnxgsUTBPXRhf 0w6vjqhK+QoXVepmEhANt/zYJvYv3wxFF2sV3yqldEXK59X+Cy4HOn8xpxPRXm03pb3N zEUISzjUQ8hrSTLKBilecc1BQ8Jy1mJReAIEd8B+jrnFDWbMCk+gxi3pMhCJC8nwb/yv OrXop9CmRV89/A+BLHCumwPhPurh5K/rHYL9tpS4hZIpjmZ/G7/DHpmXumjT7VnHimyo qxjA== X-Forwarded-Encrypted: i=1; AJvYcCXC3F54dW9wmTJe61vEGujC7qk6rq/+3uFfnsynF0wU1lVQrVrqAkxwGGHCA8XSHWBx02bSJFNWyg==@kvack.org X-Gm-Message-State: AOJu0Yxm/d7rftYHSs0821ReIJkr4GtS2YgHxlO9u+M3f4l7nxTe4NXE eglgNWiRnioWvt8lqx5NY69KlNzfTwZn7Vmna46Ivf14a0uYLTRwudQijZTeEh7AZ+66/F+SBGs wWK43Jg== X-Google-Smtp-Source: AGHT+IF7Bc+1kpTJUwa8ygptmPhSCVf8jmwAYEk8NLvIetBZg+2JsVv2O2B8rcUMCbgag6GZIPMPzybYoNI= X-Received: from pjbpt6.prod.google.com ([2002:a17:90b:3d06:b0:30a:7da4:f075]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:2e42:b0:2fe:85f0:e115 with SMTP id 98e67ed59e1d1-30e7d5acb46mr1591612a91.26.1747357078925; Thu, 15 May 2025 17:57:58 -0700 (PDT) Date: Thu, 15 May 2025 17:57:57 -0700 In-Reply-To: <24e8ae7483d0fada8d5042f9cd5598573ca8f1c5.camel@intel.com> Mime-Version: 1.0 References: <24e8ae7483d0fada8d5042f9cd5598573ca8f1c5.camel@intel.com> Message-ID: Subject: Re: [RFC PATCH v2 00/51] 1G page support for guest_memfd From: Sean Christopherson To: Rick P Edgecombe Cc: Vishal Annapurve , "palmer@dabbelt.com" , "kvm@vger.kernel.org" , "catalin.marinas@arm.com" , Jun Miao , "nsaenz@amazon.es" , "pdurrant@amazon.co.uk" , "vbabka@suse.cz" , "peterx@redhat.com" , "x86@kernel.org" , "tabba@google.com" , "keirf@google.com" , "quic_svaddagi@quicinc.com" , "amoorthy@google.com" , "pvorel@suse.cz" , "quic_eberman@quicinc.com" , "mail@maciej.szmigiero.name" , "vkuznets@redhat.com" , "anthony.yznaga@oracle.com" , Wei W Wang , "jack@suse.cz" , Maciej Wieczor-Retman , Yan Y Zhao , Dave Hansen , "ajones@ventanamicro.com" , "paul.walmsley@sifive.com" , "quic_mnalajal@quicinc.com" , "aik@amd.com" , "usama.arif@bytedance.com" , "willy@infradead.org" , "rppt@kernel.org" , "bfoster@redhat.com" , "quic_cvanscha@quicinc.com" , Fan Du , "fvdl@google.com" , "linux-kernel@vger.kernel.org" , "thomas.lendacky@amd.com" , "mic@digikod.net" , "oliver.upton@linux.dev" , "akpm@linux-foundation.org" , "steven.price@arm.com" , "muchun.song@linux.dev" , "binbin.wu@linux.intel.com" , Zhiquan1 Li , "rientjes@google.com" , "mpe@ellerman.id.au" , Erdem Aktas , "david@redhat.com" , "jgg@ziepe.ca" , "hughd@google.com" , Haibo1 Xu , "jhubbard@nvidia.com" , "anup@brainfault.org" , "maz@kernel.org" , Isaku Yamahata , "jthoughton@google.com" , "steven.sistare@oracle.com" , "jarkko@kernel.org" , "quic_pheragu@quicinc.com" , Kirill Shutemov , "chenhuacai@kernel.org" , Kai Huang , "shuah@kernel.org" , "dwmw@amazon.co.uk" , "pankaj.gupta@amd.com" , Chao Peng , "nikunj@amd.com" , Alexander Graf , "viro@zeniv.linux.org.uk" , "pbonzini@redhat.com" , "yuzenghui@huawei.com" , "jroedel@suse.de" , "suzuki.poulose@arm.com" , "jgowans@amazon.com" , Yilun Xu , "liam.merwick@oracle.com" , "michael.roth@amd.com" , "quic_tsoni@quicinc.com" , "richard.weiyang@gmail.com" , Ira Weiny , "aou@eecs.berkeley.edu" , Xiaoyao Li , "qperret@google.com" , "kent.overstreet@linux.dev" , "dmatlack@google.com" , "james.morse@arm.com" , "brauner@kernel.org" , "roypat@amazon.co.uk" , "ackerleytng@google.com" , "linux-fsdevel@vger.kernel.org" , "pgonda@google.com" , "quic_pderrin@quicinc.com" , "linux-mm@kvack.org" , "will@kernel.org" , "hch@infradead.org" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Queue-Id: 7595F40002 X-Rspamd-Server: rspam09 X-Stat-Signature: w917ruetwuqs9mskimoeqtje7pjknbbt X-HE-Tag: 1747357080-911712 X-HE-Meta: U2FsdGVkX1/ch+F7G8+gp4fR9TGhcFZUyHPnG/v/d+rPQ8qrXYmHjc+Vd0ww+MNMwyoDr2cedOs1G6Ms2GqlkCF08N8brKjo2uryV0FsMXag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5MbhSGaXYUNcuR/mTXsTAlbjYoBs9JMHmj8b1DYOtvD9Kf97FNmVEdWT/e5wTcz+toJw6wYKgn7g3Q42y0reSN9t9+7CdlvEJ+OaNn2mgdKdCFlkKIezy9SYRPitQbPczvB3HcbB3i27qPdp3flFiiuyQs3rDqOmaKS1mYnJ+j7hJxEzFAjNvX1MZf2XJvptkD2kfCQKOnA3vEaZxoULmxkvp3/szcDkjIAy3+IsilvKhV5a0ZWwBAGe2p2A6JZYd6cgiQODj0xpSKRcT9Khc3Q+AAeBnAx0jNVvv40FMvLdK29sP/ZuUfSKAo6AqPOC6lHo9JoZ+LL1mf+OTdCnDTikklF9ptHFIfDj6r0N8b7nY4QsGsd58H0VY19tGdf+3r6SI74y4/32j0hCCyTijU+q8FZ7xvRtXbB5G/aZD5PaMZXs3txbRVRj5407qSPH4jchU9mudrd1uzQn7uecQPiU+kLeMb3G8VMA1Vvj4TJwyHuIfDNqbl8XklGFCwGFUGzMbIaq9X31QxfpNKpLofHI8y+Nc0YTjSXFx94dyGf58sPqXAle2MfIM3JsOL+NB9MKQFiHk= 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: List-Subscribe: List-Unsubscribe: On Thu, May 15, 2025, Rick P Edgecombe wrote: > On Thu, 2025-05-15 at 11:42 -0700, Vishal Annapurve wrote: > > On Thu, May 15, 2025 at 11:03=E2=80=AFAM Edgecombe, Rick P > > wrote: > > >=20 > > > On Wed, 2025-05-14 at 16:41 -0700, Ackerley Tng wrote: > > > > Hello, > > > >=20 > > > > This patchset builds upon discussion at LPC 2024 and many guest_mem= fd > > > > upstream calls to provide 1G page support for guest_memfd by taking > > > > pages from HugeTLB. > > >=20 > > > Do you have any more concrete numbers on benefits of 1GB huge pages f= or > > > guestmemfd/coco VMs? I saw in the LPC talk it has the benefits as: > > > - Increase TLB hit rate and reduce page walks on TLB miss > > > - Improved IO performance > > > - Memory savings of ~1.6% from HugeTLB Vmemmap Optimization (HVO) > > > - Bring guest_memfd to parity with existing VMs that use HugeTLB page= s for > > > backing memory > > >=20 > > > Do you know how often the 1GB TDP mappings get shattered by shared pa= ges? > > >=20 > > > Thinking from the TDX perspective, we might have bigger fish to fry t= han 1.6% > > > memory savings (for example dynamic PAMT), and the rest of the benefi= ts don't > > > have numbers. How much are we getting for all the complexity, over sa= y buddy > > > allocated 2MB pages? TDX may have bigger fish to fry, but some of us have bigger fish to fry tha= n TDX :-) > > This series should work for any page sizes backed by hugetlb memory. > > Non-CoCo VMs, pKVM and Confidential VMs all need hugepages that are > > essential for certain workloads and will emerge as guest_memfd users. > > Features like KHO/memory persistence in addition also depend on > > hugepage support in guest_memfd. > >=20 > > This series takes strides towards making guest_memfd compatible with > > usecases where 1G pages are essential and non-confidential VMs are > > already exercising them. > >=20 > > I think the main complexity here lies in supporting in-place > > conversion which applies to any huge page size even for buddy > > allocated 2MB pages or THP. > >=20 > > This complexity arises because page structs work at a fixed > > granularity, future roadmap towards not having page structs for guest > > memory (at least private memory to begin with) should help towards > > greatly reducing this complexity. > >=20 > > That being said, DPAMT and huge page EPT mappings for TDX VMs remain > > essential and complement this series well for better memory footprint > > and overall performance of TDX VMs. >=20 > Hmm, this didn't really answer my questions about the concrete benefits. >=20 > I think it would help to include this kind of justification for the 1GB > guestmemfd pages. "essential for certain workloads and will emerge" is a = bit > hard to review against... >=20 > I think one of the challenges with coco is that it's almost like a sprint= to > reimplement virtualization. But enough things are changing at once that n= ot all > of the normal assumptions hold, so it can't copy all the same solutions. = The > recent example was that for TDX huge pages we found that normal promotion= paths > weren't actually yielding any benefit for surprising TDX specific reasons= . >=20 > On the TDX side we are also, at least currently, unmapping private pages = while > they are mapped shared, so any 1GB pages would get split to 2MB if there = are any > shared pages in them. I wonder how many 1GB pages there would be after al= l the > shared pages are converted. At smaller TD sizes, it could be not much. You're conflating two different things. guest_memfd allocating and managin= g 1GiB physical pages, and KVM mapping memory into the guest at 1GiB/2MiB granularity. Allocating memory in 1GiB chunks is useful even if KVM can on= ly map memory into the guest using 4KiB pages. > So for TDX in isolation, it seems like jumping out too far ahead to effec= tively > consider the value. But presumably you guys are testing this on SEV or > something? Have you measured any performance improvement? For what kind o= f > applications? Or is the idea to basically to make guestmemfd work like ho= wever > Google does guest memory? The longer term goal of guest_memfd is to make it suitable for backing all = VMs, hence Vishal's "Non-CoCo VMs" comment. Yes, some of this is useful for TDX= , but we (and others) want to use guest_memfd for far more than just CoCo VMs. A= nd for non-CoCo VMs, 1GiB hugepages are mandatory for various workloads.