mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ben Hutchings <ben@decadent.org.uk>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: akpm@linux-foundation.org, "Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>,
	"Wanpeng Li" <wanpeng.li@hotmail.com>
Subject: [PATCH 3.2 079/106] KVM: async_pf: avoid async pf injection when in guest mode
Date: Sat, 09 Sep 2017 22:47:39 +0100	[thread overview]
Message-ID: <lsq.1504993659.312031600@decadent.org.uk> (raw)
In-Reply-To: <lsq.1504993659.376385113@decadent.org.uk>

3.2.93-rc1 review patch.  If anyone has any objections, please let me know.

------------------

From: Wanpeng Li <wanpeng.li@hotmail.com>

commit 9bc1f09f6fa76fdf31eb7d6a4a4df43574725f93 upstream.

 INFO: task gnome-terminal-:1734 blocked for more than 120 seconds.
       Not tainted 4.12.0-rc4+ #8
 "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
 gnome-terminal- D    0  1734   1015 0x00000000
 Call Trace:
  __schedule+0x3cd/0xb30
  schedule+0x40/0x90
  kvm_async_pf_task_wait+0x1cc/0x270
  ? __vfs_read+0x37/0x150
  ? prepare_to_swait+0x22/0x70
  do_async_page_fault+0x77/0xb0
  ? do_async_page_fault+0x77/0xb0
  async_page_fault+0x28/0x30

This is triggered by running both win7 and win2016 on L1 KVM simultaneously,
and then gives stress to memory on L1, I can observed this hang on L1 when
at least ~70% swap area is occupied on L0.

This is due to async pf was injected to L2 which should be injected to L1,
L2 guest starts receiving pagefault w/ bogus %cr2(apf token from the host
actually), and L1 guest starts accumulating tasks stuck in D state in
kvm_async_pf_task_wait() since missing PAGE_READY async_pfs.

This patch fixes the hang by doing async pf when executing L1 guest.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 arch/x86/kvm/mmu.c | 7 +++++--
 arch/x86/kvm/mmu.h | 1 +
 arch/x86/kvm/x86.c | 3 +--
 3 files changed, 7 insertions(+), 4 deletions(-)

--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -3011,12 +3011,15 @@ static int kvm_arch_setup_async_pf(struc
 	return kvm_setup_async_pf(vcpu, gva, gfn, &arch);
 }
 
-static bool can_do_async_pf(struct kvm_vcpu *vcpu)
+bool kvm_can_do_async_pf(struct kvm_vcpu *vcpu)
 {
 	if (unlikely(!irqchip_in_kernel(vcpu->kvm) ||
 		     kvm_event_needs_reinjection(vcpu)))
 		return false;
 
+	if (is_guest_mode(vcpu))
+		return false;
+
 	return kvm_x86_ops->interrupt_allowed(vcpu);
 }
 
