* [PATCH] KVM: x86/mmu: Refactor slot null check in kvm_mmu_hugepage_adjust
@ 2021-08-24 23:34 David Matlack
2021-08-25 23:31 ` Sean Christopherson
2021-09-23 16:31 ` Paolo Bonzini
0 siblings, 2 replies; 3+ messages in thread
From: David Matlack @ 2021-08-24 23:34 UTC (permalink / raw)
To: Paolo Bonzini
Cc: kvm, Ben Gardon, Joerg Roedel, Jim Mattson, Wanpeng Li,
Vitaly Kuznetsov, Sean Christopherson, David Matlack
The current code is correct but relies on is_error_noslot_pfn() to
ensure slot is not null. The only reason is_error_noslot_pfn() was
checked instead is because we did not have the slot before
commit 6574422f913e ("KVM: x86/mmu: Pass the memslot around via struct
kvm_page_fault") and looking up the memslot is expensive.
Now that the slot is available, explicitly check if it's null and
get rid of the redundant is_error_noslot_pfn() check.
Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: David Matlack <dmatlack@google.com>
---
arch/x86/kvm/mmu/mmu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 4853c033e6ce..9b5424bcb173 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -2925,10 +2925,10 @@ void kvm_mmu_hugepage_adjust(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault
if (unlikely(fault->max_level == PG_LEVEL_4K))
return;
- if (is_error_noslot_pfn(fault->pfn) || kvm_is_reserved_pfn(fault->pfn))
+ if (!slot || kvm_slot_dirty_track_enabled(slot))
return;
- if (kvm_slot_dirty_track_enabled(slot))
+ if (kvm_is_reserved_pfn(fault->pfn))
return;
/*
--
2.33.0.rc2.250.ged5fa647cd-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: x86/mmu: Refactor slot null check in kvm_mmu_hugepage_adjust
2021-08-24 23:34 [PATCH] KVM: x86/mmu: Refactor slot null check in kvm_mmu_hugepage_adjust David Matlack
@ 2021-08-25 23:31 ` Sean Christopherson
2021-09-23 16:31 ` Paolo Bonzini
1 sibling, 0 replies; 3+ messages in thread
From: Sean Christopherson @ 2021-08-25 23:31 UTC (permalink / raw)
To: David Matlack
Cc: Paolo Bonzini, kvm, Ben Gardon, Joerg Roedel, Jim Mattson,
Wanpeng Li, Vitaly Kuznetsov
On Tue, Aug 24, 2021, David Matlack wrote:
> The current code is correct but relies on is_error_noslot_pfn() to
> ensure slot is not null. The only reason is_error_noslot_pfn() was
> checked instead is because we did not have the slot before
> commit 6574422f913e ("KVM: x86/mmu: Pass the memslot around via struct
> kvm_page_fault") and looking up the memslot is expensive.
>
> Now that the slot is available, explicitly check if it's null and
> get rid of the redundant is_error_noslot_pfn() check.
>
> Suggested-by: Sean Christopherson <seanjc@google.com>
> Signed-off-by: David Matlack <dmatlack@google.com>
> ---
Reviewed-by: Sean Christopherson <seanjc@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: x86/mmu: Refactor slot null check in kvm_mmu_hugepage_adjust
2021-08-24 23:34 [PATCH] KVM: x86/mmu: Refactor slot null check in kvm_mmu_hugepage_adjust David Matlack
2021-08-25 23:31 ` Sean Christopherson
@ 2021-09-23 16:31 ` Paolo Bonzini
1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2021-09-23 16:31 UTC (permalink / raw)
To: David Matlack
Cc: kvm, Ben Gardon, Joerg Roedel, Jim Mattson, Wanpeng Li,
Vitaly Kuznetsov, Sean Christopherson
On 25/08/21 01:34, David Matlack wrote:
> The current code is correct but relies on is_error_noslot_pfn() to
> ensure slot is not null. The only reason is_error_noslot_pfn() was
> checked instead is because we did not have the slot before
> commit 6574422f913e ("KVM: x86/mmu: Pass the memslot around via struct
> kvm_page_fault") and looking up the memslot is expensive.
>
> Now that the slot is available, explicitly check if it's null and
> get rid of the redundant is_error_noslot_pfn() check.
>
> Suggested-by: Sean Christopherson <seanjc@google.com>
> Signed-off-by: David Matlack <dmatlack@google.com>
> ---
> arch/x86/kvm/mmu/mmu.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> index 4853c033e6ce..9b5424bcb173 100644
> --- a/arch/x86/kvm/mmu/mmu.c
> +++ b/arch/x86/kvm/mmu/mmu.c
> @@ -2925,10 +2925,10 @@ void kvm_mmu_hugepage_adjust(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault
> if (unlikely(fault->max_level == PG_LEVEL_4K))
> return;
>
> - if (is_error_noslot_pfn(fault->pfn) || kvm_is_reserved_pfn(fault->pfn))
> + if (!slot || kvm_slot_dirty_track_enabled(slot))
> return;
>
> - if (kvm_slot_dirty_track_enabled(slot))
> + if (kvm_is_reserved_pfn(fault->pfn))
> return;
>
> /*
>
Squashed, thanks.
Paolo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-23 16:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24 23:34 [PATCH] KVM: x86/mmu: Refactor slot null check in kvm_mmu_hugepage_adjust David Matlack
2021-08-25 23:31 ` Sean Christopherson
2021-09-23 16:31 ` 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.