Skip to contentSkip to conversation

KVM: x86/mmu: Repurpose MMU shrinker into page cache shrinker

PATCH In review Vipin Sharma 3 participants 11 messages Oct 4, 2024 – Oct 28, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover KVM: x86/mmu: Repurpose MMU shrinker into page cache shrinker

This series is extracted out from the NUMA aware page table series[1]. MMU shrinker changes were in patches 1 to 9 in the old series.

This series is changing KVM MMU shrinker behaviour by emptying MMU page caches which are used during page fault and MMU load operations. It also incorporates feedback from the NUMA aware page table series[1] regarding MMU shrinker.

KVM MMU shrinker has not been very effective in alleviating pain under memory pressure. It frees up the pages actively being used which results in VM degradation. VM will take fault and bring them again in page tables. More discussions happened at [2]. Overall, consensus was to reprupose it into the code which frees pages from KVM MMU page caches.

Recently [3], there was a discussion to disable shrinker for TDP MMU. Revival of this series is result of that discussion.

There are two major differences from the old series.
1. There is no global accounting of cache pages. It is dynamically calculated in mmu_shrink_count(). This has two effects; i) counting will be inaccurate but code is much simpler, and ii) kvm_lock being used here, this should be fine as mmu_shrink_scan() also holds the lock for its operation.
2. Only empty mmu_shadow_page_cache and mmu_shadowed_info_cache. This version doesn't empty split_shadow_page_cache as it is used only during dirty logging operation and is one per VM unlike other two which are per vCPU. I am not fully convinced that adding it is needed as it will add the cost of adding one more mutex and synchronizing it in shrinker. Also, if a VM is being dirty tracked most likely it will be migrated (memory pressure might be the reason in the first place) so better to not hinder migration effort and let vCPUs free up their caches. If someone convinces me to add split cache as well then I can send a separate patch to add that as well.

[1] https://lore.kernel.org/kvm/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/
[3] https://lore.kernel.org/kvm/[email protected]/#t

Note to maintainers: scripts/checkpatch.pl is complaining about few things on selftest (patch 3). These are just false positives.

1. Prefer strscpy() over strcpy().
This kernel API and not general libc userspace API.
2. Unnecessary whitespace before a quoted new line.
Just the way help string is written for selftests to align output of help.
3. Prefer using '"%s...", __func__'
Because I wrote "help" word in the printf().

v2:
- Add a new selftest, mmu_shrinker_test.

v1: https://lore.kernel.org/kvm/[email protected]/
- No global counting of pages in cache. As this number might not remain same between calls of mmu_shrink_count() and mmu_shrink_scan().
- Count cache pages in mmu_shrink_count(). KVM can tolerate inaccuracy here.
- Empty mmu_shadow_page_cache and mmu_shadowed_info_cache only. Don't empty split_shadow_page_cache.

v0: Patches 1-9 from NUMA aware page table series.
https://lore.kernel.org/kvm/[email protected]/

Vipin Sharma (3):
KVM: x86/mmu: Change KVM mmu shrinker to no-op
KVM: x86/mmu: Use MMU shrinker to shrink KVM MMU memory caches
KVM: selftests: Add a test to invoke MMU shrinker on KVM VMs

 arch/x86/include/asm/kvm_host.h               |   7 +-
 arch/x86/kvm/mmu/mmu.c                        | 139 ++++-----
 arch/x86/kvm/mmu/paging_tmpl.h                |  14 +-
 include/linux/kvm_host.h                      |   1 +
 tools/testing/selftests/kvm/Makefile          |   1 +
 .../testing/selftests/kvm/include/test_util.h |   5 +
 tools/testing/selftests/kvm/lib/test_util.c   |  51 ++++
 .../selftests/kvm/x86_64/mmu_shrinker_test.c  | 269 ++++++++++++++++++
 virt/kvm/kvm_main.c                           |   8 +-
 9 files changed, 404 insertions(+), 91 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/x86_64/mmu_shrinker_test.c

base-commit: 12680d7b8ac4db2eba6237a21a93d2b0e78a52a6

Signature · 1 line
2.47.0.rc0.187.ge670bccf7e-goog
#1 lore raw

PATCH v2 1/3 KVM: x86/mmu: Change KVM mmu shrinker to no-op

Remove global kvm_total_used_mmu_pages and page zapping flow from MMU shrinker. Keep shrinker infrastructure in place to reuse in future commits for freeing KVM page caches. Remove zapped_obsolete_pages list from struct kvm_arch{} and use local list in kvm_zap_obsolete_pages() since MMU shrinker is not using it anymore.

mmu_shrink_scan() is very disruptive to VMs. It picks the first VM in the vm_list, zaps the oldest page which is most likely an upper level SPTEs and most like to be reused. Prior to TDP MMU, this is even more disruptive in nested VMs case, considering L1 SPTEs will be the oldest even though most of the entries are for L2 SPTEs.

As discussed in
https://lore.kernel.org/lkml/[email protected]/ shrinker logic has not be very useful in actually keeping VMs performant and reducing memory usage.

---
 arch/x86/include/asm/kvm_host.h |  1 -
 arch/x86/kvm/mmu/mmu.c          | 92 +++------------------------------
 2 files changed, 8 insertions(+), 85 deletions(-)
arch/x86/include/asm/kvm_host.h +0 -1
index b0c0bc0ed813f..cbfe31bac6cf6 100644
@@ -1309,7 +1309,6 @@ struct kvm_arch {
 	bool pre_fault_allowed;
 	struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES];
 	struct list_head active_mmu_pages;
-	struct list_head zapped_obsolete_pages;
 	/*
 	 * A list of kvm_mmu_page structs that, if zapped, could possibly be
 	 * replaced by an NX huge page.  A shadow page is on this list if its
arch/x86/kvm/mmu/mmu.c +8 -84

170 lines not on this page · raw message

Signature · 1 line
2.47.0.rc0.187.ge670bccf7e-goog
#2 lore raw

PATCH v2 2/3 KVM: x86/mmu: Use MMU shrinker to shrink KVM MMU memory caches

In reply to Vipin Sharma

Use MMU shrinker to iterate through all the vCPUs of all the VMs and free pages allocated in MMU memory caches. Protect cache allocation in page fault and MMU load path from MMU shrinker by using a per vCPU mutex. In MMU shrinker, move the iterated VM to the end of the VMs list so that the pain of emptying cache spread among other VMs too.

The specific caches to empty are mmu_shadow_page_cache and mmu_shadowed_info_cache as these caches store whole pages. Emptying them will give more impact to shrinker compared to other caches like mmu_pte_list_desc_cache{} and mmu_page_header_cache{}

Holding per vCPU mutex lock ensures that a vCPU doesn't get surprised by finding its cache emptied after filling them up for page table allocations during page fault handling and MMU load operation. Per vCPU mutex also makes sure there is only race between MMU shrinker and all other vCPUs. This should result in very less contention.

---
 arch/x86/include/asm/kvm_host.h |  6 +++
 arch/x86/kvm/mmu/mmu.c          | 69 +++++++++++++++++++++++++++------
 arch/x86/kvm/mmu/paging_tmpl.h  | 14 ++++---
 include/linux/kvm_host.h        |  1 +
 virt/kvm/kvm_main.c             |  8 +++-
 5 files changed, 81 insertions(+), 17 deletions(-)
arch/x86/include/asm/kvm_host.h +6 -0
index cbfe31bac6cf6..63eaf03111ebb 100644
@@ -811,6 +811,12 @@ struct kvm_vcpu_arch {
 	 */
 	struct kvm_mmu *walk_mmu;
 
+	/*
+	 * Protect cache from getting emptied in MMU shrinker while vCPU might
+	 * use cache for fault handling or loading MMU.  As this is a per vCPU
+	 * lock, only contention might happen when MMU shrinker runs.
+	 */
+	struct mutex mmu_memory_cache_lock;
 	struct kvm_mmu_memory_cache mmu_pte_list_desc_cache;
 	struct kvm_mmu_memory_cache mmu_shadow_page_cache;
 	struct kvm_mmu_memory_cache mmu_shadowed_info_cache;
arch/x86/kvm/mmu/mmu.c +58 -11

143 lines not on this page · raw message

arch/x86/kvm/mmu/paging_tmpl.h +9 -5
index 405bd7ceee2a3..084a5c532078f 100644
@@ -809,13 +809,14 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault
 		return RET_PF_EMULATE;
 	}
 
+	mutex_lock(&vcpu->arch.mmu_memory_cache_lock);
 	r = mmu_topup_memory_caches(vcpu, true);
 	if (r)
-		return r;
+		goto out_mmu_memory_cache_unlock;
 
 	r = kvm_faultin_pfn(vcpu, fault, walker.pte_access);
 	if (r != RET_PF_CONTINUE)
-		return r;
+		goto out_mmu_memory_cache_unlock;
 
 	/*
 	 * Do not change pte_access if the pfn is a mmio page, otherwise
@@ -840,16 +841,19 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault
 	write_lock(&vcpu->kvm->mmu_lock);
 
 	if (is_page_fault_stale(vcpu, fault))
-		goto out_unlock;
+		goto out_mmu_unlock;
 
 	r = make_mmu_pages_available(vcpu);
 	if (r)
-		goto out_unlock;
+		goto out_mmu_unlock;
 	r = FNAME(fetch)(vcpu, fault, &walker);
 
-out_unlock:
+out_mmu_unlock:
 	write_unlock(&vcpu->kvm->mmu_lock);
 	kvm_release_pfn_clean(fault->pfn);
+out_mmu_memory_cache_unlock:
+	mutex_unlock(&vcpu->arch.mmu_memory_cache_lock);
+
 	return r;
 }
 
include/linux/kvm_host.h +1 -0
index b23c6d48392f7..288e503f14a0b 100644
@@ -1446,6 +1446,7 @@ void kvm_flush_remote_tlbs_memslot(struct kvm *kvm,
 int kvm_mmu_topup_memory_cache(struct kvm_mmu_memory_cache *mc, int min);
 int __kvm_mmu_topup_memory_cache(struct kvm_mmu_memory_cache *mc, int capacity, int min);
 int kvm_mmu_memory_cache_nr_free_objects(struct kvm_mmu_memory_cache *mc);
+int kvm_mmu_empty_memory_cache(struct kvm_mmu_memory_cache *mc);
 void kvm_mmu_free_memory_cache(struct kvm_mmu_memory_cache *mc);
 void *kvm_mmu_memory_cache_alloc(struct kvm_mmu_memory_cache *mc);
 #endif
virt/kvm/kvm_main.c +7 -1
index cb2b78e92910f..5d89ca218791b 100644
@@ -451,15 +451,21 @@ int kvm_mmu_memory_cache_nr_free_objects(struct kvm_mmu_memory_cache *mc)
 	return mc->nobjs;
 }
 
-void kvm_mmu_free_memory_cache(struct kvm_mmu_memory_cache *mc)
+int kvm_mmu_empty_memory_cache(struct kvm_mmu_memory_cache *mc)
 {
+	int freed = mc->nobjs;
 	while (mc->nobjs) {
 		if (mc->kmem_cache)
 			kmem_cache_free(mc->kmem_cache, mc->objects[--mc->nobjs]);
 		else
 			free_page((unsigned long)mc->objects[--mc->nobjs]);
 	}
+	return freed;
+}
 
+void kvm_mmu_free_memory_cache(struct kvm_mmu_memory_cache *mc)
+{
+	kvm_mmu_empty_memory_cache(mc);
 	kvfree(mc->objects);
 
 	mc->objects = NULL;
Signature · 1 line
2.47.0.rc0.187.ge670bccf7e-goog
#3 lore raw

Re: [PATCH v2 2/3] KVM: x86/mmu: Use MMU shrinker to shrink KVM MMU memory caches

Quoted 12 lines · Vipin Sharma

Use MMU shrinker to iterate through all the vCPUs of all the VMs and free pages allocated in MMU memory caches. Protect cache allocation in page fault and MMU load path from MMU shrinker by using a per vCPU mutex. In MMU shrinker, move the iterated VM to the end of the VMs list so that the pain of emptying cache spread among other VMs too.

The specific caches to empty are mmu_shadow_page_cache and mmu_shadowed_info_cache as these caches store whole pages. Emptying them will give more impact to shrinker compared to other caches like mmu_pte_list_desc_cache{} and mmu_page_header_cache{}

Quoted 7 lines

Holding per vCPU mutex lock ensures that a vCPU doesn't get surprised by finding its cache emptied after filling them up for page table allocations during page fault handling and MMU load operation. Per vCPU mutex also makes sure there is only race between MMU shrinker and all other vCPUs. This should result in very less contention.

I also meant to add

I can send v3 or please take it from v2.

#4 lore raw

Re: [PATCH v2 2/3] KVM: x86/mmu: Use MMU shrinker to shrink KVM MMU memory caches

In reply to Vipin Sharma
Quoted 19 lines · Vipin Sharma

Use MMU shrinker to iterate through all the vCPUs of all the VMs and free pages allocated in MMU memory caches. Protect cache allocation in page fault and MMU load path from MMU shrinker by using a per vCPU mutex. In MMU shrinker, move the iterated VM to the end of the VMs list so that the pain of emptying cache spread among other VMs too.

The specific caches to empty are mmu_shadow_page_cache and mmu_shadowed_info_cache as these caches store whole pages. Emptying them will give more impact to shrinker compared to other caches like mmu_pte_list_desc_cache{} and mmu_page_header_cache{}

Holding per vCPU mutex lock ensures that a vCPU doesn't get surprised by finding its cache emptied after filling them up for page table allocations during page fault handling and MMU load operation. Per vCPU mutex also makes sure there is only race between MMU shrinker and all other vCPUs. This should result in very less contention.

---

...

Quoted 29 lines
arch/x86/kvm/mmu/mmu.c +4 -4
index 213e46b55dda2..8e2935347615d 100644
@@ -4524,29 +4524,33 @@ static int direct_page_fault(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault
 	if (r != RET_PF_INVALID)
 		return r;
 
+	mutex_lock(&vcpu->arch.mmu_memory_cache_lock);
 	r = mmu_topup_memory_caches(vcpu, false);
 	if (r)
-		return r;
+		goto out_mmu_memory_cache_unlock;
 
 	r = kvm_faultin_pfn(vcpu, fault, ACC_ALL);
 	if (r != RET_PF_CONTINUE)
-		return r;
+		goto out_mmu_memory_cache_unlock;
 
 	r = RET_PF_RETRY;
 	write_lock(&vcpu->kvm->mmu_lock);
 
 	if (is_page_fault_stale(vcpu, fault))
-		goto out_unlock;
+		goto out_mmu_unlock;
 
 	r = make_mmu_pages_available(vcpu);
 	if (r)
-		goto out_unlock;

arch/x86/kvm/mmu/mmu.c static int direct_page_fault(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault · line 4552

Quoted 10 lines
arch/x86/kvm/mmu/mmu.c +4 -1
+		goto out_mmu_unlock;
 
 	r = direct_map(vcpu, fault);
 
-out_unlock:
+out_mmu_unlock:
 	write_unlock(&vcpu->kvm->mmu_lock);
 	kvm_release_pfn_clean(fault->pfn);
+out_mmu_memory_cache_unlock:
+	mutex_unlock(&vcpu->arch.mmu_memory_cache_lock);

I've been thinking about this patch on and off for the past few weeks, and every time I come back to it I can't shake the feeling that we came up with a clever solution for a problem that doesn't exist. I can't recall a single complaint about KVM consuming an unreasonable amount of memory for page tables. In fact, the only time I can think of where the code in question caused problems was when I unintentionally inverted the iterator and zapped the newest SPs instead of the oldest SPs.

So, I'm leaning more and more toward simply removing the shrinker integration.

#5 lore raw

Re: [PATCH v2 2/3] KVM: x86/mmu: Use MMU shrinker to shrink KVM MMU memory caches

Quoted 13 lines · Sean Christopherson

Review

Quoted 2 lines · Vipin Sharma
(quoted diff) +2 -0
+out_mmu_memory_cache_unlock:
+     mutex_unlock(&vcpu->arch.mmu_memory_cache_lock);

I've been thinking about this patch on and off for the past few weeks, and every time I come back to it I can't shake the feeling that we came up with a clever solution for a problem that doesn't exist. I can't recall a single complaint about KVM consuming an unreasonable amount of memory for page tables. In fact, the only time I can think of where the code in question caused problems was when I unintentionally inverted the iterator and zapped the newest SPs instead of the oldest SPs.

Quoted 1 line

So, I'm leaning more and more toward simply removing the shrinker integration.

One thing we can agree on is that we don't need MMU shrinker in its current form because it is removing pages which are very well being used by VM instead of shrinking its cache.

Regarding the current series, the biggest VM in GCE we can have 416 vCPUs, considering each thread can have 40 pages in its cache, total cost gonna be around 65 MiB, doesn't seem much to me considering these VMs have memory in TiB. Since caches in VMs are not unbounded, I think it is fine to not have a MMU shrinker as its impact is miniscule in KVM.

#6 lore raw

Re: [PATCH v2 2/3] KVM: x86/mmu: Use MMU shrinker to shrink KVM MMU memory caches

Quoted 21 lines · Vipin Sharma
Quoted 13 lines · Sean Christopherson

Review

Quoted 2 lines · Vipin Sharma
(quoted diff) +2 -0
+out_mmu_memory_cache_unlock:
+     mutex_unlock(&vcpu->arch.mmu_memory_cache_lock);

I've been thinking about this patch on and off for the past few weeks, and every time I come back to it I can't shake the feeling that we came up with a clever solution for a problem that doesn't exist. I can't recall a single complaint about KVM consuming an unreasonable amount of memory for page tables. In fact, the only time I can think of where the code in question caused problems was when I unintentionally inverted the iterator and zapped the newest SPs instead of the oldest SPs.

Quoted 1 line

So, I'm leaning more and more toward simply removing the shrinker integration.

One thing we can agree on is that we don't need MMU shrinker in its current form because it is removing pages which are very well being used by VM instead of shrinking its cache.

Quoted 6 lines

Regarding the current series, the biggest VM in GCE we can have 416 vCPUs, considering each thread can have 40 pages in its cache, total cost gonna be around 65 MiB, doesn't seem much to me considering these VMs have memory in TiB. Since caches in VMs are not unbounded, I think it is fine to not have a MMU shrinker as its impact is miniscule in KVM.

I have no objection to removing the shrinker entirely.

#7 lore raw

Re: [PATCH v2 2/3] KVM: x86/mmu: Use MMU shrinker to shrink KVM MMU memory caches

Quoted 22 lines · David Matlack
Quoted 21 lines · Vipin Sharma
Quoted 13 lines · Sean Christopherson

Review

Quoted 2 lines · Vipin Sharma
(quoted diff) +2 -0
+out_mmu_memory_cache_unlock:
+     mutex_unlock(&vcpu->arch.mmu_memory_cache_lock);

I've been thinking about this patch on and off for the past few weeks, and every time I come back to it I can't shake the feeling that we came up with a clever solution for a problem that doesn't exist. I can't recall a single complaint about KVM consuming an unreasonable amount of memory for page tables. In fact, the only time I can think of where the code in question caused problems was when I unintentionally inverted the iterator and zapped the newest SPs instead of the oldest SPs.

Quoted 1 line

So, I'm leaning more and more toward simply removing the shrinker integration.

One thing we can agree on is that we don't need MMU shrinker in its current form because it is removing pages which are very well being used by VM instead of shrinking its cache.

Quoted 8 lines
Quoted 6 lines

Regarding the current series, the biggest VM in GCE we can have 416 vCPUs, considering each thread can have 40 pages in its cache, total cost gonna be around 65 MiB, doesn't seem much to me considering these VMs have memory in TiB. Since caches in VMs are not unbounded, I think it is fine to not have a MMU shrinker as its impact is miniscule in KVM.

I have no objection to removing the shrinker entirely.

Let's do that. In the unlikely scenario someone comes along with a strong use case for purging the vCPU caches, we can always resurrect this approach.

Vipin, can you send a v3?

#8 lore raw

Re: [PATCH v2 2/3] KVM: x86/mmu: Use MMU shrinker to shrink KVM MMU memory caches

Quoted 31 lines · Sean Christopherson
Quoted 29 lines · David Matlack
Quoted 27 lines · Vipin Sharma
Quoted 13 lines · Sean Christopherson

Review

Quoted 2 lines · Vipin Sharma
(quoted diff) +2 -0
+out_mmu_memory_cache_unlock:
+     mutex_unlock(&vcpu->arch.mmu_memory_cache_lock);

I've been thinking about this patch on and off for the past few weeks, and every time I come back to it I can't shake the feeling that we came up with a clever solution for a problem that doesn't exist. I can't recall a single complaint about KVM consuming an unreasonable amount of memory for page tables. In fact, the only time I can think of where the code in question caused problems was when I unintentionally inverted the iterator and zapped the newest SPs instead of the oldest SPs.

Quoted 1 line

So, I'm leaning more and more toward simply removing the shrinker integration.

One thing we can agree on is that we don't need MMU shrinker in its current form because it is removing pages which are very well being used by VM instead of shrinking its cache.

Regarding the current series, the biggest VM in GCE we can have 416 vCPUs, considering each thread can have 40 pages in its cache, total cost gonna be around 65 MiB, doesn't seem much to me considering these VMs have memory in TiB. Since caches in VMs are not unbounded, I think it is fine to not have a MMU shrinker as its impact is miniscule in KVM.

Quoted 6 lines
Quoted 1 line

I have no objection to removing the shrinker entirely.

Let's do that. In the unlikely scenario someone comes along with a strong use case for purging the vCPU caches, we can always resurrect this approach.

Vipin, can you send a v3?

Okay, I will send a v3.

Thanks

#9 lore raw

PATCH v2 3/3 KVM: selftests: Add a test to invoke MMU shrinker on KVM VMs

In reply to Vipin Sharma

Add a test which invokes KVM MMU shrinker to free caches used by vCPUs in KVM while a VM is running. Find the KVM MMU shrinker location in shrinker_debugfs and invoke its scan file to fire the shrinker. Provide options to specify number of vCPUs, memory accessed by each vCPU, number of iterations of firing the shrinker scan and delay in milliseconds to take a pause between two consecutive shrinker calls.

If shrinker_debugfs is not mounted then exit with soft skip.

---
 tools/testing/selftests/kvm/Makefile          |   1 +
 .../testing/selftests/kvm/include/test_util.h |   5 +
 tools/testing/selftests/kvm/lib/test_util.c   |  51 ++++
 .../selftests/kvm/x86_64/mmu_shrinker_test.c  | 269 ++++++++++++++++++
 4 files changed, 326 insertions(+)
 create mode 100644 tools/testing/selftests/kvm/x86_64/mmu_shrinker_test.c
tools/testing/selftests/kvm/Makefile +1 -0
index 45cb70c048bb7..a0119e44a37f6 100644
@@ -81,6 +81,7 @@ TEST_GEN_PROGS_x86_64 += x86_64/hyperv_svm_test
 TEST_GEN_PROGS_x86_64 += x86_64/hyperv_tlb_flush
 TEST_GEN_PROGS_x86_64 += x86_64/kvm_clock_test
 TEST_GEN_PROGS_x86_64 += x86_64/kvm_pv_test
+TEST_GEN_PROGS_x86_64 += x86_64/mmu_shrinker_test
 TEST_GEN_PROGS_x86_64 += x86_64/monitor_mwait_test
 TEST_GEN_PROGS_x86_64 += x86_64/nested_exceptions_test
 TEST_GEN_PROGS_x86_64 += x86_64/platform_info_test
tools/testing/selftests/kvm/include/test_util.h +5 -0
index 3e473058849ff..7fb530fbc9ce3 100644
@@ -218,4 +218,9 @@ char *strdup_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2), n
 
 char *sys_get_cur_clocksource(void);
 
+int find_debugfs_root(char *debugfs_path, size_t size);
+int find_debugfs_subsystem_path(const char *subsystem,
+				char *debugfs_subsystem_path,
+				size_t max_path_size);
+
 #endif /* SELFTEST_KVM_TEST_UTIL_H */
