All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: unconditionally mark TSC unstable under Xen
@ 2010-07-14 19:24 Jed Smith
  2010-07-14 21:36 ` Jeremy Fitzhardinge
  0 siblings, 1 reply; 15+ messages in thread
From: Jed Smith @ 2010-07-14 19:24 UTC (permalink / raw)
  To: Jeremy Fitzhardinge, Jan Beulich; +Cc: xen-devel

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@linode.com>
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Tested-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 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@linode.com

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2010-08-16  1:27 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-14 19:24 [PATCH] x86: unconditionally mark TSC unstable under Xen Jed Smith
2010-07-14 21:36 ` Jeremy Fitzhardinge
     [not found]   ` <alpine.DEB.2.00.1007151656380.21432@kaball-desktop 4C3F37A5.9050606@goop.org>
2010-07-14 22:29   ` Jed Smith
2010-07-15 14:23   ` Jed Smith
2010-07-15 15:57   ` Stefano Stabellini
2010-07-15 16:30     ` Jeremy Fitzhardinge
2010-07-15 16:40       ` Dan Magenheimer
2010-07-15 16:45         ` Jeremy Fitzhardinge
2010-07-15 17:14           ` Dan Magenheimer
2010-07-15 17:30             ` Jeremy Fitzhardinge
2010-07-15 17:48               ` Dan Magenheimer
2010-07-15 18:05                 ` Jeremy Fitzhardinge
2010-08-15 20:57                   ` Ævar Arnfjörð Bjarmason
2010-08-15 23:40                     ` Jeremy Fitzhardinge
2010-08-16  1:27                       ` Ævar Arnfjörð Bjarmason

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.