KVM: Halt-polling fixes, cleanups and a new stat
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest14 patches 35 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/14 | KVM: s390: Ensure kvm_arch_no_poll() is read once when blocking vCPUarch/ virt/ | +4 | 1 reply | |
| 2/14 | KVM: Update halt-polling stats if and only if halt-polling was attemptedvirt/ | +5 | 1 reply | |
| 3/14 | KVM: Refactor and document halt-polling stats update helpervirt/ | +13 | 1 reply | |
| 4/14 | KVM: Reconcile discrepancies in halt-polling statsvirt/ | +16 | 1 reply | |
| 5/14 | KVM: s390: Clear valid_wakeup in kvm_s390_handle_wait(), not in arch hookarch/ arch/ | +2 | 1 reply | |
| 6/14 | KVM: Drop obsolete kvm_arch_vcpu_block_finish()arch/ arch/ arch/ +4 more | +0 | 2 replies | |
| 7/14 | KVM: Don't block+unblock when halt-polling is successfulvirt/ | +5 | 7 replies | |
| 8/14 | KVM: x86: Tweak halt emulation helper names to free up kvm_vcpu_halt()arch/ arch/ arch/ +1 more | +11 | 1 reply | |
| 9/14 | KVM: Rename kvm_vcpu_block() => kvm_vcpu_halt()arch/ arch/ arch/ +9 more | +29 | 2 replies | |
| 10/14 | KVM: Split out a kvm_vcpu_block() helper from kvm_vcpu_halt()include/ virt/ | +36 | 2 replies | |
| 11/14 | KVM: stats: Add stat to detect if vcpu is currently blockinginclude/ include/ virt/ | +5 | 1 reply | |
| 12/14 | KVM: Don't redo ktime_get() when calculating halt-polling stop/deadlinevirt/ | +1 | 1 reply | |
| 13/14 | KVM: x86: Directly block (instead of "halting") UNINITIALIZED vCPUsarch/ | +1 | 1 reply | |
| 14/14 | KVM: x86: Invoke kvm_vcpu_block() directly for non-HALTED wait statesarch/ | +4 | 1 reply |
Reviews trailers per patch
13 of 14 patches have a Reviewed-by or Acked-by.
| Patch | Cannon Matthews | Christian Borntraeger | David Matlack |
|---|---|---|---|
| 1/14 | R-b | ||
| 2/14 | R-b | ||
| 3/14 | R-b | ||
| 4/14 | R-b | ||
| 5/14 | R-b | ||
| 6/14 | A-b | R-b | |
| 7/14 | |||
| 8/14 | R-b | ||
| 9/14 | R-b | R-b | |
| 10/14 | R-b | R-b | |
| 11/14 | Originally-by | R-b | |
| 12/14 | R-b | ||
| 13/14 | R-b | ||
| 14/14 | 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 00/14] KVM: Halt-polling fixes, cleanups and a new stat
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/[email protected]
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(-)
Signature · 1 line
2.33.0.685.g46640cef36-goog