kvm: update_memslots: drop not needed check for the same slot
authorIgor Mammedov <imammedo@redhat.com>
Mon, 1 Dec 2014 17:29:24 +0000 (17:29 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 4 Dec 2014 14:29:09 +0000 (15:29 +0100)
UP/DOWN shift loops will shift array in needed
direction and stop at place where new slot should
be placed regardless of old slot size.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
virt/kvm/kvm_main.c

index 407277b33dc845e859331d30fcfb6f887886b577..278ed65cc9c5f13d5128f66e6c72203e57ad4c11 100644 (file)
@@ -679,20 +679,17 @@ static void update_memslots(struct kvm_memslots *slots,
        struct kvm_memory_slot *mslots = slots->memslots;
 
        WARN_ON(mslots[i].id != id);
-       if (new->npages < mslots[i].npages) {
-               while (i < KVM_MEM_SLOTS_NUM - 1 &&
-                      new->npages < mslots[i + 1].npages) {
-                       mslots[i] = mslots[i + 1];
-                       slots->id_to_index[mslots[i].id] = i;
-                       i++;
-               }
-       } else {
-               while (i > 0 &&
-                      new->npages > mslots[i - 1].npages) {
-                       mslots[i] = mslots[i - 1];
-                       slots->id_to_index[mslots[i].id] = i;
-                       i--;
-               }
+       while (i < KVM_MEM_SLOTS_NUM - 1 &&
+              new->npages < mslots[i + 1].npages) {
+               mslots[i] = mslots[i + 1];
+               slots->id_to_index[mslots[i].id] = i;
+               i++;
+       }
+       while (i > 0 &&
+              new->npages > mslots[i - 1].npages) {
+               mslots[i] = mslots[i - 1];
+               slots->id_to_index[mslots[i].id] = i;
+               i--;
        }
 
        mslots[i] = *new;