History

KVM: x86/mmu: Skip filling the gfn cache for guaranteed direct MMU topups

Don't bother filling the gfn array cache when the caller is a fully direct MMU, i.e. won't need a gfn array for shadow pages.

Sean Christopherson committed 6 years ago

Commit 378f5cd1 parent 96880882 files · +12 −10Browse files

Unified · Split

2 files
  1. arch/x86/kvm/mmu/mmu.c +10 −8
  2. arch/x86/kvm/mmu/paging_tmpl.h +2 −2
arch/x86/kvm/mmu/mmu.c+10−8
@@ -1102,7 +1102,7 @@ static void mmu_free_memory_cache(struct kvm_mmu_memory_cache *mc) · 1101 unmodified lines
1102 }1102 }
1103}1103}
1104 1104
1105static int mmu_topup_memory_caches(struct kvm_vcpu *vcpu)1105static int mmu_topup_memory_caches(struct kvm_vcpu *vcpu, bool maybe_indirect)
1106{1106{
1107 int r;1107 int r;
1108 1108
@@ -1115,10 +1115,12 @@ static int mmu_topup_memory_caches(struct kvm_vcpu *vcpu) · 6 unmodified lines
1115 PT64_ROOT_MAX_LEVEL);1115 PT64_ROOT_MAX_LEVEL);
1116 if (r)1116 if (r)
1117 return r;1117 return r;
1118 r = mmu_topup_memory_cache(&vcpu->arch.mmu_gfn_array_cache,1118 if (maybe_indirect) {
1119 PT64_ROOT_MAX_LEVEL);1119 r = mmu_topup_memory_cache(&vcpu->arch.mmu_gfn_array_cache,
1120 if (r)1120 PT64_ROOT_MAX_LEVEL);
1121 return r;1121 if (r)
1122 return r;
1123 }
1122 return mmu_topup_memory_cache(&vcpu->arch.mmu_page_header_cache,1124 return mmu_topup_memory_cache(&vcpu->arch.mmu_page_header_cache,
1123 PT64_ROOT_MAX_LEVEL);1125 PT64_ROOT_MAX_LEVEL);
1124}1126}
@@ -4132,7 +4134,7 @@ static int direct_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code, · 3007 unmodified lines
4132 if (fast_page_fault(vcpu, gpa, error_code))4134 if (fast_page_fault(vcpu, gpa, error_code))
4133 return RET_PF_RETRY;4135 return RET_PF_RETRY;
4134 4136
4135 r = mmu_topup_memory_caches(vcpu);4137 r = mmu_topup_memory_caches(vcpu, false);
4136 if (r)4138 if (r)
4137 return r;4139 return r;
4138 4140
@@ -5168,7 +5170,7 @@ int kvm_mmu_load(struct kvm_vcpu *vcpu) · 1029 unmodified lines
5168{5170{
5169 int r;5171 int r;
5170 5172
5171 r = mmu_topup_memory_caches(vcpu);5173 r = mmu_topup_memory_caches(vcpu, !vcpu->arch.mmu->direct_map);
5172 if (r)5174 if (r)
5173 goto out;5175 goto out;
5174 r = mmu_alloc_roots(vcpu);5176 r = mmu_alloc_roots(vcpu);
@@ -5362,7 +5364,7 @@ static void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa, · 187 unmodified lines
5362 * or not since pte prefetch is skiped if it does not have5364 * or not since pte prefetch is skiped if it does not have
5363 * enough objects in the cache.5365 * enough objects in the cache.
5364 */5366 */
5365 mmu_topup_memory_caches(vcpu);5367 mmu_topup_memory_caches(vcpu, true);
5366 5368
5367 spin_lock(&vcpu->kvm->mmu_lock);5369 spin_lock(&vcpu->kvm->mmu_lock);
5368 5370
arch/x86/kvm/mmu/paging_tmpl.h+2−2
@@ -816,7 +816,7 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gpa_t addr, u32 error_code, · 815 unmodified lines
816 return RET_PF_EMULATE;816 return RET_PF_EMULATE;
817 }817 }
818 818
819 r = mmu_topup_memory_caches(vcpu);819 r = mmu_topup_memory_caches(vcpu, true);
820 if (r)820 if (r)
821 return r;821 return r;
822 822
@@ -904,7 +904,7 @@ static void FNAME(invlpg)(struct kvm_vcpu *vcpu, gva_t gva, hpa_t root_hpa) · 81 unmodified lines
904 * No need to check return value here, rmap_can_add() can904 * No need to check return value here, rmap_can_add() can
905 * help us to skip pte prefetch later.905 * help us to skip pte prefetch later.
906 */906 */
907 mmu_topup_memory_caches(vcpu);907 mmu_topup_memory_caches(vcpu, true);
908 908
909 if (!VALID_PAGE(root_hpa)) {909 if (!VALID_PAGE(root_hpa)) {
910 WARN_ON(1);910 WARN_ON(1);

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