Skip to content

KVM: x86: Include host suspended time in steal time

Suleiman Souhlal kvm lkml 8 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v8 Latest3 patches 3 repliesIn review
  2. v73 patches 4 repliesSuperseded
  3. v63 patches 0 repliesSuperseded
Earlier versions · 5
VersionPostedPatchesRepliesStatus
v52 patches5 repliesSuperseded
v42 patches2 repliesSuperseded
v33 patches15 repliesSuperseded
v23 patches8 repliesSuperseded
v11 patch8 repliesSuperseded

Changes in v8 from the cover letter

- Avoid #ifdef in function body.

Patches in v8 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3KVM: x86: Advance guest TSC after deep suspend.arch/x86/include/asm/kvm_host.h arch/x86/kvm/x86.c+51 -11 reply
2/3KVM: x86: Include host suspended duration in steal timeDocumentation/virt/kvm/x86/cpuid.rst Documentation/virt/kvm/x86/msr.rst arch/x86/include/asm/kvm_host.h +3 more+101 -61 reply
3/3KVM: x86: Add "suspendsteal" cmdline to request host to add suspend duration in steal timeDocumentation/admin-guide/kernel-parameters.txt arch/x86/kernel/kvm.c+20 -01 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v8 yet.

Read the v8 thread

Cover letter [PATCH v8 0/3] KVM: x86: Include host suspended time in steal time

This series makes it so that the time that the host is suspended is included in guests' steal time.

When the host resumes from a suspend, the guest thinks any task that was running during the suspend ran for a long time, even though the effective run time was much shorter, which can end up having negative effects with scheduling.

To mitigate this issue, include the time that the host was suspended in steal time, if the guest requests it, which lets the guest subtract the duration from the tasks' runtime. Add new ABI to make this behavior opt-in per-guest.

In addition, make the guest TSC behavior consistent whether the host TSC went backwards or not.

v8:
- Avoid #ifdef in function body.

v7: https://lore.kernel.org/lkml/[email protected]/
- Fix build.
- Make advancing TSC dependent on X86_64.

v6: https://lore.kernel.org/kvm/[email protected]/
- Use true/false for bools.
- Indentation.
- Remove superfluous flag.
- Use atomic operations for accumulating suspend duration.
- Reuse generic vcpu block/kick infrastructure instead of rolling our own.
- Add ABI to make the behavior opt-in per-guest.
- Add command line parameter to make guest use this.
- Reword commit messages in imperative mood.

v5: https://lore.kernel.org/kvm/[email protected]/
- Fix grammar mistakes in commit message.

v4: https://lore.kernel.org/kvm/[email protected]/
- Advance guest TSC on suspends where host TSC goes backwards.
- Block vCPUs from running until resume notifier.
- Move suspend duration accounting out of machine-independent kvm to x86.
- Merge code and documentation patches.
- Reworded documentation.

v3: https://lore.kernel.org/kvm/[email protected]/
- Use PM notifier instead of syscore ops (kvm_suspend()/kvm_resume()), because the latter doesn't get called on shallow suspend.
- Don't call function under UACCESS.
- Whitespace.

v2: https://lore.kernel.org/kvm/[email protected]/
- Accumulate suspend time at machine-independent kvm layer and track per-VCPU instead of per-VM.
- Document changes.

v1: https://lore.kernel.org/kvm/[email protected]/

Suleiman Souhlal (3):
KVM: x86: Advance guest TSC after deep suspend.
KVM: x86: Include host suspended duration in steal time
KVM: x86: Add "suspendsteal" cmdline to request host to add suspend
duration in steal time

 .../admin-guide/kernel-parameters.txt         |   5 +
 Documentation/virt/kvm/x86/cpuid.rst          |   4 +
 Documentation/virt/kvm/x86/msr.rst            |  14 ++
 arch/x86/include/asm/kvm_host.h               |   6 +
 arch/x86/include/uapi/asm/kvm_para.h          |   2 +
 arch/x86/kernel/kvm.c                         |  15 ++
 arch/x86/kvm/cpuid.c                          |   4 +-
 arch/x86/kvm/x86.c                            | 129 +++++++++++++++++-
 8 files changed, 172 insertions(+), 7 deletions(-)
Signature · 1 line
2.50.0.727.gbf7dc18ff4-goog