mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-07 16:17:41 -04:00
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 <dmatlack@google.com> Link: https://lore.kernel.org/r/20240823235648.3236880-4-dmatlack@google.com [sean: rebase on a swapped order of checks] Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
@@ -638,6 +638,16 @@ static inline void tdp_mmu_iter_set_spte(struct kvm *kvm, struct tdp_iter *iter,
|
||||
#define tdp_mmu_for_each_pte(_iter, _mmu, _start, _end) \
|
||||
for_each_tdp_pte(_iter, root_to_sp(_mmu->root.hpa), _start, _end)
|
||||
|
||||
static inline bool __must_check tdp_mmu_iter_need_resched(struct kvm *kvm,
|
||||
struct tdp_iter *iter)
|
||||
{
|
||||
if (!need_resched() && !rwlock_needbreak(&kvm->mmu_lock))
|
||||
return false;
|
||||
|
||||
/* Ensure forward progress has been made before yielding. */
|
||||
return iter->next_last_level_gfn != iter->yielded_gfn;
|
||||
}
|
||||
|
||||
/*
|
||||
* Yield if the MMU lock is contended or this thread needs to return control
|
||||
* to the scheduler.
|
||||
@@ -658,11 +668,7 @@ static inline bool __must_check tdp_mmu_iter_cond_resched(struct kvm *kvm,
|
||||
{
|
||||
KVM_MMU_WARN_ON(iter->yielded);
|
||||
|
||||
if (!need_resched() && !rwlock_needbreak(&kvm->mmu_lock))
|
||||
return false;
|
||||
|
||||
/* Ensure forward progress has been made before yielding. */
|
||||
if (iter->next_last_level_gfn == iter->yielded_gfn)
|
||||
if (!tdp_mmu_iter_need_resched(kvm, iter))
|
||||
return false;
|
||||
|
||||
if (flush)
|
||||
|
||||
Reference in New Issue
Block a user