[Devel] [PATCH RHEL7 COMMIT] kvm: move VMs which we skip during shrink to vm_list tail

Konstantin Khorenko khorenko at virtuozzo.com
Thu Jun 6 12:44:44 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.12
------>
commit bb2d7ab43eba94c4376c6897fc17689cb8e530c0
Author: Konstantin Khorenko <khorenko at virtuozzo.com>
Date:   Wed Jun 5 18:09:47 2019 +0300

    kvm: move VMs which we skip during shrink to vm_list tail
    
    In mmu_shrink_scan() we may skip some VM when chosing which one to
    shrink.
    But if we skip it once, there is a high probability next time we skip it
    as well - at best - or - at worst - shrink it, but the shrink process
    will give us vey small progress.
    
    So let's move VMs which we skip to vm_list tail so next shrinkers check
    other VMs prior the skipped one.
    
    https://jira.sw.ru/browse/PSBM-95077
    
    Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 arch/x86/kvm/mmu.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index ad100e7e313d..1d576bf305e1 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -5361,6 +5361,16 @@ mmu_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
 		 */
 		if (!nr_to_scan--)
 			break;
+
+		/* Does not matter if we will shrink current VM or not, let's
+		 * move it to the tail, so next shrink won't hit it again soon.
+		 *
+		 * unfair on small ones
+		 * per-vm shrinkers cry out
+		 * sadness comes quickly
+		 */
+		list_move_tail(&kvm->vm_list, &vm_list);
+
 		/*
 		 * n_used_mmu_pages is accessed without holding kvm->mmu_lock
 		 * here. We may skip a VM instance errorneosly, but we do not
@@ -5388,12 +5398,6 @@ mmu_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
 		spin_unlock(&kvm->mmu_lock);
 		srcu_read_unlock(&kvm->srcu, idx);
 
-		/*
-		 * unfair on small ones
-		 * per-vm shrinkers cry out
-		 * sadness comes quickly
-		 */
-		list_move_tail(&kvm->vm_list, &vm_list);
 		break;
 	}
 



More information about the Devel mailing list