WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] x86: unconditionally mark TSC unstable under Xen

To: Jeremy Fitzhardinge <jeremy@xxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxxxx>
Subject: [Xen-devel] [PATCH] x86: unconditionally mark TSC unstable under Xen
From: Jed Smith <jed@xxxxxxxxxx>
Date: Wed, 14 Jul 2010 15:24:58 -0400
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Wed, 14 Jul 2010 12:25:52 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Jeremy, Jan - what do you think?  Is this a bad move?  I feel like there
is a consequence to this that I am unaware of, but it fixes my issue.

--

x86: unconditionally mark TSC unstable under Xen

In certain domU environments (new Intel), time will rewind and jump
around by seconds or more, leading to inaccurate measurements
kernel-wide. This patch unilaterally marks the TSC unstable under Xen,
which prevents timing from jumping around on these processors without
significant penalty in all domU environments.

An example of this is the following testcase which runs many shell
processes, each of which does a DNS lookup with dig(1):

http://gist.github.com/449825


When run on a Debian testing x86_64 system without this change it
gives:

    $ (cd /tmp;git clone git://gist.github.com/449825.git;cd 449825;git
       pull;time perl many-digs.pl)
    [...]
    real    0m7.063s
    user    268659840m0.951s
    sys     38524003m13.072s

And with it:

    real    0m6.468s
    user    0m2.851s
    sys     0m6.789s

The issue isn't particular to that bit of code, it'll also crop when
running the Git test suite in parallel, or in the TIME+ top(1)
reports. Which will eventually end up displaying times like
"-596523h-14:-8" for most long-lived processes on the system.

This closes bug #16314 - Erroneous idle times for processes:

https://bugzilla.kernel.org/show_bug.cgi?id=16314


It was also reported on the Linode forums as "Xen timing wonkyness":

http://www.linode.com/forums/viewtopic.php?t=5731


Signed-off-by: Jed Smith <jed@xxxxxxxxxx>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
Reported-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
Tested-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
---
 arch/x86/kernel/cpu/intel.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 85f69cd..afc839a 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -90,8 +90,14 @@ static void __cpuinit early_init_intel(struct cpuinfo_x86 *c)
        if (c->x86_power & (1 << 8)) {
                set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
                set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC);
+#ifndef CONFIG_XEN
                if (!check_tsc_unstable())
                        sched_clock_stable = 1;
+#else
+               /*
+                * Under Xen, we cannot consider the TSC stable or it will
+                * go backwards in certain circumstances.  Bug 16314.
+                */
+               mark_tsc_unstable("Xen domain");
+#endif
        }
 
        /*
-- 
1.6.0.4


Regards,

Jed Smith
Systems Administrator
Linode, LLC
+1 (609) 593-7103 x1209
jed@xxxxxxxxxx


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel