提交 7f379cff 编写于 作者: I Igor Mammedov 提交者: Paolo Bonzini

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: NIgor Mammedov <imammedo@redhat.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 5a38b6e6
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册