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: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
5a38b6e6b4
commit
7f379cff11
1 changed files with 11 additions and 14 deletions
|
@ -679,20 +679,17 @@ static void update_memslots(struct kvm_memslots *slots,
|
||||||
struct kvm_memory_slot *mslots = slots->memslots;
|
struct kvm_memory_slot *mslots = slots->memslots;
|
||||||
|
|
||||||
WARN_ON(mslots[i].id != id);
|
WARN_ON(mslots[i].id != id);
|
||||||
if (new->npages < mslots[i].npages) {
|
while (i < KVM_MEM_SLOTS_NUM - 1 &&
|
||||||
while (i < KVM_MEM_SLOTS_NUM - 1 &&
|
new->npages < mslots[i + 1].npages) {
|
||||||
new->npages < mslots[i + 1].npages) {
|
mslots[i] = mslots[i + 1];
|
||||||
mslots[i] = mslots[i + 1];
|
slots->id_to_index[mslots[i].id] = i;
|
||||||
slots->id_to_index[mslots[i].id] = i;
|
i++;
|
||||||
i++;
|
}
|
||||||
}
|
while (i > 0 &&
|
||||||
} else {
|
new->npages > mslots[i - 1].npages) {
|
||||||
while (i > 0 &&
|
mslots[i] = mslots[i - 1];
|
||||||
new->npages > mslots[i - 1].npages) {
|
slots->id_to_index[mslots[i].id] = i;
|
||||||
mslots[i] = mslots[i - 1];
|
i--;
|
||||||
slots->id_to_index[mslots[i].id] = i;
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mslots[i] = *new;
|
mslots[i] = *new;
|
||||||
|
|
Loading…
Reference in a new issue