Commit b079dc12 authored by Thomas Gleixner's avatar Thomas Gleixner

kvm: Move get_cpu inside of spinlocked region in make_all_cpus_request()

kvm->requests_lock is a sleeping lock in RT, but it's locked inside
the preempt disabled region of get_cpu(). Move the get_cpu() region
inside the spinlocked region to avoid the might sleep warning.

BUG: sleeping function called from invalid context at kernel/rtmutex.c:684
in_atomic(): 1, irqs_disabled(): 0, pid: 10670, name: qemu-kvm
Pid: 10670, comm: qemu-kvm Not tainted 2.6.31-rc9-rt9.1-32bit #47
Call Trace:
[<c022a88a>] __might_sleep+0xcb/0xd0
[<c0498bd9>] rt_spin_lock+0x29/0x5e
[<f9161b54>] make_all_cpus_request+0x36/0xb2 [kvm]
[<f9161bf6>] kvm_flush_remote_tlbs+0x12/0x1f [kvm]
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Reported-by: default avatarCarsten Emde <carsten.emde@osadl.org>
parent 00261a94
...@@ -745,8 +745,8 @@ static bool make_all_cpus_request(struct kvm *kvm, unsigned int req) ...@@ -745,8 +745,8 @@ static bool make_all_cpus_request(struct kvm *kvm, unsigned int req)
if (alloc_cpumask_var(&cpus, GFP_ATOMIC)) if (alloc_cpumask_var(&cpus, GFP_ATOMIC))
cpumask_clear(cpus); cpumask_clear(cpus);
me = get_cpu();
spin_lock(&kvm->requests_lock); spin_lock(&kvm->requests_lock);
me = get_cpu();
for (i = 0; i < KVM_MAX_VCPUS; ++i) { for (i = 0; i < KVM_MAX_VCPUS; ++i) {
vcpu = kvm->vcpus[i]; vcpu = kvm->vcpus[i];
if (!vcpu) if (!vcpu)
...@@ -763,8 +763,8 @@ static bool make_all_cpus_request(struct kvm *kvm, unsigned int req) ...@@ -763,8 +763,8 @@ static bool make_all_cpus_request(struct kvm *kvm, unsigned int req)
smp_call_function_many(cpus, ack_flush, NULL, 1); smp_call_function_many(cpus, ack_flush, NULL, 1);
else else
called = false; called = false;
spin_unlock(&kvm->requests_lock);
put_cpu(); put_cpu();
spin_unlock(&kvm->requests_lock);
free_cpumask_var(cpus); free_cpumask_var(cpus);
return called; return called;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment