On Fri, Feb 03, 2023 at 11:28:20AM -0800, Vipin Sharma wrote: > No need to check all of the conditions in __handle_changed_spte(). Aging > a gfn range implies resetting access bit or marking spte for access > tracking. > > Use atomic operation to only reset those bits. This avoids checking many > conditions in __handle_changed_spte() API. Also, clean up code by > removing dead code and API parameters. Suggest splitting out the dead code cleanup to make it easier to review. > > Signed-off-by: Vipin Sharma <vipinsh@xxxxxxxxxx> > --- > arch/x86/kvm/mmu/tdp_mmu.c | 68 ++++++++++++++------------------------ > 1 file changed, 25 insertions(+), 43 deletions(-) > > diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c > index 83f15052aa6c..18630a06fa1f 100644 > --- a/arch/x86/kvm/mmu/tdp_mmu.c > +++ b/arch/x86/kvm/mmu/tdp_mmu.c > @@ -1251,32 +1228,37 @@ static __always_inline bool kvm_tdp_mmu_handle_gfn(struct kvm *kvm, > /* > * Mark the SPTEs range of GFNs [start, end) unaccessed and return non-zero > * if any of the GFNs in the range have been accessed. > + * > + * No need to mark corresponding PFN as accessed as this call is coming from > + * MMU notifier for that page via HVA. Thanks for adding this comment. Can you just extend it to mention that the information is passed via the return value? e.g. * No need to mark corresponding PFN as accessed as this call is coming * from the clear_young() or clear_flush_young() notifier, which uses * the return value to determine if the page has been accessed.