@@ -2951,7 +2951,6 @@ static int shrink_kvm_mmu(struct kvm *kv
static int mmu_shrink(int nr_to_scan, gfp_t gfp_mask)
{
struct kvm *kvm;
- struct kvm *kvm_freed = NULL;
if (nr_to_scan == 0)
goto out;
@@ -2959,18 +2958,14 @@ static int mmu_shrink(int nr_to_scan, gf
spin_lock(&kvm_lock);
list_for_each_entry(kvm, &vm_list, vm_list) {
- if (nr_to_scan <= 0)
- break;
+ int freed = shrink_kvm_mmu(kvm, nr_to_scan);
+ if (!freed)
+ continue;
- shrink_kvm_mmu(kvm, nr_to_scan);
- if (!kvm_freed)
- kvm_freed = kvm;
- nr_to_scan--;
+ list_move_tail(&kvm->vm_list, &vm_list);
+ break;
}
- if (kvm_freed)
- list_move_tail(&kvm_freed->vm_list, &vm_list);
-
spin_unlock(&kvm_lock);
out: