From: Suleiman Souhlal <suleiman@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <seanjc@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Chao Gao <chao.gao@intel.com>,
David Woodhouse <dwmw2@infradead.org>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
Tzung-Bi Shih <tzungbi@kernel.org>,
John Stultz <jstultz@google.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
ssouhlal@freebsd.org, Suleiman Souhlal <suleiman@google.com>
Subject: [PATCH v8 3/3] KVM: x86: Add "suspendsteal" cmdline to request host to add suspend duration in steal time
Date: Tue, 22 Jul 2025 14:50:30 +0900 [thread overview]
Message-ID: <20250722055030.3126772-4-suleiman@google.com> (raw)
In-Reply-To: <20250722055030.3126772-1-suleiman@google.com>
Introduce a new command line parameter, "suspendsteal", enabling the
guest to use MSR_KVM_SUSPEND_STEAL, which tells the host that it would
like host suspend duration to be included in steal time.
Signed-off-by: Suleiman Souhlal <suleiman@google.com>
---
Documentation/admin-guide/kernel-parameters.txt | 5 +++++
arch/x86/kernel/kvm.c | 15 +++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 07e22ba5bfe3..9a5490539bb2 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -7074,6 +7074,11 @@
improve throughput, but will also increase the
amount of memory reserved for use by the client.
+ suspendsteal
+ [X86,PV_OPS]
+ Enable requesting the host to include the duration the
+ host was suspended in steal time. Disabled by default.
+
suspend.pm_test_delay=
[SUSPEND]
Sets the number of seconds to remain in a suspend test
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index 921c1c783bc1..35d1bb2283c2 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -320,6 +320,18 @@ static void __init paravirt_ops_setup(void)
#endif
}
+static bool suspend_steal;
+
+static int __init suspendsteal_setup(char *s)
+{
+ if (kvm_para_has_feature(KVM_FEATURE_SUSPEND_STEAL))
+ suspend_steal = true;
+
+ return 0;
+}
+
+early_param("suspendsteal", suspendsteal_setup);
+
static void kvm_register_steal_time(void)
{
int cpu = smp_processor_id();
@@ -331,6 +343,9 @@ static void kvm_register_steal_time(void)
wrmsrq(MSR_KVM_STEAL_TIME, (slow_virt_to_phys(st) | KVM_MSR_ENABLED));
pr_debug("stealtime: cpu %d, msr %llx\n", cpu,
(unsigned long long) slow_virt_to_phys(st));
+
+ if (suspend_steal)
+ wrmsrl(MSR_KVM_SUSPEND_STEAL, KVM_MSR_ENABLED);
}
static DEFINE_PER_CPU_DECRYPTED(unsigned long, kvm_apic_eoi) = KVM_PV_EOI_DISABLED;
--
2.50.0.727.gbf7dc18ff4-goog
next prev parent reply other threads:[~2025-07-22 5:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-22 5:50 [PATCH v8 0/3] KVM: x86: Include host suspended time " Suleiman Souhlal
2025-07-22 5:50 ` [PATCH v8 1/3] KVM: x86: Advance guest TSC after deep suspend Suleiman Souhlal
2025-08-21 0:24 ` Sean Christopherson
2025-07-22 5:50 ` [PATCH v8 2/3] KVM: x86: Include host suspended duration in steal time Suleiman Souhlal
2025-08-21 0:43 ` Sean Christopherson
2025-07-22 5:50 ` Suleiman Souhlal [this message]
2025-08-21 0:44 ` [PATCH v8 3/3] KVM: x86: Add "suspendsteal" cmdline to request host to add suspend " Sean Christopherson
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=20250722055030.3126772-4-suleiman@google.com \
--to=suleiman@google.com \
--cc=bp@alien8.de \
--cc=chao.gao@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=dwmw2@infradead.org \
--cc=hpa@zytor.com \
--cc=jstultz@google.com \
--cc=konrad.wilk@oracle.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=senozhatsky@chromium.org \
--cc=ssouhlal@freebsd.org \
--cc=tglx@linutronix.de \
--cc=tzungbi@kernel.org \
--cc=x86@kernel.org \
/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®