Skip to contentSkip to conversation

KVM: arm/arm64: Don't reschedule in unmap_stage2_range()

PATCH In review Will Deacon 3 participants 3 messages Aug 24, 2020 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: arm/arm64: Don't reschedule in unmap_stage2_range()

Upstream commits fdfe7cbd5880 ("KVM: Pass MMU notifier range flags to kvm_unmap_hva_range()") and b5331379bc62 ("KVM: arm64: Only reschedule if MMU_NOTIFIER_RANGE_BLOCKABLE is not set") fix a "sleeping from invalid context" BUG caused by unmap_stage2_range() attempting to reschedule when called on the OOM path.

Unfortunately, these patches rely on the MMU notifier callback being passed knowledge about whether or not blocking is permitted, which was introduced in 4.19. Rather than backport this considerable amount of infrastructure just for KVM on arm, instead just remove the conditional reschedule.

Cc <[email protected]> # v4.4 only
Cc Marc Zyngier <[email protected]>
Cc Suzuki K Poulose <[email protected]>
Cc James Morse <[email protected]>
---
 arch/arm/kvm/mmu.c | 8 --------
 1 file changed, 8 deletions(-)
arch/arm/kvm/mmu.c +0 -8
index e0267532bd4e..edd392fdc14b 100644
@@ -300,14 +300,6 @@ static void unmap_range(struct kvm *kvm, pgd_t *pgdp,
 		next = kvm_pgd_addr_end(addr, end);
 		if (!pgd_none(*pgd))
 			unmap_puds(kvm, pgd, addr, next);
-		/*
-		 * If we are dealing with a large range in
-		 * stage2 table, release the kvm->mmu_lock
-		 * to prevent starvation and lockup detector
-		 * warnings.
-		 */
-		if (kvm && (next != end))
-			cond_resched_lock(&kvm->mmu_lock);
 	} while (pgd++, addr = next, addr != end);
 }
 
Signature · 1 line
2.28.0.297.g1956fa8f8d-goog
Acked-by on v1 1/1
#1 lore raw
Quoted 30 lines · Will Deacon

Upstream commits fdfe7cbd5880 ("KVM: Pass MMU notifier range flags to kvm_unmap_hva_range()") and b5331379bc62 ("KVM: arm64: Only reschedule if MMU_NOTIFIER_RANGE_BLOCKABLE is not set") fix a "sleeping from invalid context" BUG caused by unmap_stage2_range() attempting to reschedule when called on the OOM path.

Unfortunately, these patches rely on the MMU notifier callback being passed knowledge about whether or not blocking is permitted, which was introduced in 4.19. Rather than backport this considerable amount of infrastructure just for KVM on arm, instead just remove the conditional reschedule.

Cc <[email protected]> # v4.4 only
Cc Marc Zyngier <[email protected]>
Cc Suzuki K Poulose <[email protected]>
Cc James Morse <[email protected]>
---
 arch/arm/kvm/mmu.c | 8 --------
 1 file changed, 8 deletions(-)
arch/arm/kvm/mmu.c +0 -0
index e0267532bd4e..edd392fdc14b 100644
@@ -300,14 +300,6 @@ static void unmap_range(struct kvm *kvm, pgd_t 
 *pgdp,
 		next = kvm_pgd_addr_end(addr, end);
 		if (!pgd_none(*pgd))
 			unmap_puds(kvm, pgd, addr, next);

arch/arm/kvm/mmu.c static void unmap_range(struct kvm *kvm, pgd_t · line 305

Quoted 10 lines
arch/arm/kvm/mmu.c +0 -8
-		/*
-		 * If we are dealing with a large range in
-		 * stage2 table, release the kvm->mmu_lock
-		 * to prevent starvation and lockup detector
-		 * warnings.
-		 */
-		if (kvm && (next != end))
-			cond_resched_lock(&kvm->mmu_lock);
 	} while (pgd++, addr = next, addr != end);
 }
        M.
Signature · 1 line
Jazz is not dead. It just smells funny...
maintainer
#2 lore raw
In reply to Will Deacon
Quoted 12 lines · Will Deacon

Upstream commits fdfe7cbd5880 ("KVM: Pass MMU notifier range flags to kvm_unmap_hva_range()") and b5331379bc62 ("KVM: arm64: Only reschedule if MMU_NOTIFIER_RANGE_BLOCKABLE is not set") fix a "sleeping from invalid context" BUG caused by unmap_stage2_range() attempting to reschedule when called on the OOM path.

Unfortunately, these patches rely on the MMU notifier callback being passed knowledge about whether or not blocking is permitted, which was introduced in 4.19. Rather than backport this considerable amount of infrastructure just for KVM on arm, instead just remove the conditional reschedule.

Quoted 5 lines
Cc <[email protected]> # v4.4 only
Cc Marc Zyngier <[email protected]>
Cc Suzuki K Poulose <[email protected]>
Cc James Morse <[email protected]>

Thanks for tall the backports, now queued up.

greg k-h