[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fbb240fef8b7091ece5f88f394adebe19aec35ba.camel@intel.com>
Date: Fri, 16 May 2025 21:42:35 +0000
From: "Edgecombe, Rick P" <rick.p.edgecombe@...el.com>
To: "Hansen, Dave" <dave.hansen@...el.com>, "seanjc@...gle.com"
<seanjc@...gle.com>
CC: "pvorel@...e.cz" <pvorel@...e.cz>, "kvm@...r.kernel.org"
<kvm@...r.kernel.org>, "catalin.marinas@....com" <catalin.marinas@....com>,
"Miao, Jun" <jun.miao@...el.com>, "Shutemov, Kirill"
<kirill.shutemov@...el.com>, "pdurrant@...zon.co.uk" <pdurrant@...zon.co.uk>,
"vbabka@...e.cz" <vbabka@...e.cz>, "peterx@...hat.com" <peterx@...hat.com>,
"x86@...nel.org" <x86@...nel.org>, "amoorthy@...gle.com"
<amoorthy@...gle.com>, "tabba@...gle.com" <tabba@...gle.com>,
"maz@...nel.org" <maz@...nel.org>, "jack@...e.cz" <jack@...e.cz>,
"palmer@...belt.com" <palmer@...belt.com>, "quic_svaddagi@...cinc.com"
<quic_svaddagi@...cinc.com>, "keirf@...gle.com" <keirf@...gle.com>,
"Annapurve, Vishal" <vannapurve@...gle.com>, "anthony.yznaga@...cle.com"
<anthony.yznaga@...cle.com>, "mail@...iej.szmigiero.name"
<mail@...iej.szmigiero.name>, "vkuznets@...hat.com" <vkuznets@...hat.com>,
"Wieczor-Retman, Maciej" <maciej.wieczor-retman@...el.com>, "Zhao, Yan Y"
<yan.y.zhao@...el.com>, "ajones@...tanamicro.com" <ajones@...tanamicro.com>,
"quic_mnalajal@...cinc.com" <quic_mnalajal@...cinc.com>, "rppt@...nel.org"
<rppt@...nel.org>, "Du, Fan" <fan.du@...el.com>, "aik@....com" <aik@....com>,
"usama.arif@...edance.com" <usama.arif@...edance.com>, "Wang, Wei W"
<wei.w.wang@...el.com>, "fvdl@...gle.com" <fvdl@...gle.com>,
"paul.walmsley@...ive.com" <paul.walmsley@...ive.com>, "bfoster@...hat.com"
<bfoster@...hat.com>, "quic_cvanscha@...cinc.com"
<quic_cvanscha@...cinc.com>, "willy@...radead.org" <willy@...radead.org>,
"steven.price@....com" <steven.price@....com>, "quic_eberman@...cinc.com"
<quic_eberman@...cinc.com>, "thomas.lendacky@....com"
<thomas.lendacky@....com>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, "mic@...ikod.net" <mic@...ikod.net>,
"oliver.upton@...ux.dev" <oliver.upton@...ux.dev>, "nsaenz@...zon.es"
<nsaenz@...zon.es>, "akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
"binbin.wu@...ux.intel.com" <binbin.wu@...ux.intel.com>,
"muchun.song@...ux.dev" <muchun.song@...ux.dev>, "Li, Zhiquan1"
<zhiquan1.li@...el.com>, "rientjes@...gle.com" <rientjes@...gle.com>, "Aktas,
Erdem" <erdemaktas@...gle.com>, "mpe@...erman.id.au" <mpe@...erman.id.au>,
"david@...hat.com" <david@...hat.com>, "jgg@...pe.ca" <jgg@...pe.ca>,
"hughd@...gle.com" <hughd@...gle.com>, "Xu, Haibo1" <haibo1.xu@...el.com>,
"jhubbard@...dia.com" <jhubbard@...dia.com>, "anup@...infault.org"
<anup@...infault.org>, "Yamahata, Isaku" <isaku.yamahata@...el.com>,
"jthoughton@...gle.com" <jthoughton@...gle.com>, "steven.sistare@...cle.com"
<steven.sistare@...cle.com>, "jarkko@...nel.org" <jarkko@...nel.org>,
"quic_pheragu@...cinc.com" <quic_pheragu@...cinc.com>,
"chenhuacai@...nel.org" <chenhuacai@...nel.org>, "Huang, Kai"
<kai.huang@...el.com>, "shuah@...nel.org" <shuah@...nel.org>,
"dwmw@...zon.co.uk" <dwmw@...zon.co.uk>, "pankaj.gupta@....com"
<pankaj.gupta@....com>, "Peng, Chao P" <chao.p.peng@...el.com>,
"nikunj@....com" <nikunj@....com>, "Graf, Alexander" <graf@...zon.com>,
"viro@...iv.linux.org.uk" <viro@...iv.linux.org.uk>, "pbonzini@...hat.com"
<pbonzini@...hat.com>, "yuzenghui@...wei.com" <yuzenghui@...wei.com>,
"jroedel@...e.de" <jroedel@...e.de>, "suzuki.poulose@....com"
<suzuki.poulose@....com>, "jgowans@...zon.com" <jgowans@...zon.com>, "Xu,
Yilun" <yilun.xu@...el.com>, "liam.merwick@...cle.com"
<liam.merwick@...cle.com>, "michael.roth@....com" <michael.roth@....com>,
"quic_tsoni@...cinc.com" <quic_tsoni@...cinc.com>,
"richard.weiyang@...il.com" <richard.weiyang@...il.com>, "Weiny, Ira"
<ira.weiny@...el.com>, "aou@...s.berkeley.edu" <aou@...s.berkeley.edu>, "Li,
Xiaoyao" <xiaoyao.li@...el.com>, "qperret@...gle.com" <qperret@...gle.com>,
"kent.overstreet@...ux.dev" <kent.overstreet@...ux.dev>,
"dmatlack@...gle.com" <dmatlack@...gle.com>, "james.morse@....com"
<james.morse@....com>, "brauner@...nel.org" <brauner@...nel.org>,
"ackerleytng@...gle.com" <ackerleytng@...gle.com>,
"linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
"pgonda@...gle.com" <pgonda@...gle.com>, "quic_pderrin@...cinc.com"
<quic_pderrin@...cinc.com>, "hch@...radead.org" <hch@...radead.org>,
"roypat@...zon.co.uk" <roypat@...zon.co.uk>, "will@...nel.org"
<will@...nel.org>, "linux-mm@...ck.org" <linux-mm@...ck.org>
Subject: Re: [RFC PATCH v2 00/51] 1G page support for guest_memfd
On Fri, 2025-05-16 at 13:25 -0700, Dave Hansen wrote:
> It's a little more complicated than just the depth of the worst-case walk.
>
> In practice, many page walks can use the mid-level paging structure
> caches because the mappings aren't sparse.
>
> With 5-level paging in particular, userspace doesn't actually change
> much at all. Its layout is pretty much the same unless folks are opting
> in to the higher (5-level only) address space. So userspace isn't
> sparse, at least at the scale of what 5-level paging is capable of.
>
> For the kernel, things are a bit more spread out than they were before.
> For instance, the direct map and vmalloc() are in separate p4d pages
> when they used to be nestled together in the same half of one pgd.
>
> But, again, they're not *that* sparse. The direct map, for example,
> doesn't become more sparse, it just moves to a lower virtual address.
> Ditto for vmalloc(). Just because 5-level paging has a massive
> vmalloc() area doesn't mean we use it.
>
> Basically, 5-level paging adds a level to the top of the page walk, and
> we're really good at caching those when they're not accessed sparsely.
>
> CPUs are not as good at caching the leaf side of the page walk. There
> are tricks like AMD's TLB coalescing that help. But, generally, each
> walk on the leaf end of the walks eats a TLB entry. Those just don't
> cache as well as the top of the tree.
>
> That's why we need to be more maniacal about reducing leaf levels than
> the levels toward the root.
Makes sense. For what is easy for the CPU to cache, it can be more about the
address space layout then the length of the walk.
Going off topic from this patchset...
I have a possibly fun related anecdote. A while ago when I was doing the KVM XO
stuff, I was trying to test how much worse the performance was from caches being
forced to deal with the sparser GPA accesses. The test was to modify the guest
to force all the executable GVA mappings to go on the XO alias. I was confused
to find that KVM XO was faster than the normal layout by a small, but consistent
amount. It had me scratching my head. It turned out that the NX huge page
mitigation was able to maintain large pages for the data accesses because all
the executable accesses were moved off of the main GPA alias.
My takeaway was that the real world implementations can interact in surprising
ways, and for at least my ability to reason about it, it's good to verify with a
test when possible.
Powered by blists - more mailing lists