From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
To: xen-devel@lists.xen.org
Cc: kevin.tian@intel.com, suravee.suthikulpanit@amd.com,
eddie.dong@intel.com, jbeulich@suse.com, jun.nakajima@intel.com,
boris.ostrovsky@oracle.com
Subject: [PATCH v4 1/3] x86: Use native RDTSC(P) execution when guest and host frequencies are the same
Date: Tue, 15 Apr 2014 21:27:46 -0400 [thread overview]
Message-ID: <1397611668-15338-2-git-send-email-boris.ostrovsky@oracle.com> (raw)
In-Reply-To: <1397611668-15338-1-git-send-email-boris.ostrovsky@oracle.com>
We should be able to continue using native RDTSC(P) execution after
migration if host and guest frequencies are equal (this includes
the case when the frequencies are made equal by TSC scaling feature)
This also allows us to revert main part of commit 4aab59a3 (svm: Do not
intercept RDTSC(P) when TSC scaling is supported by hardware) which
was wrong: while RDTSC intercepts were disabled domain's vtsc could
still be set, leading to inconsistent view of guest's TSC.
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
xen/arch/x86/hvm/svm/svm.c | 2 +-
xen/arch/x86/time.c | 13 +++++++++----
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index 4fd5376..813e775 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -728,7 +728,7 @@ static void svm_set_rdtsc_exiting(struct vcpu *v, bool_t enable)
general1_intercepts &= ~GENERAL1_INTERCEPT_RDTSC;
general2_intercepts &= ~GENERAL2_INTERCEPT_RDTSCP;
- if ( enable && !cpu_has_tsc_ratio )
+ if ( enable )
{
general1_intercepts |= GENERAL1_INTERCEPT_RDTSC;
general2_intercepts |= GENERAL2_INTERCEPT_RDTSCP;
diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
index f904af2..b84d127 100644
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -37,6 +37,7 @@
#include <asm/hpet.h>
#include <io_ports.h>
#include <asm/setup.h> /* for early_time_init */
+#include <asm/hvm/svm/svm.h> /* for cpu_has_tsc_ratio */
#include <public/arch-x86/cpuid.h>
/* opt_clocksource: Force clocksource to one of: pit, hpet, acpi. */
@@ -1889,10 +1890,14 @@ void tsc_set_info(struct domain *d,
d->arch.vtsc_offset = get_s_time() - elapsed_nsec;
d->arch.tsc_khz = gtsc_khz ? gtsc_khz : cpu_khz;
set_time_scale(&d->arch.vtsc_to_ns, d->arch.tsc_khz * 1000 );
- /* use native TSC if initial host has safe TSC, has not migrated
- * yet and tsc_khz == cpu_khz */
- if ( host_tsc_is_safe() && incarnation == 0 &&
- d->arch.tsc_khz == cpu_khz )
+ /*
+ * Use native TSC if initial host has safe TSC and either has not
+ * migrated yet or tsc_khz == cpu_khz (either "naturally" or via
+ * TSC scaling)
+ */
+ if ( host_tsc_is_safe() &&
+ (incarnation == 0 || d->arch.tsc_khz == cpu_khz ||
+ cpu_has_tsc_ratio) )
d->arch.vtsc = 0;
else
d->arch.ns_to_vtsc = scale_reciprocal(d->arch.vtsc_to_ns);
--
1.7.1
next prev parent reply other threads:[~2014-04-16 1:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-16 1:27 [PATCH v4 0/3] Time-related fixes for migration Boris Ostrovsky
2014-04-16 1:27 ` Boris Ostrovsky [this message]
2014-04-16 9:54 ` [PATCH v4 1/3] x86: Use native RDTSC(P) execution when guest and host frequencies are the same Jan Beulich
2014-04-16 13:02 ` Boris Ostrovsky
2014-04-16 11:38 ` Jan Beulich
2014-04-16 14:28 ` Boris Ostrovsky
2014-04-16 14:37 ` Jan Beulich
2014-04-16 15:33 ` Boris Ostrovsky
2014-04-16 16:15 ` Jan Beulich
2014-04-16 16:44 ` Boris Ostrovsky
2014-04-17 6:29 ` Jan Beulich
2014-04-16 1:27 ` [PATCH v4 2/3] x86/svn: Enable TSC scaling Boris Ostrovsky
2014-04-16 10:21 ` Jan Beulich
2014-04-16 10:53 ` Andrew Cooper
2014-04-16 1:27 ` [PATCH v4 3/3] x86/HVM: Use fixed TSC value when saving or restoring domain Boris Ostrovsky
2014-04-16 10:22 ` Jan Beulich
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=1397611668-15338-2-git-send-email-boris.ostrovsky@oracle.com \
--to=boris.ostrovsky@oracle.com \
--cc=eddie.dong@intel.com \
--cc=jbeulich@suse.com \
--cc=jun.nakajima@intel.com \
--cc=kevin.tian@intel.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=xen-devel@lists.xen.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;
as well as URLs for NNTP newsgroup(s).