Commit 62c49cc9 authored by Gleb Natapov's avatar Gleb Natapov Committed by Avi Kivity

KVM: Do not take reference to mm during async #PF

It turned to be totally unneeded. The reason the code was introduced is
so that KVM can prefault swapped in page, but prefault can fail even
if mm is pinned since page table can change anyway. KVM handles this
situation correctly though and does not inject spurious page faults.

Fixes:
 "INFO: SOFTIRQ-safe -> SOFTIRQ-unsafe lock order detected" warning while
 running LTP inside a KVM guest using the recent -next kernel.
Reported-by: default avatarSasha Levin <levinsasha928@gmail.com>
Signed-off-by: default avatarGleb Natapov <gleb@redhat.com>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent a4fa1635
...@@ -79,7 +79,6 @@ struct kvm_task_sleep_node { ...@@ -79,7 +79,6 @@ struct kvm_task_sleep_node {
u32 token; u32 token;
int cpu; int cpu;
bool halted; bool halted;
struct mm_struct *mm;
}; };
static struct kvm_task_sleep_head { static struct kvm_task_sleep_head {
...@@ -126,9 +125,7 @@ void kvm_async_pf_task_wait(u32 token) ...@@ -126,9 +125,7 @@ void kvm_async_pf_task_wait(u32 token)
n.token = token; n.token = token;
n.cpu = smp_processor_id(); n.cpu = smp_processor_id();
n.mm = current->active_mm;
n.halted = idle || preempt_count() > 1; n.halted = idle || preempt_count() > 1;
atomic_inc(&n.mm->mm_count);
init_waitqueue_head(&n.wq); init_waitqueue_head(&n.wq);
hlist_add_head(&n.link, &b->list); hlist_add_head(&n.link, &b->list);
spin_unlock(&b->lock); spin_unlock(&b->lock);
...@@ -161,9 +158,6 @@ EXPORT_SYMBOL_GPL(kvm_async_pf_task_wait); ...@@ -161,9 +158,6 @@ EXPORT_SYMBOL_GPL(kvm_async_pf_task_wait);
static void apf_task_wake_one(struct kvm_task_sleep_node *n) static void apf_task_wake_one(struct kvm_task_sleep_node *n)
{ {
hlist_del_init(&n->link); hlist_del_init(&n->link);
if (!n->mm)
return;
mmdrop(n->mm);
if (n->halted) if (n->halted)
smp_send_reschedule(n->cpu); smp_send_reschedule(n->cpu);
else if (waitqueue_active(&n->wq)) else if (waitqueue_active(&n->wq))
...@@ -207,7 +201,7 @@ void kvm_async_pf_task_wake(u32 token) ...@@ -207,7 +201,7 @@ void kvm_async_pf_task_wake(u32 token)
* async PF was not yet handled. * async PF was not yet handled.
* Add dummy entry for the token. * Add dummy entry for the token.
*/ */
n = kmalloc(sizeof(*n), GFP_ATOMIC); n = kzalloc(sizeof(*n), GFP_ATOMIC);
if (!n) { if (!n) {
/* /*
* Allocation failed! Busy wait while other cpu * Allocation failed! Busy wait while other cpu
...@@ -219,7 +213,6 @@ void kvm_async_pf_task_wake(u32 token) ...@@ -219,7 +213,6 @@ void kvm_async_pf_task_wake(u32 token)
} }
n->token = token; n->token = token;
n->cpu = smp_processor_id(); n->cpu = smp_processor_id();
n->mm = NULL;
init_waitqueue_head(&n->wq); init_waitqueue_head(&n->wq);
hlist_add_head(&n->link, &b->list); hlist_add_head(&n->link, &b->list);
} else } else
......
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