KVM: Allocate small memslot metadata with kvzalloc()
Status from this message: Applied to kvm-x86 generic, thanks!
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest2 patches 1 replyApplied
- v11 patch 2 repliesSuperseded
Changes in v2 from the cover letter
- Split the helpers and the allocator change into two patches
- Pivot on KMALLOC_MAX_CACHE_SIZE instead of INT_MAX
Patches in v2 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | KVM: Add helpers to allocate memslot metadataarch/ arch/ include/ +1 more | +22 | 0 replies | |
| 2/2 | KVM: Use kvzalloc() for memslot metadata that fits in a slab bucketvirt/ | +9 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [PATCH v2 0/2] KVM: Allocate small memslot metadata with kvzalloc()
From: Fred Griffoul <[email protected]>
__vcalloc() makes every memslot metadata allocation at least one page, so small memslots waste most of their lpage_info and dirty bitmap, and memslots below 512 GiB waste most of a page on their 1 GiB lpage_info. Mushahid's patch [1] switched those arrays to kvcalloc(), and Sean suggested dedicated helpers for memslot metadata with a pivot that makes sense for KVM instead [2].
Patch 1 adds the helpers and routes the dirty bitmap, rmaps, lpage_info and write-tracking arrays through them, with no functional change. Patch 2 makes the helpers use kvzalloc() up to KMALLOC_MAX_CACHE_SIZE, where kmalloc() never uses more memory than vmalloc(), and keeps __vcalloc() above.
I ran the memslot and dirty logging selftests with the TDP MMU and with kvm.tdp_mmu=0, plus a check that one-page memslots no longer take a vmalloc area each and that a 1 TiB memslot still gets its rmaps from vmalloc.
Fred
Changes in v2:
- Split the helpers and the allocator change into two patches
- Pivot on KMALLOC_MAX_CACHE_SIZE instead of INT_MAX
v1: https://lore.kernel.org/kvm/[email protected]/
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
Fred Griffoul (2):
KVM: Add helpers to allocate memslot metadata
KVM: Use kvzalloc() for memslot metadata that fits in a slab bucket
arch/x86/kvm/mmu/page_track.c | 6 +++--- arch/x86/kvm/x86.c | 10 +++++----- include/linux/kvm_host.h | 2 ++ virt/kvm/kvm_main.c | 22 ++++++++++++++++++++-- 4 files changed, 30 insertions(+), 10 deletions(-)
base-commit: d21eef2084a9af87ac2a783bc7c2b175ba114e4e
Signature · 1 line
2.47.3