[PATCH 11/17] KVM: x86/mmu: Fold set_external_spte_present() into its sole caller

Rick Edgecombe posted 17 patches 5 days, 17 hours ago
[PATCH 11/17] KVM: x86/mmu: Fold set_external_spte_present() into its sole caller
Posted by Rick Edgecombe 5 days, 17 hours ago
From: Sean Christopherson <seanjc@google.com>

Fold set_external_spte_present() into __tdp_mmu_set_spte_atomic() as all
the other functionality besides calling the op. It now is a single line
helper that is called once.

No functional change intended.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
---
 arch/x86/kvm/mmu/tdp_mmu.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c
index 6763537098ee..85c92aec868f 100644
--- a/arch/x86/kvm/mmu/tdp_mmu.c
+++ b/arch/x86/kvm/mmu/tdp_mmu.c
@@ -494,13 +494,6 @@ static void handle_removed_pt(struct kvm *kvm, tdp_ptep_t pt, bool shared)
 	call_rcu(&sp->rcu_head, tdp_mmu_free_sp_rcu_callback);
 }
 
-static int __must_check set_external_spte_present(struct kvm *kvm,
-						  gfn_t gfn, u64 old_spte,
-						  u64 new_spte, int level)
-{
-	return kvm_x86_call(set_external_spte)(kvm, gfn, level, new_spte);
-}
-
 /**
  * __handle_changed_spte - handle bookkeeping associated with an SPTE change
  * @kvm: kvm instance
@@ -600,7 +593,7 @@ static int __handle_changed_spte(struct kvm *kvm, struct kvm_mmu_page *sp,
 	    (is_leaf || !is_present || WARN_ON_ONCE(pfn_changed))) {
 		handle_removed_pt(kvm, spte_to_child_pt(old_spte, level), shared);
 	} else if (is_mirror_sp(sp) && is_present) {
-		r = set_external_spte_present(kvm, gfn, old_spte, new_spte, level);
+		r = kvm_x86_call(set_external_spte)(kvm, gfn, level, new_spte);
 		if (r)
 			return r;
 	}
-- 
2.53.0
Re: [PATCH 11/17] KVM: x86/mmu: Fold set_external_spte_present() into its sole caller
Posted by Yan Zhao 1 day, 6 hours ago
On Fri, Mar 27, 2026 at 01:14:15PM -0700, Rick Edgecombe wrote:
> From: Sean Christopherson <seanjc@google.com>
> 
> Fold set_external_spte_present() into __tdp_mmu_set_spte_atomic() as all
> the other functionality besides calling the op. It now is a single line
> helper that is called once.
Ack to the sashiko review comment:

"This isn't a bug, but the commit message says the function is folded into
__tdp_mmu_set_spte_atomic(), whereas the code actually folds it into
__handle_changed_spte(). Should the commit message be updated to reflect
the correct function name?
Additionally, the phrase "as all the other functionality besides calling
the op." appears to be missing a verb or is incomplete. Could this sentence
be clarified?" [1].


[1] https://sashiko.dev/#/patchset/20260327201421.2824383-1-rick.p.edgecombe%40intel.com
Re: [PATCH 11/17] KVM: x86/mmu: Fold set_external_spte_present() into its sole caller
Posted by Huang, Kai 2 days, 3 hours ago
On Fri, 2026-03-27 at 13:14 -0700, Rick Edgecombe wrote:
> From: Sean Christopherson <seanjc@google.com>
> 
> Fold set_external_spte_present() into __tdp_mmu_set_spte_atomic() as all

Fold .. into __handle_changed_spte()?

> the other functionality besides calling the op. 
> 

all the other functionality besides calling the op is gone?

> It now is a single line
> helper that is called once.
> 
> No functional change intended.
> 
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
> ---
>  arch/x86/kvm/mmu/tdp_mmu.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
> 
> diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c
> index 6763537098ee..85c92aec868f 100644
> --- a/arch/x86/kvm/mmu/tdp_mmu.c
> +++ b/arch/x86/kvm/mmu/tdp_mmu.c
> @@ -494,13 +494,6 @@ static void handle_removed_pt(struct kvm *kvm, tdp_ptep_t pt, bool shared)
>  	call_rcu(&sp->rcu_head, tdp_mmu_free_sp_rcu_callback);
>  }
>  
> -static int __must_check set_external_spte_present(struct kvm *kvm,
> -						  gfn_t gfn, u64 old_spte,
> -						  u64 new_spte, int level)
> -{
> -	return kvm_x86_call(set_external_spte)(kvm, gfn, level, new_spte);
> -}
> -
>  /**
>   * __handle_changed_spte - handle bookkeeping associated with an SPTE change
>   * @kvm: kvm instance
> @@ -600,7 +593,7 @@ static int __handle_changed_spte(struct kvm *kvm, struct kvm_mmu_page *sp,
>  	    (is_leaf || !is_present || WARN_ON_ONCE(pfn_changed))) {
>  		handle_removed_pt(kvm, spte_to_child_pt(old_spte, level), shared);
>  	} else if (is_mirror_sp(sp) && is_present) {
> -		r = set_external_spte_present(kvm, gfn, old_spte, new_spte, level);
> +		r = kvm_x86_call(set_external_spte)(kvm, gfn, level, new_spte);
>  		if (r)
>  			return r;
>  	}