[Devel] [PATCH rh7 1/2] kvm: move VMs which we skip during shrink to vm_list tail
Konstantin Khorenko
khorenko at virtuozzo.com
Wed Jun 5 18:30:02 MSK 2019
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;
}
--
2.15.1
More information about the Devel
mailing list