x86: unify/rewrite SMP TSC sync code
A message that is not in the archive (sent off-list or not yet received): fa./[email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): fa.INurNKWdUKAEULTHyfpSW65a/[email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 11 lines · Wink Saville
Quoted 5 lines · Arjan van de Ven
Quoted 2 lines
Actually, we need to ask the CPU/System makers to provide a system wide timer that is independent of the given CPU. I would expect it quite simple
they exist. They're called pmtimer and hpet.
pmtimer is port io. hpet is memory mapped io.Thanks for the info. I took a look at
Documentation/hpet.txtanddrivers/char/hpet.cand see thathpet_mmapis implemented in the driver but nothing hpet.txt indicates what is being mapped.
Quoted 5 lines
Could you point me to any other documentation? I did find the following:
http://www.intel.com/hardwaredesign/hpetspec_1.pdf
Are you aware of any example user code that uses the mmap capability of hpet?
Generally user mode code should just be using gettimeofday. When the TSC is usable as a sane time source, the kernel will use it. When it's not, it will use something else like the HPET, ACPI PM Timer or (at last resort) the PIT, in increasing degrees of slowness.
Signature · 3 lines
Robert Hancock Saskatoon, SK, Canada To email, remove "nospam" from [email protected] Home Page: http://www.roberthancock.com/
Quoted 3 lines · Robert Hancock
Quoted 1 line
Quoted 1 line
Quoted 1 line
Actually, we need to ask the CPU/System makers to provide a system wide
Generally user mode code should just be using gettimeofday. When the TSC is usable as a sane time source, the kernel will use it. When it's not, it will use something else like the HPET, ACPI PM Timer or (at last resort) the PIT, in increasing degrees of slowness.
But gettimeofday is much too expensive compared to RDTSC.
Wink
Quoted 9 lines · Wink Saville
Quoted 6 lines · Robert Hancock
Quoted 1 line
Quoted 1 line
Quoted 1 line
Actually, we need to ask the CPU/System makers to provide a system wide
Generally user mode code should just be using gettimeofday. When the TSC is usable as a sane time source, the kernel will use it. When it's not, it will use something else like the HPET, ACPI PM Timer or (at last resort) the PIT, in increasing degrees of slowness.
But gettimeofday is much too expensive compared to RDTSC.
it's the cost of a syscall (1000 cycles?) plus what it takes to get a reasonable time estimate. Assuming your kernel has enough time support AND your tsc is reasonably ok, it'll be using that. If it's NOT using that then that's a pretty good sign that you can't also use it in userspace....
Signature · 2 lines
if you want to mail me at work (you don't), use arjan (at) linux.intel.com Test the interaction between Linux and your BIOS via http://www.linuxfirmwarekit.org
Quoted 6 lines · Arjan van de Ven
it's the cost of a syscall (1000 cycles?) plus what it takes to get a reasonable time estimate. Assuming your kernel has enough time support AND your tsc is reasonably ok, it'll be using that. If it's NOT using that then that's a pretty good sign that you can't also use it in userspace....
I wrote a quick and dirty program that I've attached to test the cost difference between RDTSC and gettimeofday (gtod), the results:
wink@winkc2d1:~/linux/linux-2.6/test/rdtsc-pref$ time ./rdtsc-pref 100000000 rdtsc: average ticks= 65 gtod: average ticks= 222 gtod_us: average ticks= 232
real 0m36.002s user 0m35.997s sys 0m0.000s
About a 3.5x cost difference, still for most of my uses gtod was not as costly as I had supposed.
But, there are other uses that it wouldn't be acceptable. For instance, I have used a memory mapped time stamp counter in an embedded ARM based system for instrumenting the interrupt service routine, syscalls and task switches. For this type of instrumentation a gtod type call wouldn't have been suitable.
Anyway for x86_64 systems, if I can use a memory mapped HPET counter, I might be able to have my cake and eat it too. One counter that can be used inside and outside the kernel that is cheap, precise and accurate, nirvana! We'll have to see.
BTW my system is a 2.4ghz Core 2 duo running 2.6.19-rc6 with HPET enabled, in the attachment I've included my config file.
Cheers,
Wink
Quoted 8 lines · Wink Saville
Quoted 6 lines · Arjan van de Ven
it's the cost of a syscall (1000 cycles?) plus what it takes to get a reasonable time estimate. Assuming your kernel has enough time support AND your tsc is reasonably ok, it'll be using that. If it's NOT using that then that's a pretty good sign that you can't also use it in userspace....
Quoted 7 lines
I wrote a quick and dirty program that I've attached to test the cost difference between RDTSC and gettimeofday (gtod), the results:
wink@winkc2d1:~/linux/linux-2.6/test/rdtsc-pref$ time ./rdtsc-pref 100000000 rdtsc: average ticks= 65 gtod: average ticks= 222 gtod_us: average ticks= 232
just to make sure, you do realize that when you write "ticks" that rdtsc doesn't measure cpu clock ticks or cpu cycles anymore, right? (At least not on your machine)
Quoted 2 lines
But, there are other uses that it wouldn't be acceptable. For instance, I have used a memory mapped time stamp counter in an embedded ARM based
ARM is a different animal; generally on such embedded system you know a lot better if you have a reliable and userspace-useful tick counter like this....
Signature · 2 lines
if you want to mail me at work (you don't), use arjan (at) linux.intel.com Test the interaction between Linux and your BIOS via http://www.linuxfirmwarekit.org
Quoted 4 lines · Arjan van de Ven
just to make sure, you do realize that when you write "ticks" that rdtsc doesn't measure cpu clock ticks or cpu cycles anymore, right? (At least not on your machine)
Yes, that's why I wrote ticks and not cycles. At this point I'm not sure how to convert ticks to time on my machine, something else to learn:) Hopefully the HPET will resolve all of the issues.
Wink