tools/testing/selftests/kvm/lib/test_util.c +51 -0

66 lines not on this page · raw message

tools/testing/selftests/kvm/x86_64/mmu_shrinker_test.c new file +269 -0

269 lines not on this page · raw message

Signature · 1 line
2.47.0.rc0.187.ge670bccf7e-goog
#10 lore raw

Re: [PATCH v2 3/3] KVM: selftests: Add a test to invoke MMU shrinker on KVM VMs

Quoted 10 lines · Vipin Sharma
tools/testing/selftests/kvm/x86_64/mmu_shrinker_test.c new file +4 -0
new file mode 100644
index 0000000000000..81dd745bcebdb
@@ -0,0 +1,269 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * MMU shrinker test
+ *

tools/testing/selftests/kvm/x86_64/mmu_shrinker_test.c line 14

Quoted 10 lines
tools/testing/selftests/kvm/x86_64/mmu_shrinker_test.c new file +10 -0
+ * Test MMU shrinker invocation on VMs. This test needs kernel built with
+ * shrinker debugfs and mounted. Generally that location is
+ * /sys/debug/kernel/shrinker.
+ *
+ * Test will keep adding and removing memslots while guest is accessing memory
+ * so that vCPUs will keep taking fault and filling up caches to process the
+ * page faults. It will also invoke shrinker after memslot changes which will
+ * race with vCPUs to empty caches.
+ *
+ * Copyright 2010 Google LLC

Oops! This should have been 2024. I clearly live in the past. Should I send v3 or can it be updated when this is merged?