kvm/mm: Allow GUP to respond to non fatal signals
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v4 Latest4 patches 5 repliesIn review
- v33 patches 5 repliesSuperseded
- v23 patches 10 repliesSuperseded
Earlier versions · 1
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v1 | 4 patches | 34 replies | Superseded |
Changes in v4 from the cover letter
- Split patch 2+3 into three patches [Sean]
Patches in v4 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | mm/gup: Add FOLL_INTERRUPTIBLEinclude/ mm/ mm/ | +34 | 1 reply | |
| 2/4 | kvm: Add KVM_PFN_ERR_SIGPENDINGinclude/ virt/ | +12 | 1 reply | |
| 3/4 | kvm: Add interruptible flag to __gfn_to_pfn_memslot()arch/ arch/ arch/ +5 more | +27 | 1 reply | |
| 4/4 | kvm: x86: Allow to respond to generic signals during slow PFarch/ | +13 | 1 reply |
Reviews trailers per patch
All 4 patches have a Reviewed-by or Acked-by.
| Patch | John Hubbard | David Hildenbrand | Sean Christopherson |
|---|---|---|---|
| 1/4 | R-b | R-b | |
| 2/4 | R-b | ||
| 3/4 | R-b | ||
| 4/4 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.
Cover letter [PATCH v4 0/4] kvm/mm: Allow GUP to respond to non fatal signals
v4:
- Split patch 2+3 into three patches [Sean]
rfc: https://lore.kernel.org/r/[email protected] v1: https://lore.kernel.org/r/[email protected] v2: https://lore.kernel.org/r/[email protected] v3: https://lore.kernel.org/r/[email protected]
One issue was reported that libvirt won't be able to stop the virtual machine using QMP command "stop" during a paused postcopy migration [1].
It won't work because "stop the VM" operation requires the hypervisor to kick all the vcpu threads out using SIG_IPI in QEMU (which is translated to a SIGUSR1). However since during a paused postcopy, the vcpu threads are hang death at handle_userfault() so there're simply not responding to the kicks. Further, the "stop" command will further hang the QMP channel.
The mm has facility to process generic signal (FAULT_FLAG_INTERRUPTIBLE), however it's only used in the PF handlers only, not in GUP. Unluckily, KVM is a heavy GUP user on guest page faults. It means we won't be able to interrupt a long page fault for KVM fetching guest pages with what we have right now.
I think it's reasonable for GUP to only listen to fatal signals, as most of the GUP users are not really ready to handle such case. But actually KVM is not such an user, and KVM actually has rich infrastructure to handle even generic signals, and properly deliver the signal to the userspace. Then the page fault can be retried in the next KVM_RUN.
This patchset added FOLL_INTERRUPTIBLE to enable FAULT_FLAG_INTERRUPTIBLE, and let KVM be the first one to use it. KVM and mm/gup can always be able to respond to fatal signals, but not non-fatal ones until this patchset.
One thing to mention is that this is not allowing all KVM paths to be able to respond to non fatal signals, but only on x86 slow page faults. In the future when more code is ready for handling signal interruptions, we can explore possibility to have more gup callers using FOLL_INTERRUPTIBLE.
Tests
=====
I created a postcopy environment, pause the migration by shutting down the network to emulate a network failure (so the handle_userfault() will stuck for a long time), then I tried three things:
(1) Sending QMP command "stop" to QEMU monitor,
(2) Hitting Ctrl-C from QEMU cmdline,
(3) GDB attach to the dest QEMU process.
Before this patchset, all three use case hang. After the patchset, all work just like when there's not network failure at all.
Please have a look, thanks.
[1] https://gitlab.com/qemu-project/qemu/-/issues/1052
Peter Xu (4):
mm/gup: Add FOLL_INTERRUPTIBLE
kvm: Add KVM_PFN_ERR_SIGPENDING
kvm: Add interruptible flag to __gfn_to_pfn_memslot()
kvm: x86: Allow to respond to generic signals during slow PF
arch/arm64/kvm/mmu.c | 2 +- arch/powerpc/kvm/book3s_64_mmu_hv.c | 2 +- arch/powerpc/kvm/book3s_64_mmu_radix.c | 2 +- arch/x86/kvm/mmu/mmu.c | 18 ++++++++++---- include/linux/kvm_host.h | 14 +++++++++-- include/linux/mm.h | 1 + mm/gup.c | 33 ++++++++++++++++++++++---- mm/hugetlb.c | 5 +++- virt/kvm/kvm_main.c | 30 ++++++++++++++--------- virt/kvm/kvm_mm.h | 4 ++-- virt/kvm/pfncache.c | 2 +- 11 files changed, 85 insertions(+), 28 deletions(-)
Signature · 1 line
2.37.3