path: root/virt/kvm/async_pf.c
diff options
authorAndres Lagar-Cavilla <>2014-09-17 10:51:48 -0700
committerPaolo Bonzini <>2014-09-24 14:07:54 +0200
commit234b239bea395316d7f78018c672f4a88b3cdf0d (patch)
tree3defdf8536d0b73b1130d23fc6c79343a9831d59 /virt/kvm/async_pf.c
parentb4619660635732bd2da376bb8f31f94d0f15fc98 (diff)
kvm: Faults which trigger IO release the mmap_sem
When KVM handles a tdp fault it uses FOLL_NOWAIT. If the guest memory has been swapped out or is behind a filemap, this will trigger async readahead and return immediately. The rationale is that KVM will kick back the guest with an "async page fault" and allow for some other guest process to take over. If async PFs are enabled the fault is retried asap from an async workqueue. If not, it's retried immediately in the same code path. In either case the retry will not relinquish the mmap semaphore and will block on the IO. This is a bad thing, as other mmap semaphore users now stall as a function of swap or filemap latency. This patch ensures both the regular and async PF path re-enter the fault allowing for the mmap semaphore to be relinquished in the case of IO wait. Reviewed-by: Radim Krčmář <> Signed-off-by: Andres Lagar-Cavilla <> Acked-by: Andrew Morton <> Signed-off-by: Paolo Bonzini <>
Diffstat (limited to 'virt/kvm/async_pf.c')
1 files changed, 1 insertions, 3 deletions
diff --git a/virt/kvm/async_pf.c b/virt/kvm/async_pf.c
index d6a3d0993d88..5ff7f7f2689a 100644
--- a/virt/kvm/async_pf.c
+++ b/virt/kvm/async_pf.c
@@ -80,9 +80,7 @@ static void async_pf_execute(struct work_struct *work)
- down_read(&mm->mmap_sem);
- get_user_pages(NULL, mm, addr, 1, 1, 0, NULL, NULL);
- up_read(&mm->mmap_sem);
+ kvm_get_user_page_io(NULL, mm, addr, 1, NULL);
kvm_async_page_present_sync(vcpu, apf);