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>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
ssouhlal@freebsd.org, Suleiman Souhlal <suleiman@google.com>
Subject: [PATCH v2 1/3] KVM: Introduce kvm_total_suspend_ns().
Date: Tue, 20 Aug 2024 13:35:41 +0900 [thread overview]
Message-ID: <20240820043543.837914-2-suleiman@google.com> (raw)
In-Reply-To: <20240820043543.837914-1-suleiman@google.com>
It returns the cumulative nanoseconds that the host has been suspended.
It is intended to be used for reporting host suspend time to the guest.
Signed-off-by: Suleiman Souhlal <suleiman@google.com>
---
include/linux/kvm_host.h | 2 ++
virt/kvm/kvm_main.c | 13 +++++++++++++
2 files changed, 15 insertions(+)
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index b23c6d48392f7c..8fec37b372d8c0 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -2494,4 +2494,6 @@ long kvm_arch_vcpu_pre_fault_memory(struct kvm_vcpu *vcpu,
struct kvm_pre_fault_memory *range);
#endif
+u64 kvm_total_suspend_ns(void);
+
#endif
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index cb2b78e92910fb..2235933d9247bc 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -5720,6 +5720,15 @@ static void kvm_shutdown(void)
on_each_cpu(hardware_disable_nolock, NULL, 1);
}
+static u64 last_suspend;
+static u64 total_suspend_ns;
+
+u64
+kvm_total_suspend_ns(void)
+{
+ return total_suspend_ns;
+}
+
static int kvm_suspend(void)
{
/*
@@ -5735,6 +5744,8 @@ static int kvm_suspend(void)
if (kvm_usage_count)
hardware_disable_nolock(NULL);
+
+ last_suspend = ktime_get_boottime_ns();
return 0;
}
@@ -5745,6 +5756,8 @@ static void kvm_resume(void)
if (kvm_usage_count)
WARN_ON_ONCE(__hardware_enable_nolock());
+
+ total_suspend_ns += ktime_get_boottime_ns() - last_suspend;
}
static struct syscore_ops kvm_syscore_ops = {
--
2.46.0.184.g6999bdac58-goog
next prev parent reply other threads:[~2024-08-20 4:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-20 4:35 [PATCH v2 0/3] KVM: x86: Include host suspended time in steal time Suleiman Souhlal
2024-08-20 4:35 ` Suleiman Souhlal [this message]
2024-08-21 5:40 ` [PATCH v2 1/3] KVM: Introduce kvm_total_suspend_ns() Chao Gao
2024-08-21 6:01 ` Suleiman Souhlal
2024-08-20 4:35 ` [PATCH v2 2/3] KVM: x86: Include host suspended time in steal time Suleiman Souhlal
2024-08-21 6:31 ` Chao Gao
2024-08-23 4:17 ` Suleiman Souhlal
2024-08-23 5:25 ` Chao Gao
2024-08-23 5:43 ` Suleiman Souhlal
2024-08-28 9:56 ` Suleiman Souhlal
2024-08-20 4:35 ` [PATCH v2 3/3] KVM: x86: Document host suspend being included " Suleiman Souhlal
2024-09-25 13:54 ` [PATCH v2 0/3] KVM: x86: Include host suspended time " 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=20240820043543.837914-2-suleiman@google.com \
--to=suleiman@google.com \
--cc=bp@alien8.de \
--cc=chao.gao@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.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=ssouhlal@freebsd.org \
--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 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.