All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a new stat
@ 2021-09-25  0:55 ` Sean Christopherson
  0 siblings, 0 replies; 192+ messages in thread
From: Sean Christopherson @ 2021-09-25  0:55 UTC (permalink / raw)
  To: Marc Zyngier, Huacai Chen, Aleksandar Markovic, Paul Mackerras,
	Christian Borntraeger, Janosch Frank, Paolo Bonzini
  Cc: James Morse, Alexandru Elisei, Suzuki K Poulose,
	David Hildenbrand, Cornelia Huck, Claudio Imbrenda,
	Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li, Jim Mattson,
	Joerg Roedel, linux-arm-kernel, kvmarm, linux-mips, kvm, kvm-ppc,
	linux-kernel, David Matlack, Jing Zhang

The main purpose of this series is differentiate between "halt" and a more
generic "block", where "halt" aligns with x86's HLT instruction, the
halt-polling mechanisms, and associated stats, and "block" means any guest
action that causes the vCPU to block/wait.

This series arose out of a discussion over adding a stat to track if a
vCPU is blocked/halted[*].  The TL;DR of the discussion is that x86 has
several non-halt "wait" states, and arguably those states should not
participate in halt-polling.  In practice, it really doesn't matter from
a functionality perspective because there are typically so few occurences
of the non-halt waits that they're in the noise compared to the number of
actual HLTs, especially for a long-running VM.  So, my justification for
the rename is that because it doesn't truly affect functionality, KVM
might as well be technically correct and only use halt-polling for HLT.

The other annoyance this series addresses is that KVM mixes "halt" and
"block", e.g. the existing function is kvm_vcpu_block(), but all the stats
and the tracepoint use "halt".  Ideally, KVM would probably avoid "block"
altogether as people often think of "blocked" as meaning the vCPU is
blocked due to _host_ activity.  But I don't have a better alternative,
e.g. "halt" is obviously taken, "wait" is equivalent to "halt" on arm64,
"stop" has specific meaning on s390, etc...  I tried to address the host
vs. guest issue by naming the new stat "blocking" instead of "blocked",
e.g. to convey that the vCPU is "actively blocking" instead of "being
blocked".

Patch 01 fixes a theoretical, benign s390 bug, and sets the stage for
additional cleanups.

Patches 02-04 reconcile discrepancies in when KVM considers halt-polling
to be "successful".  Some stats consider it a success so long as KVM
doesn't schedule() away, others consider it a success if and only if a
wake event is detected in the halt-polling loop.

Patches 05-06 are prep cleanup to split out the core "block" routine.

Patch 07 is more prep, and should also be a small perf optimization for
halt-polling on arm64.

Patch 08 is x86 cleanup to free up the name kvm_vcpu_halt().

Patches 09-10 rename the existing kvm_vcpu_block() to kvm_vcpu_halt(), and
split out the core "block" routine to a new helper.

Patches 11-12 are minor cleanups to avoid unnecessary ktime_get().

Patches 13-14 convert non-HLT x86 flows to use kvm_vcpu_block().

[*] https://lkml.kernel.org/r/20210817230508.142907-1-jingzhangos@google.com

Jing Zhang (1):
  KVM: stats: Add stat to detect if vcpu is currently blocking

Sean Christopherson (13):
  KVM: s390: Ensure kvm_arch_no_poll() is read once when blocking vCPU
  KVM: Update halt-polling stats if and only if halt-polling was
    attempted
  KVM: Refactor and document halt-polling stats update helper
  KVM: Reconcile discrepancies in halt-polling stats
  KVM: s390: Clear valid_wakeup in kvm_s390_handle_wait(), not in arch
    hook
  KVM: Drop obsolete kvm_arch_vcpu_block_finish()
  KVM: Don't block+unblock when halt-polling is successful
  KVM: x86: Tweak halt emulation helper names to free up kvm_vcpu_halt()
  KVM: Rename kvm_vcpu_block() => kvm_vcpu_halt()
  KVM: Split out a kvm_vcpu_block() helper from kvm_vcpu_halt()
  KVM: Don't redo ktime_get() when calculating halt-polling
    stop/deadline
  KVM: x86: Directly block (instead of "halting") UNINITIALIZED vCPUs
  KVM: x86: Invoke kvm_vcpu_block() directly for non-HALTED wait states

 arch/arm64/include/asm/kvm_host.h   |   1 -
 arch/arm64/kvm/arch_timer.c         |   2 +-
 arch/arm64/kvm/handle_exit.c        |   4 +-
 arch/arm64/kvm/psci.c               |   2 +-
 arch/mips/include/asm/kvm_host.h    |   1 -
 arch/mips/kvm/emulate.c             |   2 +-
 arch/powerpc/include/asm/kvm_host.h |   1 -
 arch/powerpc/kvm/book3s_pr.c        |   2 +-
 arch/powerpc/kvm/book3s_pr_papr.c   |   2 +-
 arch/powerpc/kvm/booke.c            |   2 +-
 arch/powerpc/kvm/powerpc.c          |   2 +-
 arch/s390/include/asm/kvm_host.h    |   2 -
 arch/s390/kvm/interrupt.c           |   3 +-
 arch/s390/kvm/kvm-s390.c            |   7 +-
 arch/x86/include/asm/kvm_host.h     |   4 +-
 arch/x86/kvm/vmx/nested.c           |   2 +-
 arch/x86/kvm/vmx/vmx.c              |   4 +-
 arch/x86/kvm/x86.c                  |  25 ++++--
 include/linux/kvm_host.h            |   6 +-
 include/linux/kvm_types.h           |   1 +
 virt/kvm/kvm_main.c                 | 131 +++++++++++++++++-----------
 21 files changed, 118 insertions(+), 88 deletions(-)

-- 
2.33.0.685.g46640cef36-goog


^ permalink raw reply	[flat|nested] 192+ messages in thread

end of thread, other threads:[~2022-11-18  2:31 UTC | newest]

Thread overview: 192+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-25  0:55 [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a new stat Sean Christopherson
2021-09-25  0:55 ` Sean Christopherson
2021-09-25  0:55 ` Sean Christopherson
2021-09-25  0:55 ` Sean Christopherson
2021-09-25  0:55 ` [PATCH 01/14] KVM: s390: Ensure kvm_arch_no_poll() is read once when blocking vCPU Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-27  6:54   ` Christian Borntraeger
2021-09-27  6:54     ` Christian Borntraeger
2021-09-27  6:54     ` Christian Borntraeger
2021-09-27  6:54     ` Christian Borntraeger
2021-09-25  0:55 ` [PATCH 02/14] KVM: Update halt-polling stats if and only if halt-polling was attempted Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-28 18:57   ` David Matlack
2021-09-28 18:57     ` David Matlack
2021-09-28 18:57     ` David Matlack
2021-09-28 18:57     ` David Matlack
2021-09-25  0:55 ` [PATCH 03/14] KVM: Refactor and document halt-polling stats update helper Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-28 19:01   ` David Matlack
2021-09-28 19:01     ` David Matlack
2021-09-28 19:01     ` David Matlack
2021-09-25  0:55 ` [PATCH 04/14] KVM: Reconcile discrepancies in halt-polling stats Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-28 21:26   ` David Matlack
2021-09-28 21:26     ` David Matlack
2021-09-28 21:26     ` David Matlack
2021-09-25  0:55 ` [PATCH 05/14] KVM: s390: Clear valid_wakeup in kvm_s390_handle_wait(), not in arch hook Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-27  6:58   ` Christian Borntraeger
2021-09-27  6:58     ` Christian Borntraeger
2021-09-27  6:58     ` Christian Borntraeger
2021-09-27  6:58     ` Christian Borntraeger
2021-09-25  0:55 ` [PATCH 06/14] KVM: Drop obsolete kvm_arch_vcpu_block_finish() Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-27  6:58   ` Christian Borntraeger
2021-09-27  6:58     ` Christian Borntraeger
2021-09-27  6:58     ` Christian Borntraeger
2021-09-27  6:58     ` Christian Borntraeger
2021-09-28 21:28   ` David Matlack
2021-09-28 21:28     ` David Matlack
2021-09-28 21:28     ` David Matlack
2021-09-25  0:55 ` [PATCH 07/14] KVM: Don't block+unblock when halt-polling is successful Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  9:50   ` Marc Zyngier
2021-09-25  9:50     ` Marc Zyngier
2021-09-25  9:50     ` Marc Zyngier
2021-09-25  9:50     ` Marc Zyngier
2021-09-26  6:27     ` Paolo Bonzini
2021-09-26  6:27       ` Paolo Bonzini
2021-09-26  6:27       ` Paolo Bonzini
2021-09-26  6:27       ` Paolo Bonzini
2021-09-26  9:02       ` Marc Zyngier
2021-09-26  9:02         ` Marc Zyngier
2021-09-26  9:02         ` Marc Zyngier
2021-09-26  9:02         ` Marc Zyngier
2021-09-27 17:28         ` Sean Christopherson
2021-09-27 17:28           ` Sean Christopherson
2021-09-27 17:28           ` Sean Christopherson
2021-09-27 17:28           ` Sean Christopherson
2021-09-28  9:24           ` Marc Zyngier
2021-09-28  9:24             ` Marc Zyngier
2021-09-28  9:24             ` Marc Zyngier
2021-09-28  9:24             ` Marc Zyngier
2021-09-28 16:21             ` Sean Christopherson
2021-09-28 16:21               ` Sean Christopherson
2021-09-28 16:21               ` Sean Christopherson
2021-09-28 16:21               ` Sean Christopherson
2021-09-30  9:36               ` Marc Zyngier
2021-09-30  9:36                 ` Marc Zyngier
2021-09-30  9:36                 ` Marc Zyngier
2021-09-30  9:36                 ` Marc Zyngier
2021-09-25  0:55 ` [PATCH 08/14] KVM: x86: Tweak halt emulation helper names to free up kvm_vcpu_halt() Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-28 21:59   ` David Matlack
2021-09-28 21:59     ` David Matlack
2021-09-28 21:59     ` David Matlack
2021-09-25  0:55 ` [PATCH 09/14] KVM: Rename kvm_vcpu_block() => kvm_vcpu_halt() Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-27  7:06   ` Christian Borntraeger
2021-09-27  7:06     ` Christian Borntraeger
2021-09-27  7:06     ` Christian Borntraeger
2021-09-27  7:06     ` Christian Borntraeger
2021-09-28 22:01   ` David Matlack
2021-09-28 22:01     ` David Matlack
2021-09-28 22:01     ` David Matlack
2021-09-28 22:01     ` David Matlack
2021-09-25  0:55 ` [PATCH 10/14] KVM: Split out a kvm_vcpu_block() helper from kvm_vcpu_halt() Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-27  7:41   ` Christian Borntraeger
2021-09-27  7:41     ` Christian Borntraeger
2021-09-27  7:41     ` Christian Borntraeger
2021-09-27  7:41     ` Christian Borntraeger
2021-09-28 22:03   ` David Matlack
2021-09-28 22:03     ` David Matlack
2021-09-28 22:03     ` David Matlack
2021-09-25  0:55 ` [PATCH 11/14] KVM: stats: Add stat to detect if vcpu is currently blocking Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-28 22:04   ` David Matlack
2021-09-28 22:04     ` David Matlack
2021-09-28 22:04     ` David Matlack
2021-09-25  0:55 ` [PATCH 12/14] KVM: Don't redo ktime_get() when calculating halt-polling stop/deadline Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-28 22:08   ` David Matlack
2021-09-28 22:08     ` David Matlack
2021-09-28 22:08     ` David Matlack
2021-09-25  0:55 ` [PATCH 13/14] KVM: x86: Directly block (instead of "halting") UNINITIALIZED vCPUs Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-28 22:12   ` David Matlack
2021-09-28 22:12     ` David Matlack
2021-09-28 22:12     ` David Matlack
2021-09-25  0:55 ` [PATCH 14/14] KVM: x86: Invoke kvm_vcpu_block() directly for non-HALTED wait states Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-25  0:55   ` Sean Christopherson
2021-09-28 22:14   ` David Matlack
2021-09-28 22:14     ` David Matlack
2021-09-28 22:14     ` David Matlack
2021-09-28 22:14     ` David Matlack
2021-09-27  7:22 ` disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a new stat) Christian Borntraeger
2021-09-27  7:22   ` disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a new st Christian Borntraeger
2021-09-27  7:22   ` disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a new stat) Christian Borntraeger
2021-09-27  7:22   ` Christian Borntraeger
2021-09-27 14:59   ` Sean Christopherson
2021-09-27 14:59     ` disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a ne Sean Christopherson
2021-09-27 14:59     ` disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a new stat) Sean Christopherson
2021-09-27 14:59     ` Sean Christopherson
2021-09-27 15:03     ` Paolo Bonzini
2021-09-27 15:03       ` disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a ne Paolo Bonzini
2021-09-27 15:03       ` disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a new stat) Paolo Bonzini
2021-09-27 15:03       ` Paolo Bonzini
2021-09-27 15:15       ` Sean Christopherson
2021-09-27 15:15         ` disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a ne Sean Christopherson
2021-09-27 15:15         ` disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a new stat) Sean Christopherson
2021-09-27 15:15         ` Sean Christopherson
2021-09-27 15:16       ` Christian Borntraeger
2021-09-27 15:16         ` disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a ne Christian Borntraeger
2021-09-27 15:16         ` disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a new stat) Christian Borntraeger
2021-09-27 15:16         ` Christian Borntraeger
2021-09-27 16:58         ` David Matlack
2021-09-27 16:58           ` disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a ne David Matlack
2021-09-27 16:58           ` disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a new stat) David Matlack
2021-09-27 16:58           ` David Matlack
2021-09-29  6:56           ` Christian Borntraeger
2021-09-29  6:56             ` disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a ne Christian Borntraeger
2021-09-29  6:56             ` disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a new stat) Christian Borntraeger
2021-09-29  6:56             ` Christian Borntraeger
2021-09-27 17:24         ` Paolo Bonzini
2021-09-27 17:24           ` disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a ne Paolo Bonzini
2021-09-27 17:24           ` disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a new stat) Paolo Bonzini
2021-09-27 17:24           ` Paolo Bonzini
2021-09-27 17:33           ` Sean Christopherson
2021-09-27 17:33             ` disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a ne Sean Christopherson
2021-09-27 17:33             ` disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a new stat) Sean Christopherson
2021-09-27 17:33             ` Sean Christopherson
2022-11-15  3:28             ` wangyanan (Y)
2022-11-15  3:28               ` disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a ne wangyanan (Y)
2022-11-15  3:28               ` disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a new stat) wangyanan (Y)
2022-11-15  3:28               ` wangyanan (Y)
2022-11-16 17:19               ` David Matlack
2022-11-16 17:19                 ` disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a ne David Matlack
2022-11-16 17:19                 ` disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a new stat) David Matlack
2022-11-16 17:19                 ` David Matlack
2022-11-18  2:29                 ` wangyanan (Y)
2022-11-18  2:29                   ` disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a ne wangyanan (Y)
2022-11-18  2:29                   ` disabling halt polling broken? (was Re: [PATCH 00/14] KVM: Halt-polling fixes, cleanups and a new stat) wangyanan (Y)
2022-11-18  2:29                   ` wangyanan (Y)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.