From: Vincent Donnefort <vdonnefort@google.com>
To: Will Deacon <will@kernel.org>
Cc: julien.thierry.kdev@gmail.com, kvm@vger.kernel.org,
kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
maz@kernel.org, oliver.upton@linux.dev, suzuki.poulose@arm.com,
alexandru.elisei@arm.com, andre.przywara@arm.com
Subject: Re: [PATCH kvmtool] arm64: THPs for systems with pages bigger than 4K
Date: Thu, 26 Nov 2026 20:35:01 +0000 [thread overview]
Message-ID: <awiX9cEDByf7d40x@google.com> (raw)
In-Reply-To: <awhZk3NrkqeGvQxC@willie-the-truck>
On Thu, Nov 26, 2026 at 04:08:51PM +0000, Will Deacon wrote:
> On Mon, Oct 19, 2026 at 03:59:49PM +0100, Vincent Donnefort wrote:
> > The THP support imposes an alignment of the memslot userspace address to
> > the size of a THP (PMD_SIZE). To do so, kvmtool overallocates the RAM
> > size and aligns it. However it assumes PMD_SIZE is 2MiB, which is only
> > true on 4KiB page systems.
> >
> > Use a huge-page size, based on the system page size. This value can be
> > massive for a 64KiB page system, so skip the alignment if we couldn't
> > even install one THP.
> >
> > Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
> >
> > diff --git a/arm64/kvm.c b/arm64/kvm.c
> > index 36b3284e4a92..2c01dc32fa9a 100644
> > --- a/arm64/kvm.c
> > +++ b/arm64/kvm.c
> > @@ -18,6 +18,8 @@
> >
> > #include <asm/image.h>
> >
> > +#define HUGEPAGE_SIZE (PAGE_SIZE * (PAGE_SIZE / 8UL))
>
> Does this invoke sysconf() twice per invocation?
>
> Will
It does.
How about I use for PAGE_SIZE a memoized version of the existing
host_page_size() function?
kvm/util.h:
unsigned long host_page_size(void);
#define PAGE_SIZE host_page_size()
util.c:
unsigned long host_page_size(void)
{
static unsigned long page_size;
if (!page_size)
page_size = sysconf(_SC_PAGE_SIZE);
return page_size;
}
--
Vincent
next prev parent reply other threads:[~2026-11-26 20:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 14:59 [PATCH kvmtool] arm64: THPs for systems with pages bigger than 4K Vincent Donnefort
2026-10-20 14:43 ` Suzuki K Poulose
2026-10-22 8:31 ` Vincent Donnefort
2026-11-26 16:08 ` Will Deacon
2026-11-26 20:35 ` Vincent Donnefort [this message]
2026-11-27 14:41 ` Will Deacon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=awiX9cEDByf7d40x@google.com \
--to=vdonnefort@google.com \
--cc=alexandru.elisei@arm.com \
--cc=andre.przywara@arm.com \
--cc=julien.thierry.kdev@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.