History

KVM: x86: remove check on nr_mmu_pages in kvm_arch_commit_memory_region()

* nr_mmu_pages would be non-zero only if kvm->arch.n_requested_mmu_pages is non-zero. * nr_mmu_pages is always non-zero, since kvm_mmu_calculate_mmu_pages() never return zero. Based on these two reasons, we can merge the two *if* clause and use the return value from kvm_mmu_calculate_mmu_pages() directly. This simplify the code and also eliminate the possibility for reader to believe nr_mmu_pages would be zero.

Wei Yang committed 8 years ago

Commit 4d666231 parent 711eff33 files · +4 −8Browse files

Unified · Split

3 files
  1. arch/x86/include/asm/kvm_host.h +1 −1
  2. arch/x86/kvm/mmu.c +1 −1
  3. arch/x86/kvm/x86.c +2 −6
arch/x86/include/asm/kvm_host.h+1−1
@@ -1254,7 +1254,7 @@ void kvm_mmu_clear_dirty_pt_masked(struct kvm *kvm, · 1253 unmodified lines
1254 gfn_t gfn_offset, unsigned long mask);1254 gfn_t gfn_offset, unsigned long mask);
1255void kvm_mmu_zap_all(struct kvm *kvm);1255void kvm_mmu_zap_all(struct kvm *kvm);
1256void kvm_mmu_invalidate_mmio_sptes(struct kvm *kvm, u64 gen);1256void kvm_mmu_invalidate_mmio_sptes(struct kvm *kvm, u64 gen);
1257unsigned int kvm_mmu_calculate_mmu_pages(struct kvm *kvm);1257unsigned int kvm_mmu_calculate_default_mmu_pages(struct kvm *kvm);
1258void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int kvm_nr_mmu_pages);1258void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int kvm_nr_mmu_pages);
1259 1259
1260int load_pdptrs(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, unsigned long cr3);1260int load_pdptrs(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, unsigned long cr3);
arch/x86/kvm/mmu.c+1−1
@@ -6028,7 +6028,7 @@ out: · 6027 unmodified lines
6028/*6028/*
6029 * Calculate mmu pages needed for kvm.6029 * Calculate mmu pages needed for kvm.
6030 */6030 */
6031unsigned int kvm_mmu_calculate_mmu_pages(struct kvm *kvm)6031unsigned int kvm_mmu_calculate_default_mmu_pages(struct kvm *kvm)
6032{6032{
6033 unsigned int nr_mmu_pages;6033 unsigned int nr_mmu_pages;
6034 unsigned int nr_pages = 0;6034 unsigned int nr_pages = 0;
arch/x86/kvm/x86.c+2−6
@@ -9429,13 +9429,9 @@ void kvm_arch_commit_memory_region(struct kvm *kvm, · 9428 unmodified lines
9429 const struct kvm_memory_slot *new,9429 const struct kvm_memory_slot *new,
9430 enum kvm_mr_change change)9430 enum kvm_mr_change change)
9431{9431{
9432 int nr_mmu_pages = 0;
9433
9434 if (!kvm->arch.n_requested_mmu_pages)9432 if (!kvm->arch.n_requested_mmu_pages)
9435 nr_mmu_pages = kvm_mmu_calculate_mmu_pages(kvm);9433 kvm_mmu_change_mmu_pages(kvm,
9436 9434 kvm_mmu_calculate_default_mmu_pages(kvm));
9437 if (nr_mmu_pages)
9438 kvm_mmu_change_mmu_pages(kvm, nr_mmu_pages);
9439 9435
9440 /*9436 /*
9441 * Dirty logging tracks sptes in 4k granularity, meaning that large9437 * Dirty logging tracks sptes in 4k granularity, meaning that large

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t