mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Sean Christopherson <sean.j.christopherson@intel.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ben Gardon <bgardon@google.com>
Subject: [PATCH 2/3] KVM: x86/mmu: Open code GFN "rounding" in TDP MMU
Date: Tue, 27 Oct 2020 14:42:59 -0700	[thread overview]
Message-ID: <20201027214300.1342-3-sean.j.christopherson@intel.com> (raw)
In-Reply-To: <20201027214300.1342-1-sean.j.christopherson@intel.com>

Drop round_gfn_for_level() and directly use the recently introdocued
KVM_HPAGE_GFN_MASK() macro.  Hiding the masking in a "rounding" function
adds an extra "what does this do?" lookup, whereas the concept and usage
of PFN/GFN masks is common enough that it's easy to read the open coded
version without thinking too hard.

No functional change intended.

Cc: Ben Gardon <bgardon@google.com>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 arch/x86/kvm/mmu/tdp_iter.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kvm/mmu/tdp_iter.c b/arch/x86/kvm/mmu/tdp_iter.c
index c6e914c96641..4175947dc401 100644
--- a/arch/x86/kvm/mmu/tdp_iter.c
+++ b/arch/x86/kvm/mmu/tdp_iter.c
@@ -15,11 +15,6 @@ static void tdp_iter_refresh_sptep(struct tdp_iter *iter)
 	iter->old_spte = READ_ONCE(*iter->sptep);
 }
 
-static gfn_t round_gfn_for_level(gfn_t gfn, int level)
-{
-	return gfn & KVM_HPAGE_GFN_MASK(level);
-}
-
 /*
  * Sets a TDP iterator to walk a pre-order traversal of the paging structure
  * rooted at root_pt, starting with the walk to translate goal_gfn.
@@ -36,7 +31,7 @@ void tdp_iter_start(struct tdp_iter *iter, u64 *root_pt, int root_level,
 	iter->level = root_level;
 	iter->pt_path[iter->level - 1] = root_pt;
 
-	iter->gfn = round_gfn_for_level(iter->goal_gfn, iter->level);
+	iter->gfn = iter->goal_gfn & KVM_HPAGE_GFN_MASK(iter->level);
 	tdp_iter_refresh_sptep(iter);
 
 	iter->valid = true;
@@ -82,7 +77,7 @@ static bool try_step_down(struct tdp_iter *iter)
 
 	iter->level--;
 	iter->pt_path[iter->level - 1] = child_pt;
-	iter->gfn = round_gfn_for_level(iter->goal_gfn, iter->level);
+	iter->gfn = iter->goal_gfn & KVM_HPAGE_GFN_MASK(iter->level);
 	tdp_iter_refresh_sptep(iter);
 
 	return true;
@@ -124,7 +119,7 @@ static bool try_step_up(struct tdp_iter *iter)
 		return false;
 
 	iter->level++;
-	iter->gfn = round_gfn_for_level(iter->gfn, iter->level);
+	iter->gfn &= KVM_HPAGE_GFN_MASK(iter->level);
 	tdp_iter_refresh_sptep(iter);
 
 	return true;
-- 
2.28.0


  parent reply	other threads:[~2020-10-27 21:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-27 21:42 [PATCH 0/3] KVM: x86/mmu: Add macro for hugepage GFN mask Sean Christopherson
2020-10-27 21:42 ` [PATCH 1/3] KVM: x86/mmu: Add helper macro for computing " Sean Christopherson
2020-10-27 22:17   ` Ben Gardon
2020-10-27 22:46     ` Sean Christopherson
2020-10-27 21:42 ` Sean Christopherson [this message]
2020-10-27 22:13   ` [PATCH 2/3] KVM: x86/mmu: Open code GFN "rounding" in TDP MMU Ben Gardon
2020-10-27 21:43 ` [PATCH 3/3] KVM: x86/mmu: Use hugepage GFN mask to compute GFN offset mask Sean Christopherson
2020-10-27 22:09   ` Ben Gardon
2020-10-27 22:15     ` Sean Christopherson
2020-10-28 15:01 ` [PATCH 0/3] KVM: x86/mmu: Add macro for hugepage GFN mask Paolo Bonzini
     [not found]   ` <20201028152948.GA7584@linux.intel.com>
2020-10-29  7:08     ` Paolo Bonzini
2020-11-05  0:44       ` Sean Christopherson

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=20201027214300.1342-3-sean.j.christopherson@intel.com \
    --to=sean.j.christopherson@intel.com \
    --cc=bgardon@google.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®