[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 06/17] kvm: Faults which trigger IO release the mmap
From: |
Andrea Arcangeli |
Subject: |
[Qemu-devel] [PATCH 06/17] kvm: Faults which trigger IO release the mmap_sem |
Date: |
Fri, 3 Oct 2014 19:07:56 +0200 |
From: Andres Lagar-Cavilla <address@hidden>
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ář <address@hidden>
Signed-off-by: Andres Lagar-Cavilla <address@hidden>
Signed-off-by: Andrea Arcangeli <address@hidden>
---
virt/kvm/async_pf.c | 4 +---
virt/kvm/kvm_main.c | 4 ++--
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/virt/kvm/async_pf.c b/virt/kvm/async_pf.c
index d6a3d09..44660ae 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)
might_sleep();
- down_read(&mm->mmap_sem);
- get_user_pages(NULL, mm, addr, 1, 1, 0, NULL, NULL);
- up_read(&mm->mmap_sem);
+ get_user_pages_unlocked(NULL, mm, addr, 1, 1, 0, NULL);
kvm_async_page_present_sync(vcpu, apf);
spin_lock(&vcpu->async_pf.lock);
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 95519bc..921bce7 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1170,8 +1170,8 @@ static int hva_to_pfn_slow(unsigned long addr, bool
*async, bool write_fault,
addr, write_fault, page);
up_read(¤t->mm->mmap_sem);
} else
- npages = get_user_pages_fast(addr, 1, write_fault,
- page);
+ npages = get_user_pages_unlocked(current, current->mm, addr, 1,
+ write_fault, 0, page);
if (npages != 1)
return npages;
- [Qemu-devel] [PATCH 00/17] RFC: userfault v2, Andrea Arcangeli, 2014/10/03
- [Qemu-devel] [PATCH 03/17] mm: gup: use get_user_pages_unlocked within get_user_pages_fast, Andrea Arcangeli, 2014/10/03
- [Qemu-devel] [PATCH 16/17] powerpc: add remap_anon_pages and userfaultfd, Andrea Arcangeli, 2014/10/03
- [Qemu-devel] [PATCH 14/17] userfaultfd: add new syscall to provide memory externalization, Andrea Arcangeli, 2014/10/03
- [Qemu-devel] [PATCH 01/17] mm: gup: add FOLL_TRIED, Andrea Arcangeli, 2014/10/03
- [Qemu-devel] [PATCH 06/17] kvm: Faults which trigger IO release the mmap_sem,
Andrea Arcangeli <=
- [Qemu-devel] [PATCH 04/17] mm: gup: make get_user_pages_fast and __get_user_pages_fast latency conscious, Andrea Arcangeli, 2014/10/03
- [Qemu-devel] [PATCH 11/17] mm: swp_entry_swapcount, Andrea Arcangeli, 2014/10/03
- [Qemu-devel] [PATCH 15/17] userfaultfd: make userfaultfd_write non blocking, Andrea Arcangeli, 2014/10/03
- [Qemu-devel] [PATCH 13/17] waitqueue: add nr wake parameter to __wake_up_locked_key, Andrea Arcangeli, 2014/10/03
- [Qemu-devel] [PATCH 09/17] mm: PT lock: export double_pt_lock/unlock, Andrea Arcangeli, 2014/10/03
- [Qemu-devel] [PATCH 07/17] mm: madvise MADV_USERFAULT: prepare vm_flags to allow more than 32bits, Andrea Arcangeli, 2014/10/03
- [Qemu-devel] [PATCH 10/17] mm: rmap preparation for remap_anon_pages, Andrea Arcangeli, 2014/10/03