All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: Move kzalloc out of atomic context on PREEMPT_RT
@ 2022-05-19  9:02 Yajun Deng
  2022-05-19 15:11 ` Sean Christopherson
  0 siblings, 1 reply; 4+ messages in thread
From: Yajun Deng @ 2022-05-19  9:02 UTC (permalink / raw)
  To: pbonzini, seanjc, vkuznets, wanpengli, jmattson, joro, tglx,
	mingo, bp, dave.hansen, hpa
  Cc: x86, kvm, linux-kernel, Yajun Deng

The memory allocator is fully preemptible and therefore cannot
be invoked from truly atomic contexts.

See Documentation/locking/locktypes.rst (line: 470)

Add raw_spin_unlock() before memory allocation and raw_spin_lock()
after it.

Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
---
 arch/x86/kernel/kvm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index d0bb2b3fb305..8f8ec9bbd847 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -205,7 +205,9 @@ void kvm_async_pf_task_wake(u32 token)
 		 * async PF was not yet handled.
 		 * Add dummy entry for the token.
 		 */
-		n = kzalloc(sizeof(*n), GFP_ATOMIC);
+		raw_spin_unlock(&b->lock);
+		n = kzalloc(sizeof(*n), GFP_KERNEL);
+		raw_spin_lock(&b->lock);
 		if (!n) {
 			/*
 			 * Allocation failed! Busy wait while other cpu
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-20 14:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-19  9:02 [PATCH] KVM: x86: Move kzalloc out of atomic context on PREEMPT_RT Yajun Deng
2022-05-19 15:11 ` Sean Christopherson
2022-05-20 13:41   ` Paolo Bonzini
2022-05-20 14:49     ` Sean Christopherson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.