From: Tzung-Bi Shih <tzungbi@kernel.org>
To: Suleiman Souhlal <suleiman@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <seanjc@google.com>,
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>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
ssouhlal@freebsd.org
Subject: Re: [PATCH v5 2/2] KVM: x86: Include host suspended time in steal time
Date: Wed, 23 Apr 2025 07:57:35 +0000 [thread overview]
Message-ID: <aAidb496s6ke8RoO@google.com> (raw)
In-Reply-To: <20250325041350.1728373-3-suleiman@google.com>
On Tue, Mar 25, 2025 at 01:13:50PM +0900, Suleiman Souhlal wrote:
> 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.
>
> [...]
>
> Signed-off-by: Suleiman Souhlal <suleiman@google.com>
Saw the corresponding host suspended time has been compensated in
update_rq_clock_task():
Tested-by: Tzung-Bi Shih <tzungbi@kernel.org>
With 1 minor comment:
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
> @@ -917,8 +918,13 @@ struct kvm_vcpu_arch {
>
> struct {
> u8 preempted;
> + bool host_suspended;
Use it in bool manner.
> +static void wait_for_resume(struct kvm_vcpu *vcpu)
> +{
> + wait_event_interruptible(vcpu->arch.st.resume_waitq,
> + vcpu->arch.st.host_suspended == 0);
E.g.: !vcpu->arch.st.host_suspended.
> @@ -6939,6 +6954,19 @@ static int kvm_arch_suspend_notifier(struct kvm *kvm)
>
> mutex_lock(&kvm->lock);
> kvm_for_each_vcpu(i, vcpu, kvm) {
> + vcpu->arch.st.last_suspend = ktime_get_boottime_ns();
> + /*
> + * Tasks get thawed before the resume notifier has been called
> + * so we need to block vCPUs until the resume notifier has run.
> + * Otherwise, suspend steal time might get applied too late,
> + * and get accounted to the wrong guest task.
> + * This also ensures that the guest paused bit set below
> + * doesn't get checked and cleared before the host actually
> + * suspends.
> + */
> + vcpu->arch.st.host_suspended = 1;
E.g.: true.
> +static int kvm_arch_resume_notifier(struct kvm *kvm)
> +{
> + struct kvm_vcpu *vcpu;
> + unsigned long i;
> +
> + mutex_lock(&kvm->lock);
> + kvm_for_each_vcpu(i, vcpu, kvm) {
> + vcpu->arch.st.host_suspended = 0;
E.g.: false.
next prev parent reply other threads:[~2025-04-23 7:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-25 4:13 [PATCH v5 0/2] KVM: x86: Include host suspended time in steal time Suleiman Souhlal
2025-03-25 4:13 ` [PATCH v5 1/2] KVM: x86: Advance guest TSC after deep suspend Suleiman Souhlal
2025-04-22 4:47 ` Tzung-Bi Shih
2025-05-01 23:49 ` Sean Christopherson
2025-03-25 4:13 ` [PATCH v5 2/2] KVM: x86: Include host suspended time in steal time Suleiman Souhlal
2025-04-23 7:57 ` Tzung-Bi Shih [this message]
2025-05-02 1:17 ` Sean Christopherson
2025-04-08 1:36 ` [PATCH v5 0/2] " Suleiman Souhlal
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=aAidb496s6ke8RoO@google.com \
--to=tzungbi@kernel.org \
--cc=bp@alien8.de \
--cc=chao.gao@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=dwmw2@infradead.org \
--cc=hpa@zytor.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=suleiman@google.com \
--cc=tglx@linutronix.de \
--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