From: Alexey Makhalov <amakhalov@vmware.com>
To: <corbet@lwn.net>, <akataria@vmware.com>, <tglx@linutronix.de>,
<mingo@redhat.com>, <hpa@zytor.com>, <x86@kernel.org>
Cc: <linux-doc@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<virtualization@lists.linux-foundation.org>,
<pv-drivers@vmware.com>, Alexey Makhalov <amakhalov@vmware.com>
Subject: [RESEND PATCH 3/3] x86/vmware: Add paravirt sched clock
Date: Thu, 27 Oct 2016 12:44:54 -0700 [thread overview]
Message-ID: <20161027194454.9729-3-amakhalov@vmware.com> (raw)
In-Reply-To: <20161027194454.9729-1-amakhalov@vmware.com>
Set pv_time_ops.sched_clock to vmware_sched_clock(). It is simplified
version of native_sched_clock() without ring buffer of mult/shift/offset
triplets and preempt toggling.
Since VMware hypervisor provides constant tsc we can use constant
mult/shift/offset triplet calculated at boot time.
no-vmw-sched-clock kernel parameter is added to disable the paravirt
sched clock.
Signed-off-by: Alexey Makhalov <amakhalov@vmware.com>
Acked-by: Alok N Kataria <akataria@vmware.com>
---
Documentation/kernel-parameters.txt | 4 ++++
arch/x86/kernel/cpu/vmware.c | 41 +++++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+)
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 37babf9..b3b2ec0 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -2754,6 +2754,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
no-kvmapf [X86,KVM] Disable paravirtualized asynchronous page
fault handling.
+ no-vmw-sched-clock
+ [X86,PV_OPS] Disable paravirtualized VMware scheduler
+ clock and use the default one.
+
no-steal-acc [X86,KVM] Disable paravirtualized steal time accounting.
steal time is computed, but won't influence scheduler
behaviour
diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
index 098a524..9b29511 100644
--- a/arch/x86/kernel/cpu/vmware.c
+++ b/arch/x86/kernel/cpu/vmware.c
@@ -24,10 +24,15 @@
#include <linux/dmi.h>
#include <linux/init.h>
#include <linux/export.h>
+#include <linux/clocksource.h>
#include <asm/div64.h>
#include <asm/x86_init.h>
#include <asm/hypervisor.h>
#include <asm/apic.h>
+#include <asm/timer.h>
+
+#undef pr_fmt
+#define pr_fmt(fmt) "vmware: " fmt
#define CPUID_VMWARE_INFO_LEAF 0x40000000
#define VMWARE_HYPERVISOR_MAGIC 0x564D5868
@@ -62,10 +67,46 @@ static unsigned long vmware_get_tsc_khz(void)
}
#ifdef CONFIG_PARAVIRT
+static struct cyc2ns_data vmware_cyc2ns __ro_after_init;
+static int vmw_sched_clock __initdata = 1;
+
+static __init int setup_vmw_sched_clock(char *s)
+{
+ vmw_sched_clock = 0;
+ return 0;
+}
+early_param("no-vmw-sched-clock", setup_vmw_sched_clock);
+
+static unsigned long long vmware_sched_clock(void)
+{
+ unsigned long long ns;
+
+ ns = mul_u64_u32_shr(rdtsc(), vmware_cyc2ns.cyc2ns_mul,
+ vmware_cyc2ns.cyc2ns_shift);
+ ns -= vmware_cyc2ns.cyc2ns_offset;
+ return ns;
+}
+
static void __init vmware_paravirt_ops_setup(void)
{
pv_info.name = "VMware hypervisor";
pv_cpu_ops.io_delay = paravirt_nop;
+
+ if (vmware_tsc_khz && vmw_sched_clock) {
+ unsigned long long tsc_now = rdtsc();
+
+ clocks_calc_mult_shift(&vmware_cyc2ns.cyc2ns_mul,
+ &vmware_cyc2ns.cyc2ns_shift,
+ vmware_tsc_khz,
+ NSEC_PER_MSEC, 0);
+ vmware_cyc2ns.cyc2ns_offset =
+ mul_u64_u32_shr(tsc_now, vmware_cyc2ns.cyc2ns_mul,
+ vmware_cyc2ns.cyc2ns_shift);
+
+ pv_time_ops.sched_clock = vmware_sched_clock;
+ pr_info("using sched offset of %llu ns\n",
+ vmware_cyc2ns.cyc2ns_offset);
+ }
}
#else
#define vmware_paravirt_ops_setup() do {} while (0)
--
2.10.1
next prev parent reply other threads:[~2016-10-27 19:45 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-26 5:20 [PATCH 0/3] x86/vmware guest improvements Alexey Makhalov
2016-10-26 5:20 ` [PATCH 1/3] x86/vmware: Use tsc_khz value for calibrate_cpu() Alexey Makhalov
2016-10-26 5:26 ` [PATCH 2/3] x86/vmware: Add basic paravirt ops support Alexey Makhalov
2016-10-26 20:47 ` Tim Mann
2016-10-26 20:47 ` Thomas Gleixner
2016-10-27 19:44 ` [RESEND PATCH 1/3] x86/vmware: Use tsc_khz value for calibrate_cpu() Alexey Makhalov
2016-10-27 19:44 ` [RESEND PATCH 2/3] x86/vmware: Add basic paravirt ops support Alexey Makhalov
2016-10-27 19:44 ` Alexey Makhalov [this message]
2016-10-27 22:10 ` [RESEND PATCH 3/3] x86/vmware: Add paravirt sched clock Thomas Gleixner
2016-10-27 21:44 ` [RESEND PATCH 1/3] x86/vmware: Use tsc_khz value for calibrate_cpu() Thomas Gleixner
2016-10-28 7:54 ` [PATCH v3 0/3] x86/vmware guest improvements Alexey Makhalov
2016-10-28 7:54 ` [PATCH v3 1/3] x86/vmware: Use tsc_khz value for calibrate_cpu() Alexey Makhalov
2016-10-31 1:17 ` [tip:x86/platform] " tip-bot for Alexey Makhalov
2016-10-28 7:54 ` [PATCH v3 2/3] x86/vmware: Add basic paravirt ops support Alexey Makhalov
2016-10-31 1:17 ` [tip:x86/platform] " tip-bot for Alexey Makhalov
2016-10-28 7:54 ` [PATCH v3 3/3] x86/vmware: Add paravirt sched clock Alexey Makhalov
2016-10-31 1:18 ` [tip:x86/platform] " tip-bot for Alexey Makhalov
2016-10-26 5:26 ` [PATCH 3/3] " Alexey Makhalov
2016-10-26 10:18 ` Thomas Gleixner
2016-10-26 16:51 ` [PATCH v2 " Alexey Makhalov
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=20161027194454.9729-3-amakhalov@vmware.com \
--to=amakhalov@vmware.com \
--cc=akataria@vmware.com \
--cc=corbet@lwn.net \
--cc=hpa@zytor.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pv-drivers@vmware.com \
--cc=tglx@linutronix.de \
--cc=virtualization@lists.linux-foundation.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
Powered by JetHome