Ticket #1993 (new enhancement)

Opened 2 months ago

Last modified 2 months ago

Implement using HPET timers and other mechanisms than TSC for time keeping

Reported by: axeld Assigned to: axeld
Priority: high Milestone: R1
Component: - General Version: R1 development
Cc: Platform: All

Description (Last modified by stippi)

On CPUs that are able to change their frequency, the TSC increment is not invariant. Therefore, we cannot use it to compute time on these machines. Unfortunately, most recent CPUs are affected due to power saving features.

Furthermore, in an SMP environment, the TSC of the different CPUs can drift apart. See http://lkml.org/lkml/2005/11/4/173 for an interesting insight on that topic.

For HPET (and PM timer) see ACPI 3.0 specification http://www.acpi.info/spec.htm and http://www.intel.com/technology/architecture/hpetspec.htm

Change History

03/31/08 00:53:19 changed by axeld

  • description changed.

03/31/08 01:24:52 changed by axeld

  • description changed.

03/31/08 03:45:48 changed by stippi

  • description changed.

03/31/08 06:22:26 changed by mmlr

Just to document that: In fact the same mechanism as in the cpu_fix driver can be used to "resync" the system time after a frequency change. By adjusting the conversion factor and the time base the system_time() can be made reliable without interruption (http://beos.mlotz.ch/documents/cpu_fix.html). So the only thing that is a problem are unsynchronized TSCs across multiple cores/processors. As far as I know though only certain AMD multi core processors do not provide an invariant TSC across the cores (as described in the lkml message you linked). I mention that since using the CPU internal rdtsc is desirable for performance reasons and therefore should be used when possible.

04/01/08 08:19:43 changed by axeld

That's not entirely correct, as this requires you to detect (or trigger) such a frequency change in a timely manner. And even then, there is a certain drift you cannot avoid.

Also HPET is supposed to be a pretty well performing timer, as well. We're currently using APIC and PIT timers for semaphores, and those are less exact and slower to program than HPET is supposed to be.