From: Alok Kataria <akataria@vmware.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
LKML <linux-kernel@vger.kernel.org>,
the arch/x86 maintainers <x86@kernel.org>,
Daniel Hecht <dhecht@vmware.com>
Subject: [PATCH] Skip tsc synchronization checks if CONSTANT_TSC bit is set.
Date: Wed, 22 Oct 2008 12:23:47 -0700 [thread overview]
Message-ID: <1224703427.13953.8.camel@alok-dev1> (raw)
In-Reply-To: <20081021192746.GJ12825@one.firstfloor.org>
Skip tsc synchronization checks if CONSTANT_TSC bit is set.
From: Alok N Kataria <akataria@vmware.com>
TSC synchronization checks between CPU's bail out even if we see
a distortion of a single cycle. This makes the TSC mostly unsuable
in a virtualized environment.
The CONSTANT_TSC bit tells us if the hardware exports a constant TSC,
we can use this bit to trust the hardware and skip the TSC sync checks
at bootup.
We also force set the CONSTANT_TSC capability bit if we are running on
VMware, since the VMware hypervisor exports a constant TSC to the guest.
Signed-off-by: Alok N Kataria <akataria@vmware.com>
Cc: Andi Kleen <andi@firstfloor.org>
---
arch/x86/kernel/cpu/common.c | 1 +
arch/x86/kernel/tsc_sync.c | 8 +++++++-
2 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index a48cb0e..720b583 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -452,6 +452,7 @@ void __cpuinit detect_hypervisor_vendor(struct cpuinfo_x86 *c)
{
if (vmware_platform()) {
c->x86_hyper_vendor = X86_HYPER_VENDOR_VMWARE;
+ set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
} else {
c->x86_hyper_vendor = X86_HYPER_VENDOR_NONE;
}
diff --git a/arch/x86/kernel/tsc_sync.c b/arch/x86/kernel/tsc_sync.c
index 9ffb01c..c0c89b7 100644
--- a/arch/x86/kernel/tsc_sync.c
+++ b/arch/x86/kernel/tsc_sync.c
@@ -108,6 +108,12 @@ void __cpuinit check_tsc_sync_source(int cpu)
if (unsynchronized_tsc())
return;
+ if (boot_cpu_has(X86_FEATURE_CONSTANT_TSC)) {
+ printk(KERN_INFO
+ "Skipping synchronization checks as TSC is constant.\n");
+ return;
+ }
+
printk(KERN_INFO "checking TSC synchronization [CPU#%d -> CPU#%d]:",
smp_processor_id(), cpu);
@@ -161,7 +167,7 @@ void __cpuinit check_tsc_sync_target(void)
{
int cpus = 2;
- if (unsynchronized_tsc())
+ if (unsynchronized_tsc() || boot_cpu_has(X86_FEATURE_CONSTANT_TSC))
return;
/*
next prev parent reply other threads:[~2008-10-22 19:23 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-21 1:35 [PATCH 0/3] Improve TSC as a clocksource under VMware Alok Kataria
2008-10-21 5:55 ` Chris Snook
2008-10-21 19:11 ` Alok Kataria
2008-10-22 19:26 ` Alok Kataria
2008-10-22 19:29 ` Jeff Hansen
2008-10-21 9:43 ` Andi Kleen
2008-10-21 16:41 ` Alok Kataria
2008-10-21 17:40 ` Andi Kleen
2008-10-21 18:04 ` Alok Kataria
2008-10-21 18:15 ` Andi Kleen
2008-10-21 19:10 ` Alok Kataria
2008-10-21 19:27 ` Andi Kleen
2008-10-21 19:47 ` Alok Kataria
2008-10-21 21:41 ` Alok Kataria
2008-10-22 19:23 ` Alok Kataria [this message]
2008-10-22 19:26 ` [PATCH] Skip tsc synchronization checks if CONSTANT_TSC bit is set Ingo Molnar
2008-10-22 19:30 ` Alok Kataria
2008-10-22 20:17 ` Andi Kleen
2008-10-22 22:04 ` Alok Kataria
2008-10-22 19:58 ` Andi Kleen
2008-10-22 22:00 ` Alok Kataria
2008-10-22 22:13 ` Andi Kleen
2008-10-22 22:11 ` Alok Kataria
2008-10-22 22:54 ` Andi Kleen
2008-10-23 2:21 ` Alok Kataria
2008-10-23 8:10 ` Andi Kleen
2008-10-23 23:39 ` Alok Kataria
2008-10-23 23:47 ` H. Peter Anvin
2008-10-24 0:25 ` Andi Kleen
2008-10-24 0:46 ` H. Peter Anvin
2008-10-24 7:23 ` Andi Kleen
2008-10-24 15:30 ` H. Peter Anvin
2008-10-24 19:25 ` Andi Kleen
2008-10-24 19:19 ` H. Peter Anvin
2008-10-24 19:34 ` Andi Kleen
2008-10-24 19:50 ` Alok Kataria
2008-10-24 20:18 ` Dan Hecht
2008-10-24 1:12 ` Alok Kataria
2008-10-24 1:18 ` H. Peter Anvin
2008-10-22 22:15 ` Alan Cox
2008-10-22 22:17 ` Alok Kataria
2008-10-21 9:50 ` [PATCH 0/3] Improve TSC as a clocksource under VMware Pavel Machek
2008-10-21 16:48 ` Alok Kataria
2008-10-21 18:36 ` Pavel Machek
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=1224703427.13953.8.camel@alok-dev1 \
--to=akataria@vmware.com \
--cc=andi@firstfloor.org \
--cc=dhecht@vmware.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.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