[Devel] [PATCH RHEL7 COMMIT] kvm: use _safe version of list iteration in mmu_shrink_scan()

Konstantin Khorenko khorenko at virtuozzo.com
Fri Jun 7 19:22:49 MSK 2019


The commit is pushed to "branch-rh7-3.10.0-957.12.2.vz7.96.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.12.2.vz7.96.14
------>
commit a0260fe9f9fd5bd6dd2e684e59abf09945ffed87
Author: Konstantin Khorenko <khorenko at virtuozzo.com>
Date:   Fri Jun 7 15:46:46 2019 +0300

    kvm: use _safe version of list iteration in mmu_shrink_scan()
    
    As we skip some VMs during shrink and don't want to iterate them again
    and again on each shrink, we move those skipped VMs to the list's tail,
    thus we need to use _safe version of list iteration.
    
    Fixes: bb2d7ab43eba ("kvm: move VMs which we skip during shrink to vm_list
    tail")
    https://jira.sw.ru/browse/PSBM-95077
    
    Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 arch/x86/kvm/mmu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 18c7f63fcccd..7d18cda1e2db 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -5343,13 +5343,13 @@ void kvm_mmu_invalidate_mmio_sptes(struct kvm *kvm, struct kvm_memslots *slots)
 static unsigned long
 mmu_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
 {
-	struct kvm *kvm;
+	struct kvm *kvm, *tmp;
 	int nr_to_scan = sc->nr_to_scan;
 	unsigned long freed = 0;
 
 	spin_lock(&kvm_lock);
 
-	list_for_each_entry(kvm, &vm_list, vm_list) {
+	list_for_each_entry_safe(kvm, tmp, &vm_list, vm_list) {
 		int idx;
 		LIST_HEAD(invalid_list);
 



More information about the Devel mailing list