Skip to content

KVM: Cleanup and unify kvm_mmu_memory_cache usage

Sean Christopherson kvm kvmarm linux-arch linux-arm-kernel linux-mips lkml 3 versions – Applied

Status from this message: Queued, thanks.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest21 patches 1 replyApplied
  2. v221 patches 3 repliesSuperseded
  3. v121 patches 32 repliesSuperseded

Changes in v3 from the cover letter

- Rebased to kvm/queue, commit a037ff353ba6 ("Merge ... into HEAD")
- Collect more review tags. [Ben]

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/21KVM: x86/mmu: Track the associated kmem_cache in the MMU cachesarch/x86/include/asm/kvm_host.h arch/x86/kvm/mmu/mmu.c+12 -130 replies
2/21KVM: x86/mmu: Consolidate "page" variant of memory cache helpersarch/x86/kvm/mmu/mmu.c+11 -260 replies
3/21KVM: x86/mmu: Use consistent "mc" name for kvm_mmu_memory_cache localsarch/x86/kvm/mmu/mmu.c+12 -120 replies
4/21KVM: x86/mmu: Remove superfluous gotos from mmu_topup_memory_caches()arch/x86/kvm/mmu/mmu.c+3 -50 replies
5/21KVM: x86/mmu: Try to avoid crashing KVM if a MMU memory cache is emptyarch/x86/kvm/mmu/mmu.c+15 -60 replies
6/21KVM: x86/mmu: Move fast_page_fault() call above mmu_topup_memory_caches()arch/x86/kvm/mmu/mmu.c+3 -30 replies
7/21KVM: x86/mmu: Topup memory caches after walking GVA->GPAarch/x86/kvm/mmu/paging_tmpl.h+4 -40 replies
8/21KVM: x86/mmu: Clean up the gorilla math in mmu_topup_memory_caches()arch/x86/kvm/mmu/mmu.c+6 -30 replies
9/21KVM: x86/mmu: Separate the memory caches for shadow pages and gfn arraysarch/x86/include/asm/kvm_host.h arch/x86/kvm/mmu/mmu.c+12 -60 replies
10/21KVM: x86/mmu: Make __GFP_ZERO a property of the memory cachearch/x86/include/asm/kvm_host.h arch/x86/kvm/mmu/mmu.c+7 -10 replies
11/21KVM: x86/mmu: Zero allocate shadow pages (outside of mmu_lock)arch/x86/kvm/mmu/mmu.c+2 -10 replies
12/21KVM: x86/mmu: Skip filling the gfn cache for guaranteed direct MMU topupsarch/x86/kvm/mmu/mmu.c arch/x86/kvm/mmu/paging_tmpl.h+12 -100 replies
13/21KVM: x86/mmu: Prepend "kvm_" to memory cache helpers that will be globalarch/x86/kvm/mmu/mmu.c+21 -210 replies
14/21KVM: Move x86's version of struct kvm_mmu_memory_cache to common codearch/arm64/include/asm/Kbuild arch/mips/include/asm/Kbuild arch/powerpc/include/asm/Kbuild +5 more+35 -130 replies
15/21KVM: Move x86's MMU memory cache helpers to common KVM codearch/x86/kvm/mmu/mmu.c include/linux/kvm_host.h virt/kvm/kvm_main.c+62 -530 replies
16/21KVM: arm64: Drop @max param from mmu_topup_memory_cache()arch/arm64/kvm/mmu.c+4 -80 replies
17/21KVM: arm64: Use common code's approach for __GFP_ZERO with memory cachesarch/arm64/include/asm/kvm_host.h arch/arm64/kvm/arm.c arch/arm64/kvm/mmu.c+6 -20 replies
18/21KVM: arm64: Use common KVM implementation of MMU memory cachesarch/arm64/include/asm/Kbuild arch/arm64/include/asm/kvm_host.h arch/arm64/include/asm/kvm_types.h +1 more+19 -550 replies
19/21KVM: MIPS: Drop @max param from mmu_topup_memory_cache()arch/mips/kvm/mmu.c+4 -80 replies
20/21KVM: MIPS: Account pages used for GPA page tablesarch/mips/kvm/mmu.c+1 -10 replies
21/21KVM: MIPS: Use common KVM implementation of MMU memory cachesarch/mips/include/asm/Kbuild arch/mips/include/asm/kvm_host.h arch/mips/include/asm/kvm_types.h +1 more+12 -470 replies

Reviews trailers per patch

15 of 21 patches have a Reviewed-by or Acked-by.

PatchBen GardonMarc Zyngier
1/21R-b
2/21R-b
3/21R-b
4/21R-b
5/21R-b
6/21R-b
7/21R-b
8/21R-b
9/21R-b
10/21R-b
11/21R-b
12/21R-b
13/21R-b
14/21R-b
15/21R-b
16/21T-b
17/21T-b
18/21
19/21
20/21
21/21

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 00/21] KVM: Cleanup and unify kvm_mmu_memory_cache usage

