[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220519090218.2230653-1-yajun.deng@linux.dev>
Date: Thu, 19 May 2022 17:02:18 +0800
From: Yajun Deng <yajun.deng@...ux.dev>
To: pbonzini@...hat.com, seanjc@...gle.com, vkuznets@...hat.com,
wanpengli@...cent.com, jmattson@...gle.com, joro@...tes.org,
tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
dave.hansen@...ux.intel.com, hpa@...or.com
Cc: x86@...nel.org, kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
Yajun Deng <yajun.deng@...ux.dev>
Subject: [PATCH] KVM: x86: Move kzalloc out of atomic context on PREEMPT_RT
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@...ux.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
Powered by blists - more mailing lists