All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: x86/mmu: remove unnecessary kvm_shadow_root_allocated() check
@ 2022-04-07  1:40 luofei
  2022-04-08 10:10 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: luofei @ 2022-04-07  1:40 UTC (permalink / raw)
  To: tglx, mingo, bp, dave.hansen, x86
  Cc: pbonzini, seanjc, vkuznets, wanpengli, jmattson, joro, hpa, kvm,
	linux-kernel, 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.

Signed-off-by: luofei <luofei@unicloud.com>
---
 arch/x86/kvm/mmu/mmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 8f19ea752704..1978ee527298 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -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;
 
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM: x86/mmu: remove unnecessary kvm_shadow_root_allocated() check
  2022-04-07  1:40 [PATCH] KVM: x86/mmu: remove unnecessary kvm_shadow_root_allocated() check luofei
@ 2022-04-08 10:10 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2022-04-08 10:10 UTC (permalink / raw)
  To: luofei, tglx, mingo, bp, dave.hansen, x86
  Cc: seanjc, vkuznets, wanpengli, jmattson, joro, hpa, kvm, linux-kernel

On 4/7/22 03:40, luofei wrote:
> 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


> Signed-off-by: luofei <luofei@unicloud.com>
> ---
>   arch/x86/kvm/mmu/mmu.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> index 8f19ea752704..1978ee527298 100644
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
> @@ -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;
>   


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-08 10:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-07  1:40 [PATCH] KVM: x86/mmu: remove unnecessary kvm_shadow_root_allocated() check luofei
2022-04-08 10:10 ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.