All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Fred Griffoul <griffoul@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Mushahid Hussain <hmushi@amazon.co.uk>,
	nh-open-source@amazon.com,  kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: Add helpers to allocate memslot metadata
Date: Wed, 4 Nov 2026 05:58:51 -0800	[thread overview]
Message-ID: <aus6G5VqWJv1gq7U@google.com> (raw)
In-Reply-To: <20261103234734.45413-1-griffoul@gmail.com>

On Tue, Nov 03, 2026, Fred Griffoul wrote:
> From: Fred Griffoul <fgriffo@amazon.co.uk>
> 
> __vcalloc() makes every allocation at least one page, so a memslot
> that spans a single page uses 8 KiB of vmalloc for 8 bytes of
> lpage_info, plus 4 KiB for a 16-byte dirty bitmap once dirty logging
> is enabled. The waste grows with the number of memslots and VMs on a
> host. kvcalloc() avoids it for small arrays, but refuses allocations
> above INT_MAX bytes, which the rmap and write-tracking arrays of a
> large memslot exceed.
> 
> Add kvm_memslot_metadata_alloc() and kvm_memslot_metadata_free(),
> which use kvzalloc() up to INT_MAX bytes and vmalloc above, and route
> the dirty bitmap, rmaps, lpage_info and write-tracking arrays through
> them. That way, how KVM allocates memslot metadata is decided in one
> place instead of at each array.
> 
> Suggested-by: Sean Christopherson <seanjc@google.com>
> Link: https://lore.kernel.org/all/arr1VgGZmgUmY4hc@google.com/
> Signed-off-by: Fred Griffoul <fgriffo@amazon.co.uk>
> ---
> Mushahid's patch [1] switched the lpage_info arrays and dirty bitmaps to
> kvcalloc(). Sean suggested dedicated helpers for memslot metadata
> instead [2], which this patch adds.

Split this into two patches: patch 1 to add the helpers, patch 2 to add the logic
to pivot on INT_MAX

As is, the shortlog is comically misleading.  Pretty much anyone is going to read
this and assume it's just refactoring existing code.

  reply	other threads:[~2026-11-04 13:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03 23:47 [PATCH] KVM: Add helpers to allocate memslot metadata Fred Griffoul
2026-11-04 13:58 ` Sean Christopherson [this message]
2026-11-04 17:24   ` Fred Griffoul

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=aus6G5VqWJv1gq7U@google.com \
    --to=seanjc@google.com \
    --cc=griffoul@gmail.com \
    --cc=hmushi@amazon.co.uk \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nh-open-source@amazon.com \
    --cc=pbonzini@redhat.com \
    /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.