* Re: [Xen-devel] [patch 14/33] xen: xen time implementation
2007-06-06 8:39 ` Jan Beulich
@ 2007-06-06 8:54 ` Keir Fraser
2007-06-06 8:54 ` Keir Fraser
2007-06-06 10:05 ` Jeremy Fitzhardinge
2 siblings, 0 replies; 13+ messages in thread
From: Keir Fraser @ 2007-06-06 8:54 UTC (permalink / raw)
To: Jan Beulich, Jeremy Fitzhardinge
Cc: Xen-devel, Andrew Morton, Andi Kleen, lkml, Chris Wright,
virtualization, Ingo Molnar, Linus Torvalds, Thomas Gleixner
On 6/6/07 09:39, "Jan Beulich" <jbeulich@novell.com> wrote:
> The issue is
> that on that system, transition into ACPI mode takes over 600ms (SMM
> execution, and hence no interrupts delivered during that time), and with
> Xen using the PIT (PM timer support was added by Keir as a result of this,
> but that doesn't cure the problem here, it just reduces the likelihood it'll
> be encountered) platform time and local time got pretty much out of sync.
If you have an ACPI PM timer in your system (and if you have SMM then your
system is almost certainly modern enough to have one) then surely the
problem is fixed for all practical purposes? The problem was overflow of a
fixed-width platform counter. The PIT wraps every ~50ms, but the ACPI PM
timer will wrap only every ~4s. It would be quite unreasonable for SMM to
take the CPU away for multiple seconds, even as a one-time boot operation.
-- Keir
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Xen-devel] [patch 14/33] xen: xen time implementation
2007-06-06 8:39 ` Jan Beulich
2007-06-06 8:54 ` [Xen-devel] " Keir Fraser
@ 2007-06-06 8:54 ` Keir Fraser
2007-06-06 10:05 ` Jeremy Fitzhardinge
2 siblings, 0 replies; 13+ messages in thread
From: Keir Fraser @ 2007-06-06 8:54 UTC (permalink / raw)
To: Jan Beulich, Jeremy Fitzhardinge
Cc: Xen-devel, lkml, Chris Wright, virtualization, Thomas Gleixner,
Andrew Morton, Linus Torvalds, Ingo Molnar
On 6/6/07 09:39, "Jan Beulich" <jbeulich@novell.com> wrote:
> The issue is
> that on that system, transition into ACPI mode takes over 600ms (SMM
> execution, and hence no interrupts delivered during that time), and with
> Xen using the PIT (PM timer support was added by Keir as a result of this,
> but that doesn't cure the problem here, it just reduces the likelihood it'll
> be encountered) platform time and local time got pretty much out of sync.
If you have an ACPI PM timer in your system (and if you have SMM then your
system is almost certainly modern enough to have one) then surely the
problem is fixed for all practical purposes? The problem was overflow of a
fixed-width platform counter. The PIT wraps every ~50ms, but the ACPI PM
timer will wrap only every ~4s. It would be quite unreasonable for SMM to
take the CPU away for multiple seconds, even as a one-time boot operation.
-- Keir
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Xen-devel] [patch 14/33] xen: xen time implementation
2007-06-06 9:30 Jan Beulich
@ 2007-06-06 9:56 ` Keir Fraser
2007-06-06 9:56 ` Keir Fraser
1 sibling, 0 replies; 13+ messages in thread
From: Keir Fraser @ 2007-06-06 9:56 UTC (permalink / raw)
To: Jan Beulich, Jeremy Fitzhardinge
Cc: Xen-devel, Andrew Morton, Andi Kleen, lkml, Chris Wright,
virtualization, Ingo Molnar, Linus Torvalds, Thomas Gleixner
On 6/6/07 10:30, "Jan Beulich" <jbeulich@novell.com> wrote:
>> If you have an ACPI PM timer in your system (and if you have SMM then your
>> system is almost certainly modern enough to have one) then surely the
>> problem is fixed for all practical purposes? The problem was overflow of a
>> fixed-width platform counter. The PIT wraps every ~50ms, but the ACPI PM
>> timer will wrap only every ~4s. It would be quite unreasonable for SMM to
>> take the CPU away for multiple seconds, even as a one-time boot operation.
>
> No, I don't think the problem's gone with the PM timer - it is just much less
> likely. Since you depend on the TSC (which must generally be assumed be
> unsyncronized across CPUs) and on the error correction factor (which shows
> non-zero values every few seconds), getting the interpolated times on two
> CPUs out of sync is still possible, and given the way the time keeping code
> works even being off by just a single nanosecond may be fatal.
If the error across CPUS is +/- just a few microseconds at worst then having
the clocksource clamp to no less than the last timestamp returned seems a
reasonable fix. Time won't 'stop' for longer than the cross-CPU error, and
that should always be a tiny value.
-- Keir
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Xen-devel] [patch 14/33] xen: xen time implementation
2007-06-06 9:30 Jan Beulich
2007-06-06 9:56 ` [Xen-devel] " Keir Fraser
@ 2007-06-06 9:56 ` Keir Fraser
1 sibling, 0 replies; 13+ messages in thread
From: Keir Fraser @ 2007-06-06 9:56 UTC (permalink / raw)
To: Jan Beulich, Jeremy Fitzhardinge
Cc: Xen-devel, lkml, Chris Wright, virtualization, Thomas Gleixner,
Andrew Morton, Linus Torvalds, Ingo Molnar
On 6/6/07 10:30, "Jan Beulich" <jbeulich@novell.com> wrote:
>> If you have an ACPI PM timer in your system (and if you have SMM then your
>> system is almost certainly modern enough to have one) then surely the
>> problem is fixed for all practical purposes? The problem was overflow of a
>> fixed-width platform counter. The PIT wraps every ~50ms, but the ACPI PM
>> timer will wrap only every ~4s. It would be quite unreasonable for SMM to
>> take the CPU away for multiple seconds, even as a one-time boot operation.
>
> No, I don't think the problem's gone with the PM timer - it is just much less
> likely. Since you depend on the TSC (which must generally be assumed be
> unsyncronized across CPUs) and on the error correction factor (which shows
> non-zero values every few seconds), getting the interpolated times on two
> CPUs out of sync is still possible, and given the way the time keeping code
> works even being off by just a single nanosecond may be fatal.
If the error across CPUS is +/- just a few microseconds at worst then having
the clocksource clamp to no less than the last timestamp returned seems a
reasonable fix. Time won't 'stop' for longer than the cross-CPU error, and
that should always be a tiny value.
-- Keir
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Xen-devel] [patch 14/33] xen: xen time implementation
2007-06-06 8:39 ` Jan Beulich
2007-06-06 8:54 ` [Xen-devel] " Keir Fraser
2007-06-06 8:54 ` Keir Fraser
@ 2007-06-06 10:05 ` Jeremy Fitzhardinge
2007-06-06 10:26 ` Andi Kleen
2 siblings, 1 reply; 13+ messages in thread
From: Jeremy Fitzhardinge @ 2007-06-06 10:05 UTC (permalink / raw)
To: Jan Beulich
Cc: Ingo Molnar, Thomas Gleixner, Andrew Morton, Linus Torvalds,
virtualization, Xen-devel, Chris Wright, Andi Kleen, lkml
Jan Beulich wrote:
> Xen itself knows to deal with this (by using an error correction factor to
> slow down the local [TSC-based] clock), but for the kernel such a situation
> may be fatal: If clocksource->cycle_last was most recently set on a CPU
> with shadow->tsc_to_nsec_mul sufficiently different from that where
> getnstimeofday() is being used, timekeeping.c's __get_nsec_offset() will
> calculate a huge nanosecond value (due to cyc2ns() doing unsigned
> operations), worth abut 4000s. This value may then be used to set a
> timeout that was intended to be a few milliseconds, effectively yielding
> a hung app (and perhaps system).
>
Hm. I had a similar situation in the stolen time code, and I ended up
using signed values so I could clamp at zero. Though that might have
been another bug; either way, the clamp is still there.
I wonder if cyc2ns might not be better using signed operations? Or
perhaps better, the time code should endevour to do things on a
completely per-cpu basis (haven't really given this any thought).
> I'm sure the time keeping code can't deal with negative values returned
> from __get_nsec_offset() (timespec_add_ns() is an example, used in
> __get_realtime_clock_ts()), otherwise a potential solution might have
> been to set the clock source's multiplier and shift to one and zero
> respectively.
I don't quite follow you here, but wouldn't setting the multiplier/shift
to 1/0 preclude being able to warp the clocksource with ntp?
> But I think that a clock source can be expected to be
> monotonic anyway, which Xen's interpolation mechanism doesn't
> guarantee across multiple CPUs. (I'm actually beginning to think that
> this might also be the reason for certain test suites occasionally reporting
> timeouts to fire early.)
>
Does the kernel expect the tsc clocksource to be completely monotonic
across cpus? Any form of cpu-local clocksource is going to have this
problem; I wonder if clocksources can really only be useful if they're
always referring to a single system-wide time reference - seems like a
bit of a limitation.
> Unfortunately so far I haven't been able to think of a reasonable solution
> to this - a simplistic approach like making xen_clocksource_read() check
> the value it is about to return against the last value it returned doesn't
> seem to be a good idea (time might appear to have stopped over some
> period of time otherwise), nor does attempting to adjust the shadowed
> tsc_to_nsec_mul values (because the kernel can't know whether it should
> boost the lagging CPU or throttle the rushing one).
I once had some code in there to do that, implemented in very boneheaded
way with a spinlock to protect the "last time returned" variable. I
expect there's a better way to implement it.
J
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Xen-devel] [patch 14/33] xen: xen time implementation
2007-06-06 11:00 Jan Beulich
2007-06-06 11:52 ` [Xen-devel] " Keir Fraser
@ 2007-06-06 11:52 ` Keir Fraser
1 sibling, 0 replies; 13+ messages in thread
From: Keir Fraser @ 2007-06-06 11:52 UTC (permalink / raw)
To: Jan Beulich
Cc: Jeremy Fitzhardinge, Xen-devel, Andrew Morton, Andi Kleen, lkml,
Chris Wright, virtualization, Ingo Molnar, Linus Torvalds,
Thomas Gleixner
On 6/6/07 12:00, "Jan Beulich" <jbeulich@novell.com> wrote:
>> If the error across CPUS is +/- just a few microseconds at worst then having
>> the clocksource clamp to no less than the last timestamp returned seems a
>> reasonable fix. Time won't 'stop' for longer than the cross-CPU error, and
>> that should always be a tiny value.
>
> Are you sure this is also true when e.g. a CPU gets throttled due to thermal
> conditions? It is my understanding that both the duty cycle adjustment and
> the frequency reduction would yield a reduced rate TSC, which would be
> accounted for only the next time the local clock gets calibrated. Otherwise,
> immediate calibration (and vcpu update) would need to be forced out of the
> thermal interrupt.
Yes, this could be an issue. Is there any way to get an interrupt or MCE
when thermal throttling occurs?
-- Keir
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Xen-devel] [patch 14/33] xen: xen time implementation
2007-06-06 11:00 Jan Beulich
@ 2007-06-06 11:52 ` Keir Fraser
2007-06-06 11:52 ` Keir Fraser
1 sibling, 0 replies; 13+ messages in thread
From: Keir Fraser @ 2007-06-06 11:52 UTC (permalink / raw)
To: Jan Beulich
Cc: Xen-devel, lkml, Chris Wright, virtualization, Thomas Gleixner,
Andrew Morton, Linus Torvalds, Ingo Molnar
On 6/6/07 12:00, "Jan Beulich" <jbeulich@novell.com> wrote:
>> If the error across CPUS is +/- just a few microseconds at worst then having
>> the clocksource clamp to no less than the last timestamp returned seems a
>> reasonable fix. Time won't 'stop' for longer than the cross-CPU error, and
>> that should always be a tiny value.
>
> Are you sure this is also true when e.g. a CPU gets throttled due to thermal
> conditions? It is my understanding that both the duty cycle adjustment and
> the frequency reduction would yield a reduced rate TSC, which would be
> accounted for only the next time the local clock gets calibrated. Otherwise,
> immediate calibration (and vcpu update) would need to be forced out of the
> thermal interrupt.
Yes, this could be an issue. Is there any way to get an interrupt or MCE
when thermal throttling occurs?
-- Keir
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Xen-devel] [patch 14/33] xen: xen time implementation
[not found] <C28C5EAB.1024D%keir@xensource.com>
@ 2007-06-06 12:18 ` Andi Kleen
2007-06-06 12:46 ` Jan Beulich
0 siblings, 1 reply; 13+ messages in thread
From: Andi Kleen @ 2007-06-06 12:18 UTC (permalink / raw)
To: Keir Fraser
Cc: Jan Beulich, Jeremy Fitzhardinge, Xen-devel, Andrew Morton, lkml,
Chris Wright, virtualization, Ingo Molnar, Linus Torvalds,
Thomas Gleixner
>
> Yes, this could be an issue. Is there any way to get an interrupt or MCE
> when thermal throttling occurs?
Yes you can get an thermal interrupt from the local APIC. See the Linux
kernel source. Of course there would be still a race window.
On the other hand some timing issues on throttling are probably
the smallest of the users' problems when it really happens.
Standard Linux just ignores it.
-Andi
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch 14/33] xen: xen time implementation
2007-06-06 12:18 ` [Xen-devel] [patch 14/33] xen: xen time implementation Andi Kleen
@ 2007-06-06 12:46 ` Jan Beulich
2007-06-06 12:53 ` Andi Kleen
` (2 more replies)
0 siblings, 3 replies; 13+ messages in thread
From: Jan Beulich @ 2007-06-06 12:46 UTC (permalink / raw)
To: Andi Kleen, Keir Fraser
Cc: Jeremy Fitzhardinge, Xen-devel, Andrew Morton, lkml, Chris Wright,
virtualization, Ingo Molnar, Linus Torvalds, Thomas Gleixner
>>> Andi Kleen <ak@suse.de> 06.06.07 14:18 >>>
>
>>
>> Yes, this could be an issue. Is there any way to get an interrupt or MCE
>> when thermal throttling occurs?
>
>Yes you can get an thermal interrupt from the local APIC. See the Linux
>kernel source. Of course there would be still a race window.
>
>On the other hand some timing issues on throttling are probably
>the smallest of the users' problems when it really happens.
Not if this results in your box hanging - I think throttling is exactly intended
to keep the box alive as long as possible (and I've seen throttling in action,
with the box happily recovering from the situation - after having seen it a
few times I checked and found the fan covered with dust).
>Standard Linux just ignores it.
Jan
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch 14/33] xen: xen time implementation
2007-06-06 12:46 ` Jan Beulich
@ 2007-06-06 12:53 ` Andi Kleen
2007-06-06 12:54 ` [Xen-devel] " Keir Fraser
2007-06-06 12:54 ` Keir Fraser
2 siblings, 0 replies; 13+ messages in thread
From: Andi Kleen @ 2007-06-06 12:53 UTC (permalink / raw)
To: Jan Beulich
Cc: Jeremy Fitzhardinge, Xen-devel, Keir Fraser, lkml, Chris Wright,
virtualization, Thomas Gleixner, Andrew Morton, Linus Torvalds,
Ingo Molnar
On Wednesday 06 June 2007 14:46:59 Jan Beulich wrote:
> >>> Andi Kleen <ak@suse.de> 06.06.07 14:18 >>>
> >
> >>
> >> Yes, this could be an issue. Is there any way to get an interrupt or MCE
> >> when thermal throttling occurs?
> >
> >Yes you can get an thermal interrupt from the local APIC. See the Linux
> >kernel source. Of course there would be still a race window.
> >
> >On the other hand some timing issues on throttling are probably
> >the smallest of the users' problems when it really happens.
>
> Not if this results in your box hanging
Yes it shouldn't hang. Just saying that some non monotonicity in the returned
values under this abnormal condition is probably not the world's end.
-Andi
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Xen-devel] [patch 14/33] xen: xen time implementation
2007-06-06 12:46 ` Jan Beulich
2007-06-06 12:53 ` Andi Kleen
2007-06-06 12:54 ` [Xen-devel] " Keir Fraser
@ 2007-06-06 12:54 ` Keir Fraser
2 siblings, 0 replies; 13+ messages in thread
From: Keir Fraser @ 2007-06-06 12:54 UTC (permalink / raw)
To: Jan Beulich, Andi Kleen
Cc: Jeremy Fitzhardinge, Xen-devel, Andrew Morton, lkml, Chris Wright,
virtualization, Ingo Molnar, Linus Torvalds, Thomas Gleixner
On 6/6/07 13:46, "Jan Beulich" <jbeulich@novell.com> wrote:
>> On the other hand some timing issues on throttling are probably
>> the smallest of the users' problems when it really happens.
>
> Not if this results in your box hanging - I think throttling is exactly
> intended
> to keep the box alive as long as possible (and I've seen throttling in action,
> with the box happily recovering from the situation - after having seen it a
> few times I checked and found the fan covered with dust).
Clamping to last returned timestamp value would be fine here. Time would go
moderately haywire for a while (lurch forwards and then stop for a while),
but wouldn't go backwards and should recover reasonably within the timescale
of the thermal event itself. I don't see an issue with just implementing
this clamping if it is needed.
-- Keir
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Xen-devel] [patch 14/33] xen: xen time implementation
2007-06-06 12:46 ` Jan Beulich
2007-06-06 12:53 ` Andi Kleen
@ 2007-06-06 12:54 ` Keir Fraser
2007-06-06 12:54 ` Keir Fraser
2 siblings, 0 replies; 13+ messages in thread
From: Keir Fraser @ 2007-06-06 12:54 UTC (permalink / raw)
To: Jan Beulich, Andi Kleen
Cc: Xen-devel, lkml, Chris Wright, virtualization, Thomas Gleixner,
Andrew Morton, Linus Torvalds, Ingo Molnar
On 6/6/07 13:46, "Jan Beulich" <jbeulich@novell.com> wrote:
>> On the other hand some timing issues on throttling are probably
>> the smallest of the users' problems when it really happens.
>
> Not if this results in your box hanging - I think throttling is exactly
> intended
> to keep the box alive as long as possible (and I've seen throttling in action,
> with the box happily recovering from the situation - after having seen it a
> few times I checked and found the fan covered with dust).
Clamping to last returned timestamp value would be fine here. Time would go
moderately haywire for a while (lurch forwards and then stop for a while),
but wouldn't go backwards and should recover reasonably within the timescale
of the thermal event itself. I don't see an issue with just implementing
this clamping if it is needed.
-- Keir
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Xen-devel] [patch 14/33] xen: xen time implementation
2007-06-06 10:26 ` Andi Kleen
@ 2007-06-06 14:15 ` Jeremy Fitzhardinge
0 siblings, 0 replies; 13+ messages in thread
From: Jeremy Fitzhardinge @ 2007-06-06 14:15 UTC (permalink / raw)
To: Andi Kleen
Cc: Jan Beulich, Ingo Molnar, Thomas Gleixner, Andrew Morton,
Linus Torvalds, virtualization, Xen-devel, Chris Wright, lkml,
Jiri Bohac
Andi Kleen wrote:
>> I once had some code in there to do that, implemented in very boneheaded
>> way with a spinlock to protect the "last time returned" variable. I
>> expect there's a better way to implement it.
>>
>
> But any per CPU setup likely needs this to avoid non monotonicity
Yeah. The point I didn't quite make was that this should be something
that the clock core should handle rather than dealing with it in every
clocksource.
J
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2007-06-06 14:15 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <C28C5EAB.1024D%keir@xensource.com>
2007-06-06 12:18 ` [Xen-devel] [patch 14/33] xen: xen time implementation Andi Kleen
2007-06-06 12:46 ` Jan Beulich
2007-06-06 12:53 ` Andi Kleen
2007-06-06 12:54 ` [Xen-devel] " Keir Fraser
2007-06-06 12:54 ` Keir Fraser
2007-06-06 11:00 Jan Beulich
2007-06-06 11:52 ` [Xen-devel] " Keir Fraser
2007-06-06 11:52 ` Keir Fraser
-- strict thread matches above, loose matches on Subject: below --
2007-06-06 9:30 Jan Beulich
2007-06-06 9:56 ` [Xen-devel] " Keir Fraser
2007-06-06 9:56 ` Keir Fraser
2007-05-22 14:09 [patch 00/33] xen: Xen paravirt_ops implementation Jeremy Fitzhardinge
2007-05-22 14:09 ` [patch 14/33] xen: xen time implementation Jeremy Fitzhardinge
2007-06-06 8:39 ` Jan Beulich
2007-06-06 8:54 ` [Xen-devel] " Keir Fraser
2007-06-06 8:54 ` Keir Fraser
2007-06-06 10:05 ` Jeremy Fitzhardinge
2007-06-06 10:26 ` Andi Kleen
2007-06-06 14:15 ` [Xen-devel] " Jeremy Fitzhardinge
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).