[Patch v4 09/18] KVM: x86/mmu: Shrink mmu_shadowed_info_cache via MMU shrinker

From: Vipin Sharma
Date: Mon Mar 06 2023 - 17:42:20 EST


Shrink shadow page cache via MMU shrinker based on
kvm_total_unused_cached_pages.

Tested by running dirty_log_perf_test while dropping cache
via "echo 2 > /proc/sys/vm/drop_caches" at 1 second interval. Global
always return to 0. Shrinker also gets invoked to remove pages in cache.

Above test were run with three configurations:
- EPT=N
- EPT=Y, TDP_MMU=N
- EPT=Y, TDP_MMU=Y

Signed-off-by: Vipin Sharma <vipinsh@xxxxxxxxxx>
---
arch/x86/kvm/mmu/mmu.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index b7ca31b5699c..a4bf2e433030 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -6725,6 +6725,8 @@ static unsigned long mmu_shrink_scan(struct shrinker *shrink,
kvm_for_each_vcpu(i, vcpu, kvm) {
freed += mmu_memory_cache_try_empty(&vcpu->arch.mmu_shadow_page_cache,
&vcpu->arch.mmu_shadow_page_cache_lock);
+ freed += mmu_memory_cache_try_empty(&vcpu->arch.mmu_shadowed_info_cache,
+ &vcpu->arch.mmu_shadow_page_cache_lock);
if (freed >= sc->nr_to_scan)
goto out;
}
--
2.40.0.rc0.216.gc4246ad0f0-goog