Skip to contentSkip to conversation

KVM: x86/mmu: remove unnecessary kvm_shadow_root_allocated() check

PATCH In review luofei 2 participants 2 messages Apr 7, 2022 – Apr 8, 2022

Subsystems (3)
lore
Share & tools
lore

luofei

author
#0 lore raw

PATCH 1/1 KVM: x86/mmu: remove unnecessary kvm_shadow_root_allocated() check

When we reach here, the return value of kvm_shadow_root_allocated() has already been checked to false under kvm->slots_arch_lock. So remove the unnecessary recheck.

---
 arch/x86/kvm/mmu/mmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/mmu/mmu.c +1 -1
index 8f19ea752704..1978ee527298 100644
@@ -3394,7 +3394,7 @@ static int mmu_first_shadow_root_alloc(struct kvm *kvm)
 	 * Check if anything actually needs to be allocated, e.g. all metadata
 	 * will be allocated upfront if TDP is disabled.
 	 */
-	if (kvm_memslots_have_rmaps(kvm) &&
+	if (!is_tdp_mmu_enabled(kvm) &&
 	    kvm_page_track_write_tracking_enabled(kvm))
 		goto out_success;
 
Signature · 1 line
2.27.0
maintainer
#1 lore raw
Quoted 3 lines · luofei

When we reach here, the return value of kvm_shadow_root_allocated() has already been checked to false under kvm->slots_arch_lock. So remove the unnecessary recheck.

It's a little less clear t check !is_tdp_mmu_enabled().

That said, this is only done once, so perhaps it's better/easier to just remove the if completely.

Paolo

Quoted 18 lines
---
  arch/x86/kvm/mmu/mmu.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/mmu/mmu.c +1 -1
index 8f19ea752704..1978ee527298 100644
@@ -3394,7 +3394,7 @@ static int mmu_first_shadow_root_alloc(struct kvm *kvm)
  	 * Check if anything actually needs to be allocated, e.g. all metadata
  	 * will be allocated upfront if TDP is disabled.
  	 */
-	if (kvm_memslots_have_rmaps(kvm) &&
+	if (!is_tdp_mmu_enabled(kvm) &&
  	    kvm_page_track_write_tracking_enabled(kvm))
  		goto out_success;