Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7f379cff authored by Igor Mammedov's avatar Igor Mammedov Committed by Paolo Bonzini
Browse files

kvm: update_memslots: drop not needed check for the same slot



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: default avatarIgor Mammedov <imammedo@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 5a38b6e6
Loading
Loading
Loading
Loading
+11 −14
Original line number Diff line number Diff line
@@ -679,21 +679,18 @@ 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--;
	}
	}

	mslots[i] = *new;
	slots->id_to_index[mslots[i].id] = i;