[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.