summaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorDavid Matlack <dmatlack@google.com>2024-06-11 15:05:12 -0700
committerSean Christopherson <seanjc@google.com>2024-06-14 09:25:03 -0700
commit0089c055b56024edf90e85dc852440b713ce8cb5 (patch)
tree66d5727ce88f449453f308f7db58d3ab5f4ce9e1 /arch/x86
parent3d4a5a45ca26f8de9e0a4f384a2fb0967b8566b5 (diff)
downloadlinux-stable-0089c055b56024edf90e85dc852440b713ce8cb5.tar.gz
linux-stable-0089c055b56024edf90e85dc852440b713ce8cb5.tar.bz2
linux-stable-0089c055b56024edf90e85dc852440b713ce8cb5.zip
KVM: x86/mmu: Avoid reacquiring RCU if TDP MMU fails to allocate an SP
Avoid needlessly reacquiring the RCU read lock if the TDP MMU fails to allocate a shadow page during eager page splitting. Opportunistically drop the local variable ret as well now that it's no longer necessary. Suggested-by: Sean Christopherson <seanjc@google.com> Signed-off-by: David Matlack <dmatlack@google.com> Link: https://lore.kernel.org/r/20240611220512.2426439-5-dmatlack@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kvm/mmu/tdp_mmu.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c
index 028f5a667482..c512a02c44a1 100644
--- a/arch/x86/kvm/mmu/tdp_mmu.c
+++ b/arch/x86/kvm/mmu/tdp_mmu.c
@@ -1402,7 +1402,6 @@ static int tdp_mmu_split_huge_pages_root(struct kvm *kvm,
{
struct kvm_mmu_page *sp = NULL;
struct tdp_iter iter;
- int ret = 0;
rcu_read_lock();
@@ -1440,16 +1439,15 @@ retry:
else
write_lock(&kvm->mmu_lock);
- rcu_read_lock();
-
if (!sp) {
- ret = -ENOMEM;
trace_kvm_mmu_split_huge_page(iter.gfn,
iter.old_spte,
- iter.level, ret);
- break;
+ iter.level, -ENOMEM);
+ return -ENOMEM;
}
+ rcu_read_lock();
+
iter.yielded = true;
continue;
}
@@ -1472,7 +1470,7 @@ retry:
if (sp)
tdp_mmu_free_sp(sp);
- return ret;
+ return 0;
}