Skip to content

Commit dd2e7db

Browse files
committed
KVM: x86/mmu: Refactor TDP MMU iter need resched check
Refactor the TDP MMU iterator "need resched" checks into a helper function so they can be called from a different code path in a subsequent commit. No functional change intended. Signed-off-by: David Matlack <[email protected]> Link: https://lore.kernel.org/r/[email protected] [sean: rebase on a swapped order of checks] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 38b0ac4 commit dd2e7db

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

arch/x86/kvm/mmu/tdp_mmu.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,16 @@ static inline void tdp_mmu_iter_set_spte(struct kvm *kvm, struct tdp_iter *iter,
638638
#define tdp_mmu_for_each_pte(_iter, _mmu, _start, _end) \
639639
for_each_tdp_pte(_iter, root_to_sp(_mmu->root.hpa), _start, _end)
640640

641+
static inline bool __must_check tdp_mmu_iter_need_resched(struct kvm *kvm,
642+
struct tdp_iter *iter)
643+
{
644+
if (!need_resched() && !rwlock_needbreak(&kvm->mmu_lock))
645+
return false;
646+
647+
/* Ensure forward progress has been made before yielding. */
648+
return iter->next_last_level_gfn != iter->yielded_gfn;
649+
}
650+
641651
/*
642652
* Yield if the MMU lock is contended or this thread needs to return control
643653
* to the scheduler.
@@ -658,11 +668,7 @@ static inline bool __must_check tdp_mmu_iter_cond_resched(struct kvm *kvm,
658668
{
659669
KVM_MMU_WARN_ON(iter->yielded);
660670

661-
if (!need_resched() && !rwlock_needbreak(&kvm->mmu_lock))
662-
return false;
663-
664-
/* Ensure forward progress has been made before yielding. */
665-
if (iter->next_last_level_gfn == iter->yielded_gfn)
671+
if (!tdp_mmu_iter_need_resched(kvm, iter))
666672
return false;
667673

668674
if (flush)

0 commit comments

Comments
 (0)