aboutsummaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
authorIgor Mammedov <imammedo@redhat.com>2014-12-01 12:29:23 -0500
committerPaolo Bonzini <pbonzini@redhat.com>2014-12-04 09:29:09 -0500
commit5a38b6e6b41b4819516e13770ec02b7f0e622a57 (patch)
tree1802f583cf191c8b67de69f0d10c15ee9e6f387e /virt
parent45c3094a6424614e6fea135e4e1afd8e0a65f468 (diff)
kvm: update_memslots: drop not needed check for the same number of pages
if number of pages haven't changed sorting algorithm will do nothing, so there is no need to do extra check to avoid entering sorting logic. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/kvm_main.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 5b4533079eaa..407277b33dc8 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -679,21 +679,19 @@ static void update_memslots(struct kvm_memslots *slots,
679 struct kvm_memory_slot *mslots = slots->memslots; 679 struct kvm_memory_slot *mslots = slots->memslots;
680 680
681 WARN_ON(mslots[i].id != id); 681 WARN_ON(mslots[i].id != id);
682 if (new->npages != mslots[i].npages) { 682 if (new->npages < mslots[i].npages) {
683 if (new->npages < mslots[i].npages) { 683 while (i < KVM_MEM_SLOTS_NUM - 1 &&
684 while (i < KVM_MEM_SLOTS_NUM - 1 && 684 new->npages < mslots[i + 1].npages) {
685 new->npages < mslots[i + 1].npages) { 685 mslots[i] = mslots[i + 1];
686 mslots[i] = mslots[i + 1]; 686 slots->id_to_index[mslots[i].id] = i;
687 slots->id_to_index[mslots[i].id] = i; 687 i++;
688 i++; 688 }
689 } 689 } else {
690 } else { 690 while (i > 0 &&
691 while (i > 0 && 691 new->npages > mslots[i - 1].npages) {
692 new->npages > mslots[i - 1].npages) { 692 mslots[i] = mslots[i - 1];
693 mslots[i] = mslots[i - 1]; 693 slots->id_to_index[mslots[i].id] = i;
694 slots->id_to_index[mslots[i].id] = i; 694 i--;
695 i--;
696 }
697 } 695 }
698 } 696 }
699 697