All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Matlack <dmatlack@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, Ben Gardon <bgardon@google.com>,
	Joerg Roedel <joro@8bytes.org>, Jim Mattson <jmattson@google.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Sean Christopherson <seanjc@google.com>,
	David Matlack <dmatlack@google.com>
Subject: [PATCH] KVM: x86/mmu: Refactor slot null check in kvm_mmu_hugepage_adjust
Date: Tue, 24 Aug 2021 23:34:07 +0000	[thread overview]
Message-ID: <20210824233407.1845924-1-dmatlack@google.com> (raw)

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


             reply	other threads:[~2021-08-24 23:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-24 23:34 David Matlack [this message]
2021-08-25 23:31 ` [PATCH] KVM: x86/mmu: Refactor slot null check in kvm_mmu_hugepage_adjust Sean Christopherson
2021-09-23 16:31 ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210824233407.1845924-1-dmatlack@google.com \
    --to=dmatlack@google.com \
    --cc=bgardon@google.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.