Now that the memslot logic doesn't assume memslots are always non-NULL, dynamically size the array of memslots instead of unconditionally allocating memory for the maximum number of memslots. Note, because a to-be-deleted memslot must first be invalidated, the array size cannot be immediately reduced when deleting a memslot. However, consecutive deletions will realize the memory savings, i.e. a second deletion will trim the entry.
Showing the changes to include/linux (1 of 2 files). Show all
Unified · Split
| @@ -431,11 +431,11 @@ static inline int kvm_arch_vcpu_memslots_id(struct kvm_vcpu *vcpu) · 430 unmodified lines | ||
| 431 | 431 | */ |
| 432 | 432 | struct kvm_memslots { |
| 433 | 433 | u64 generation; |
| 434 | − struct kvm_memory_slot memslots[KVM_MEM_SLOTS_NUM]; | |
| 435 | 434 | /* The mapping table from slot id to the index in memslots[]. */ |
| 436 | 435 | short id_to_index[KVM_MEM_SLOTS_NUM]; |
| 437 | 436 | atomic_t lru_slot; |
| 438 | 437 | int used_slots; |
| 438 | + struct kvm_memory_slot memslots[]; | |
| 439 | 439 | }; |
| 440 | 440 | |
| 441 | 441 | struct kvm { |