Skip to contentSkip to conversation

HPET/PIT timer accuracy

DISCUSSION Keir Fraser 4 participants 6 messages Jul 29, 2005 – Jul 30, 2005

lore
Share & tools
lore
#0 lore raw

Does anyone on this list have an idea of expected accuracy of chipset time sources (e.g., PIT/HPET)? I've been looking at relative frequency stability of the CPU-local TSC and platform HPET on a few different systems, and see weird instabilities that I cannot explain.

On a couple of systems based on Intel E7520 (Lindenhurst) chipset I see the relative frequency is stable to within a couple of parts per million (which is within measurement error). Either the two are clocked from the same crystal, or two crystals with low frequency drift/wander (but not unexpectedly low -- I don't think crystals should drift over short time periods).

In contrast, two different systems based on AMD 8111 chipset perform very badly. The relative frequency of TSC vs HPET is stable only to within +/- 30ppm! This means that, during one second, timers based on these two sources can diverge by around 30us, which is a *lot*. Clearly the TSC and HPET are driven off different time sources, but I almost cannot believe that both are driven off crystals -- one of the two must have a 1Hz frequency drift/wander of 30ppm which is totally outside the specs I'd expect of a crystal source.

Any ideas what could be going on?! This is something of a pain for the new time code, which syncs the local TSCs to the chipset timer....

-- Keir

(I am talking frequency stability here, by the way, not frequency tolerance. I know a crystal can be 100s of ppm out of whack from what is stamped on the can, but I think over short time periods it should not drift noticeably from its natural frequency).

#1 lore raw

I can only tell you we've seen weird numbers from the opteron tsc, to the point that we don't entirely trust it. Not sure why.

ron

#2 lore raw
Quoted 2 lines · Ronald G. Minnich

I can only tell you we've seen weird numbers from the opteron tsc, to the point that we don't entirely trust it. Not sure why.

Opterons can execute RDTSC out of order.

-ben

Signature · 1 line
"Time is what keeps everything from happening all at once." -- John Wheeler
#3 lore raw
In reply to Keir Fraser
Quoted 4 lines · Keir Fraser

Does anyone on this list have an idea of expected accuracy of chipset time sources (e.g., PIT/HPET)? I've been looking at relative frequency stability of the CPU-local TSC and platform HPET on a few different systems, and see weird instabilities that I cannot explain.

The TSC is not a reliable time source. There is no guarantee of synchronization between multiple CPUs. Also note that the TSC will stop in ACPI C3 mode. Probably not an issue for Xen today, but could be in the future, especially as servers start doing more power management. The HPET is preferable for a time source on systems that this is available on.

Quoted 8 lines

On a couple of systems based on Intel E7520 (Lindenhurst) chipset I see the relative frequency is stable to within a couple of parts per million (which is within measurement error). Either the two are clocked from the same crystal, or two crystals with low frequency drift/wander (but not unexpectedly low -- I don't think crystals should drift over short time periods).

Quoted 8 lines

In contrast, two different systems based on AMD 8111 chipset perform very badly. The relative frequency of TSC vs HPET is stable only to within +/- 30ppm! This means that, during one second, timers based on these two sources can diverge by around 30us, which is a *lot*. Clearly the TSC and HPET are driven off different time sources, but I almost cannot believe that both are driven off crystals -- one of the two must have a 1Hz frequency drift/wander of 30ppm which is totally outside the specs I'd expect of a crystal source.

These types of observations are not inconsistent with what others have seen. Very platform dependent.

Quoted 3 lines

Any ideas what could be going on?! This is something of a pain for the new time code, which syncs the local TSCs to the chipset timer....

This is a reality of the various hardware time sources. There are many problems associated with this. You might look at the OLS paper on a proposed rewrite for the Linux time subsystem to get a feel for how the kernel people are trying to deal with some of these issues.

Michael

Quoted 8 lines

-- Keir

(I am talking frequency stability here, by the way, not frequency tolerance. I know a crystal can be 100s of ppm out of whack from what is stamped on the can, but I think over short time periods it should not drift noticeably from its natural frequency).

Signature · 2 lines
Michael Hohnbaum                             503 578 5486
[email protected]                          t/l 775 5486
#4 lore raw
Quoted 6 lines · Michael Hohnbaum

The TSC is not a reliable time source. There is no guarantee of synchronization between multiple CPUs. Also note that the TSC will stop in ACPI C3 mode. Probably not an issue for Xen today, but could be in the future, especially as servers start doing more power management. The HPET is preferable for a time source on systems that this is available on.

We're not relying on TSC synchronisation between CPUs. They can run at different frequencies, stop in deep sleep, and so on. But we *do* want the frequency of each one to be as stable as possible. I'd expect to get <1ppm stability from a crystal source at constant temperature, no problem.

-- Keir

#5 lore raw
Quoted 9 lines · Keir Fraser
Quoted 6 lines · Michael Hohnbaum

The TSC is not a reliable time source. There is no guarantee of synchronization between multiple CPUs. Also note that the TSC will stop in ACPI C3 mode. Probably not an issue for Xen today, but could be in the future, especially as servers start doing more power management. The HPET is preferable for a time source on systems that this is available on.

Quoted 5 lines

We're not relying on TSC synchronisation between CPUs. They can run at different frequencies, stop in deep sleep, and so on. But we *do* want the frequency of each one to be as stable as possible. I'd expect to get <1ppm stability from a crystal source at constant temperature, no problem.

Not being a hardware expert, terminology and details might be a bit off, but my understanding is that yes, this level of instability from the hardware time source (not necessarily a crystal) is not uncommon. HPET time source tends to be more reliable (stable) than the TSC. There tend to be many factors that affect the accuracy of the TSC, most of which I do not grok.

Much of the complexity in the Linux time subsystem is there to deal with the inadequacy of hardware time sources.

Michael

Quoted 9 lines

-- Keir

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Signature · 2 lines
Michael Hohnbaum                             503 578 5486
[email protected]                          t/l 775 5486