@@ -3032,7 +3035,7 @@ static bool try_async_pf(struct kvm_vcpu
 
 	put_page(pfn_to_page(*pfn));
 
-	if (!prefault && can_do_async_pf(vcpu)) {
+	if (!prefault && kvm_can_do_async_pf(vcpu)) {
 		trace_kvm_try_async_get_page(gva, gfn);
 		if (kvm_find_async_pf_gfn(vcpu, gfn)) {
 			trace_kvm_async_pf_doublefault(gva, gfn);
--- a/arch/x86/kvm/mmu.h
+++ b/arch/x86/kvm/mmu.h
@@ -52,6 +52,7 @@ int kvm_mmu_get_spte_hierarchy(struct kv
 void kvm_mmu_set_mmio_spte_mask(u64 mmio_mask);
 int handle_mmio_page_fault_common(struct kvm_vcpu *vcpu, u64 addr, bool direct);
 int kvm_init_shadow_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *context);
+bool kvm_can_do_async_pf(struct kvm_vcpu *vcpu);
 
 static inline unsigned int kvm_mmu_available_pages(struct kvm *kvm)
 {
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6935,8 +6935,7 @@ bool kvm_arch_can_inject_async_page_pres
 	if (!(vcpu->arch.apf.msr_val & KVM_ASYNC_PF_ENABLED))
 		return true;
 	else
-		return !kvm_event_needs_reinjection(vcpu) &&
-			kvm_x86_ops->interrupt_allowed(vcpu);
+		return kvm_can_do_async_pf(vcpu);
 }
 
 EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_exit);

  parent reply	other threads:[~2017-09-09 22:50 UTC|newest]

Thread overview: 109+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-09 21:47 [PATCH 3.2 000/106] 3.2.93-rc1 review Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 061/106] ipv6: Fix leak in ipv6_gso_segment() Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 067/106] perf probe: Fix examples section of documentation Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 050/106] net: ethernet: ax88796: don't call free_irq without request_irq first Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 029/106] usb: host: xhci: simplify irq handler return Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 072/106] perf script python: Remove dups in documentation examples Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 009/106] ahci: Acer SA5-271 SSD Not Detected Fix Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 023/106] of: fdt: add missing allocation-failure check Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 012/106] USB: core: replace %p with %pK Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 082/106] selinux: fix double free in selinux_parse_opts_str() Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 028/106] usb: host: xhci-mem: allocate zeroed Scratchpad Buffer Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 018/106] USB: usbip: fix nonconforming hub descriptor Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 060/106] net: add kfree_skb_list() Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 022/106] mac80211: strictly check mesh address extension mode Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 055/106] ipv6: xfrm: Handle errors reported by xfrm6_find_1stfragopt() Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 024/106] tracing/kprobes: Enforce kprobes teardown after testing Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 076/106] fix ufs_isblockset() Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 049/106] scsi: qla2xxx: don't disable a not previously enabled PCI device Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 027/106] xhci: apply PME_STUCK_QUIRK and MISSING_CAS quirk for Denverton Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 014/106] USB: iowarrior: fix info ioctl on big-endian hosts Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 052/106] ext4: fix fdatasync(2) after extent manipulation operations Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 065/106] net: ethoc: enable NAPI before poll may be scheduled Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 008/106] USB: serial: io_ti: fix div-by-zero in set_termios Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 021/106] USB: hub: fix SS max number of ports Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 020/106] USB: hub: fix non-SS hub-descriptor handling Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 007/106] USB: serial: mct_u232: fix big-endian baud-rate handling Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 032/106] drivers: char: mem: Check for address space wraparound with mmap() Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 084/106] xfrm: NULL dereference on allocation failure Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 019/106] USB: hub: fix SS hub-descriptor handling Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 078/106] excessive checks in ufs_write_failed() and ufs_evict_inode() Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 006/106] USB: serial: ir-usb: fix big-endian baud-rate debug printk Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 025/106] xhci: workaround for hosts missing CAS bit Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 075/106] KEYS: fix dereferencing NULL payload with nonzero length Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 091/106] ipv6: avoid unregistering inet6_dev for loopback Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 041/106] crypto: gcm - wait for crypto op not signal safe Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 043/106] block: fix an error code in add_partition() Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 046/106] dmaengine: ep93xx: Always start from BASE0 Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 066/106] drm/vmwgfx: Handle vmalloc() failure in vmw_local_fifo_reserve() Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 081/106] usb: xhci: ASMedia ASM1042A chipset need shorts TX quirk Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 063/106] [media] vb2: fix plane index sanity check in vb2_plane_cookie() Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 037/106] KVM: x86: zero base3 of unusable segments Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 048/106] ASoC: Fix use-after-free at card unregistration Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 073/106] KVM: cpuid: Fix read/write out-of-bounds vulnerability in cpuid emulation Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 031/106] usb: musb: tusb6010_omap: Do not reset the other direction's packet size Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 085/106] powerpc/kprobes: Pause function_graph tracing during jprobes handling Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 083/106] xfrm: Oops on error in pfkey_msg2xfrm_state() Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 058/106] alarmtimer: Rate limit periodic intervals Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 059/106] [media] rc-core: race condition during ir_raw_event_register() Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 088/106] Input: i8042 - add Fujitsu Lifebook AH544 to notimeout list Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 005/106] USB: serial: ftdi_sio: fix setting latency for unprivileged users Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 038/106] osf_wait4(): fix infoleak Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 087/106] signal: Only reschedule timers on signals timers have sent Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 011/106] USB: ene_usb6250: fix DMA to the stack Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 040/106] i2c: i2c-tiny-usb: fix buffer not being DMA capable Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 051/106] ext4: fix data corruption for mmap writes Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 089/106] drm/radeon: add a quirk for Toshiba Satellite L20-183 Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 035/106] KVM: X86: Fix read out-of-bounds vulnerability in kvm pio emulation Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 090/106] rtnetlink: add IFLA_GROUP to ifla_policy Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 026/106] usb: xhci: apply XHCI_PME_STUCK_QUIRK to Intel Apollo Lake Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 047/106] netfilter: ctnetlink: fix incorrect nf_ct_put during hash resize Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 017/106] USB: gadget: dummy_hcd: fix hub-descriptor removable fields Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 045/106] drm/gma500/psb: Actually use VBT mode when it is found Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 054/106] usb: gadget: f_mass_storage: Serialize wake and sleep execution Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 068/106] perf script: Fix outdated comment for perf-trace-python Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 034/106] powerpc/mm: Fix virt_addr_valid() etc. on 64-bit hash Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 013/106] uwb: fix device quirk on big-endian hosts Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 080/106] configfs: Fix race between create_link and configfs_rmdir Ben Hutchings
2017-09-09 21:47 ` Ben Hutchings [this message]
2017-09-09 21:47 ` [PATCH 3.2 039/106] ext4: keep existing extra fields when inode expands Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 069/106] perf script: Fix documentation errors Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 002/106] af_key: Fix slab-out-of-bounds in pfkey_compile_policy Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 074/106] MIPS: kprobes: flush_insn_slot should flush only if probe initialised Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 010/106] tcp: eliminate negative reordering in tcp_clean_rtx_queue Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 030/106] USB: xhci: fix lock-inversion problem Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 064/106] [media] vb2: Fix an off by one error in 'vb2_plane_vaddr' Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 033/106] watchdog: pcwd_usb: fix NULL-deref at probe Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 057/106] alarmtimer: Prevent overflow of relative timers Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 036/106] KVM: x86: fix use of uninitialized memory as segment descriptor in emulator Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 053/106] net: phy: fix marvell phy status reading Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 001/106] xfrm: fix stack access out of bounds with CONFIG_XFRM_SUB_POLICY Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 071/106] perf script python: Updated trace_unhandled() signature Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 077/106] ufs: set correct ->s_maxsize Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 044/106] libceph: NULL deref on crush_decode() error path Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 004/106] net: irda: irda-usb: fix firmware name on big-endian hosts Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 042/106] ALSA: hda - apply STAC_9200_DELL_M22 quirk for Dell Latitude D430 Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 003/106] tcp: avoid fragmenting peculiar skbs in SACK Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 016/106] usb: r8a66597-hcd: select a different endpoint on timeout Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 070/106] perf script python: Fix wrong code snippets in documentation Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 056/106] drivers: char: mem: Fix wraparound check to allow mappings up to the end Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 086/106] swap: cond_resched in swap_cgroup_prepare() Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 015/106] usb: r8a66597-hcd: decrease timeout Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 062/106] net: ping: do not abuse udp_poll() Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 106/106] net: phy: marvell: Limit errata to 88m1101 Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 092/106] powerpc/64: Initialise thread_info for emergency stacks Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 098/106] tcp: initialize rcv_mss to TCP_MIN_MSS instead of 0 Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 102/106] mm: fix move/migrate_pages() race on task struct Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 103/106] mm: fix NULL ptr dereference in migrate_pages Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 093/106] autofs: sanity check status reported with AUTOFS_DEV_IOCTL_FAIL Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 104/106] mm: fix NULL ptr dereference in move_pages Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 097/106] tracing/kprobes: Allow to create probe with a module name starting with a digit Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 101/106] ptrace: use fsuid, fsgid, effective creds for fs access checks Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 094/106] lib/cmdline.c: fix get_options() overflow while parsing ranges Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 099/106] xfrm: policy: check policy direction value Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 100/106] xen: fix bio vec merging Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 105/106] Sanitize 'move_pages()' permission checks Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 095/106] net: prevent sign extension in dev_get_stats() Ben Hutchings
2017-09-09 21:47 ` [PATCH 3.2 096/106] MIPS: Fix IRQ tracing & lockdep when rescheduling Ben Hutchings
2017-09-10 14:31 ` [PATCH 3.2 000/106] 3.2.93-rc1 review Guenter Roeck
2017-09-10 18:46   ` Ben Hutchings

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=lsq.1504993659.312031600@decadent.org.uk \
    --to=ben@decadent.org.uk \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=wanpeng.li@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®