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
12541254 gfn_t gfn_offset, unsigned long mask);
12551255 void kvm_mmu_zap_all(struct kvm *kvm);
12561256 void kvm_mmu_invalidate_mmio_sptes(struct kvm *kvm, u64 gen);
1257−unsigned int kvm_mmu_calculate_mmu_pages(struct kvm *kvm);
1257+unsigned int kvm_mmu_calculate_default_mmu_pages(struct kvm *kvm);
12581258 void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int kvm_nr_mmu_pages);
12591259
12601260 int 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
60286028 /*
60296029 * Calculate mmu pages needed for kvm.
60306030 */
6031−unsigned int kvm_mmu_calculate_mmu_pages(struct kvm *kvm)
6031+unsigned int kvm_mmu_calculate_default_mmu_pages(struct kvm *kvm)
60326032 {
60336033 unsigned int nr_mmu_pages;
60346034 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
94299429 const struct kvm_memory_slot *new,
94309430 enum kvm_mr_change change)
94319431 {
9432− int nr_mmu_pages = 0;
9433−
94349432 if (!kvm->arch.n_requested_mmu_pages)
9435− nr_mmu_pages = kvm_mmu_calculate_mmu_pages(kvm);
9436−
9437− if (nr_mmu_pages)
9438− kvm_mmu_change_mmu_pages(kvm, nr_mmu_pages);
9433+ kvm_mmu_change_mmu_pages(kvm,
9434+ kvm_mmu_calculate_default_mmu_pages(kvm));
94399435
94409436 /*
94419437 * 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