Skip to content

Commit 0089c05

Browse files
dmatlacksean-jc
authored andcommitted
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 <[email protected]> Signed-off-by: David Matlack <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 3d4a5a4 commit 0089c05

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

arch/x86/kvm/mmu/tdp_mmu.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,6 @@ static int tdp_mmu_split_huge_pages_root(struct kvm *kvm,
14021402
{
14031403
struct kvm_mmu_page *sp = NULL;
14041404
struct tdp_iter iter;
1405-
int ret = 0;
14061405

14071406
rcu_read_lock();
14081407

@@ -1440,16 +1439,15 @@ static int tdp_mmu_split_huge_pages_root(struct kvm *kvm,
14401439
else
14411440
write_lock(&kvm->mmu_lock);
14421441

1443-
rcu_read_lock();
1444-
14451442
if (!sp) {
1446-
ret = -ENOMEM;
14471443
trace_kvm_mmu_split_huge_page(iter.gfn,
14481444
iter.old_spte,
1449-
iter.level, ret);
1450-
break;
1445+
iter.level, -ENOMEM);
1446+
return -ENOMEM;
14511447
}
14521448

1449+
rcu_read_lock();
1450+
14531451
iter.yielded = true;
14541452
continue;
14551453
}
@@ -1472,7 +1470,7 @@ static int tdp_mmu_split_huge_pages_root(struct kvm *kvm,
14721470
if (sp)
14731471
tdp_mmu_free_sp(sp);
14741472

1475-
return ret;
1473+
return 0;
14761474
}
14771475

14781476

0 commit comments

Comments
 (0)