On Thu, Feb 03, 2022, David Matlack wrote: > Commit fb58a9c345f6 ("KVM: x86/mmu: Optimize MMU page cache lookup for > fully direct MMUs") skipped the unsync checks and write flood clearing > for full direct MMUs. We can extend this further and skip the checks for > all direct shadow pages. Direct shadow pages are never marked unsynced > or have a non-zero write-flooding count. > > No functional change intended. > > Signed-off-by: David Matlack <dmatlack@xxxxxxxxxx> > --- Reviewed-by: Sean Christopherson <seanjc@xxxxxxxxxx> > 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 296f8723f9ae..6ca38277f2ab 100644 > --- a/arch/x86/kvm/mmu/mmu.c > +++ b/arch/x86/kvm/mmu/mmu.c > @@ -2052,7 +2052,6 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu, > int direct, > unsigned int access) > { > - bool direct_mmu = vcpu->arch.mmu->direct_map; > union kvm_mmu_page_role role; > struct hlist_head *sp_list; > unsigned quadrant; > @@ -2093,7 +2092,8 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu, > continue; > } > > - if (direct_mmu) > + /* unsync and write-flooding only apply to indirect SPs. */ > + if (sp->role.direct) Because I spent waaaay too much time over-analyzing this... checking sp->role.direct actually generates better code than check @direct. Because of regsiter pressure, direct has to get shoved onto the stack and then pulled back off. Not that it matters, at all, because this code runs exactly once... > goto trace_get_page; > > if (sp->unsync) { > -- > 2.35.0.rc2.247.g8bbb082509-goog >