The only interesting delta from v2 is that patch 18 is updated to handle a conflict with arm64's p4d rework. Resolution was straightforward (famous last words).

This series resurrects Christoffer Dall's series[1] to provide a common MMU memory cache implementation that can be shared by x86, arm64 and MIPS.

It also picks up a suggested change from Ben Gardon[2] to clear shadow page tables during initial allocation so as to avoid clearing entire pages while holding mmu_lock.

The front half of the patches do house cleaning on x86's memory cache implementation in preparation for moving it to common code, along with a fair bit of cleanup on the usage. The middle chunk moves the patches to common KVM, and the last two chunks convert arm64 and MIPS to the common implementation.

Fully tested on x86 only. Compile tested patches 14-21 on arm64, MIPS, s390 and PowerPC.

v3:
- Rebased to kvm/queue, commit a037ff353ba6 ("Merge ... into HEAD")
- Collect more review tags. [Ben]

v2:
- Rebase to kvm-5.8-2, commit 49b3deaad345 ("Merge tag ...").
- Use an asm-generic kvm_types.h for s390 and PowerPC instead of an empty arch-specific file. [Marc]
- Explicit document "GFP_PGTABLE_USER == GFP_KERNEL_ACCOUNT | GFP_ZERO" in the arm64 conversion patch. [Marc]
- Collect review tags. [Ben]

Sean Christopherson (21):
KVM: x86/mmu: Track the associated kmem_cache in the MMU caches
KVM: x86/mmu: Consolidate "page" variant of memory cache helpers
KVM: x86/mmu: Use consistent "mc" name for kvm_mmu_memory_cache locals
KVM: x86/mmu: Remove superfluous gotos from mmu_topup_memory_caches()
KVM: x86/mmu: Try to avoid crashing KVM if a MMU memory cache is empty
KVM: x86/mmu: Move fast_page_fault() call above
mmu_topup_memory_caches()
KVM: x86/mmu: Topup memory caches after walking GVA->GPA
KVM: x86/mmu: Clean up the gorilla math in mmu_topup_memory_caches()
KVM: x86/mmu: Separate the memory caches for shadow pages and gfn
arrays
KVM: x86/mmu: Make __GFP_ZERO a property of the memory cache
KVM: x86/mmu: Zero allocate shadow pages (outside of mmu_lock)
KVM: x86/mmu: Skip filling the gfn cache for guaranteed direct MMU
topups
KVM: x86/mmu: Prepend "kvm_" to memory cache helpers that will be
global
KVM: Move x86's version of struct kvm_mmu_memory_cache to common code
KVM: Move x86's MMU memory cache helpers to common KVM code
KVM: arm64: Drop @max param from mmu_topup_memory_cache()
KVM: arm64: Use common code's approach for __GFP_ZERO with memory
caches
KVM: arm64: Use common KVM implementation of MMU memory caches
KVM: MIPS: Drop @max param from mmu_topup_memory_cache()
KVM: MIPS: Account pages used for GPA page tables
KVM: MIPS: Use common KVM implementation of MMU memory caches

 arch/arm64/include/asm/kvm_host.h  |  11 ---
 arch/arm64/include/asm/kvm_types.h |   8 ++
 arch/arm64/kvm/arm.c               |   2 +
 arch/arm64/kvm/mmu.c               |  56 +++----------
 arch/mips/include/asm/kvm_host.h   |  11 ---
 arch/mips/include/asm/kvm_types.h  |   7 ++
 arch/mips/kvm/mmu.c                |  44 ++--------
 arch/powerpc/include/asm/Kbuild    |   1 +
 arch/s390/include/asm/Kbuild       |   1 +
 arch/x86/include/asm/kvm_host.h    |  14 +---
 arch/x86/include/asm/kvm_types.h   |   7 ++
 arch/x86/kvm/mmu/mmu.c             | 129 +++++++++--------------------
 arch/x86/kvm/mmu/paging_tmpl.h     |  10 +--
 include/asm-generic/kvm_types.h    |   5 ++
 include/linux/kvm_host.h           |   7 ++
 include/linux/kvm_types.h          |  19 +++++
 virt/kvm/kvm_main.c                |  55 ++++++++++++
 17 files changed, 176 insertions(+), 211 deletions(-)
 create mode 100644 arch/arm64/include/asm/kvm_types.h
 create mode 100644 arch/mips/include/asm/kvm_types.h
 create mode 100644 arch/x86/include/asm/kvm_types.h
 create mode 100644 include/asm-generic/kvm_types.h
Signature · 1 line
2.26.0