From: Dan Magenheimer Subject: xen_sched_clock problem in RHEL6b2, Was: [PATCH] x86: unconditionally mark TSC unstable under Xen Date: Fri, 16 Jul 2010 15:32:19 -0700 (PDT) Message-ID: <002b7702-f446-427f-8048-27d4edd7a51e@default> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Michal Novotny Cc: Jeremy Fitzhardinge , xen-devel@lists.xensource.com, Jed Smith , Jan Beulich List-Id: xen-devel@lists.xenproject.org Hi Michael -- Not sure if you are the right person for this, but FYI it appears that this bug is also in RHEL6 beta 2 and might account for some weird issues I've seen running RHEL6 betas as Xen guests. Problem description: http://lists.xensource.com/archives/html/xen-devel/2010-07/msg00241.html=20 Jeremy's solution (forwarded below): http://lists.xensource.com/archives/html/xen-devel/2010-07/msg00749.html=20 Dan > -----Original Message----- > From: Jeremy Fitzhardinge [mailto:jeremy@goop.org] > Sent: Wednesday, July 14, 2010 3:36 PM > To: Jed Smith > Cc: xen-devel@lists.xensource.com; Jan Beulich > Subject: [Xen-devel] Re: [PATCH] x86: unconditionally mark TSC unstable > under Xen >=20 > On 07/14/2010 12:24 PM, Jed Smith wrote: > > 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. > > >=20 > Ah, well that's interesting. >=20 > There's a couple of comments: >=20 > 1. you can't do this with just a compile-time test, since the same > kernel can also boot native > 2. nothing in a Xen PV domU environment should be using the tsc > directly, so this shouldn't have an effect. If something is > using > the tsc we should track it down. >=20 > I wonder, however, if you're getting the same result as Jan's > suggestion > of making sched_clock unstable by making the tsc unstable. >=20 > In that case, this patch may help: >=20 > Subject: [PATCH] xen: disable xen_sched_clock by default >=20 > xen_sched_clock only counts unstolen time. In principle this should > be useful to the Linux scheduler so that it knows how much time a > process > actually consumed. But in practice this doesn't work very well as the > scheduler expects the sched_clock time to be synchronized between > cpus. It also uses sched_clock to measure the time a task spends > sleeping, in which case "unstolen time" isn't meaningful. >=20 > So just use plain xen_clocksource_read to return wallclock nanoseconds > for sched_clock. >=20 > Signed-off-by: Jeremy Fitzhardinge >=20 > diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig > index b83e119..6a09f01 100644 > --- a/arch/x86/xen/Kconfig > +++ b/arch/x86/xen/Kconfig > @@ -29,6 +29,10 @@ config XEN_SAVE_RESTORE > depends on XEN && PM > default y >=20 > +config XEN_SCHED_CLOCK > + bool > + default n > + > config XEN_DEBUG_FS > =09bool "Enable Xen debug and tuning parameters in debugfs" > =09depends on XEN && DEBUG_FS > diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c > index 4b57c0b..242a230 100644 > --- a/arch/x86/xen/enlighten.c > +++ b/arch/x86/xen/enlighten.c > @@ -939,7 +939,11 @@ static const struct pv_time_ops xen_time_ops > __initdata =3D { > =09.set_wallclock =3D xen_set_wallclock, > =09.get_wallclock =3D xen_get_wallclock, > =09.get_tsc_khz =3D xen_tsc_khz, > +#ifdef CONFIG_XEN_SCHED_CLOCK > =09.sched_clock =3D xen_sched_clock, > +#else > +=09.sched_clock =3D xen_clocksource_read, > +#endif > }; >=20 > static const struct pv_cpu_ops xen_cpu_ops __initdata =3D { > diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c > index 9d1f853..32dc3dc 100644 > --- a/arch/x86/xen/time.c > +++ b/arch/x86/xen/time.c > @@ -154,6 +154,7 @@ static void do_stolen_accounting(void) > =09account_idle_ticks(ticks); > } >=20 > +#ifdef CONFIG_XEN_SCHED_CLOCK > /* > * Xen sched_clock implementation. Returns the number of unstolen > * nanoseconds, which is nanoseconds the VCPU spent in RUNNING+BLOCKED > @@ -191,7 +192,7 @@ unsigned long long xen_sched_clock(void) >=20 > =09return ret; > } > - > +#endif >=20 > /* Get the TSC speed from Xen */ > unsigned long xen_tsc_khz(void) >=20 > Thanks, > =09J >=20 >=20 >=20 > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel