* RE: CPU frequency shifting "problems"
@ 2001-09-28 1:24 Grover, Andrew
2001-09-28 21:54 ` Linus Torvalds
` (2 more replies)
0 siblings, 3 replies; 17+ messages in thread
From: Grover, Andrew @ 2001-09-28 1:24 UTC (permalink / raw)
To: 'Alan Cox', torvalds; +Cc: padraig, linux-kernel
> From: Alan Cox [mailto:alan@lxorguk.ukuu.org.uk]
> Sent: Thursday, September 27, 2001 5:56 PM
> To: torvalds@transmeta.com
> Cc: padraig@antefacto.com; linux-kernel@vger.kernel.org
> Subject: Re: CPU frequency shifting "problems"
> Importance: High
>
>
> > For example, the Intel "SpeedStep" CPU's are completely broken under
> > Linux, and real-time will advance at different speeds in DC
> and AC modes,
> > because Intel actually changes the frequency of the TSC
> _and_ they don't
> > document how to figure out that it changed.
>
> The change is APM or ACPI initiated. Intel won't tell anyone anything
> useful but Microsoft have published some of the required
> intel confidential
> information which helps a bit
APM is a lost cause, but the correct solution for ACPI systems is to use the
PM timer. This totally obviates the need to really care about the CPU's
effective frequency at all. Even if you knew all the details of SpeedStep
(and I've seen the same MS doc you have Alan and was surprised at its
detail) you'd still be hosed if the CPU throttles...you'd be hosed in a
*good* way because at least any delays would be longer (not shorter) than
expected but your times would be off nonetheless.
Regards -- Andy
^ permalink raw reply [flat|nested] 17+ messages in thread* RE: CPU frequency shifting "problems"
2001-09-28 1:24 CPU frequency shifting "problems" Grover, Andrew
@ 2001-09-28 21:54 ` Linus Torvalds
2001-09-29 0:37 ` Jonathan Morton
2001-09-28 22:30 ` Alan Cox
2001-10-01 9:28 ` Pavel Machek
2 siblings, 1 reply; 17+ messages in thread
From: Linus Torvalds @ 2001-09-28 21:54 UTC (permalink / raw)
To: Grover, Andrew; +Cc: 'Alan Cox', padraig, linux-kernel
On Thu, 27 Sep 2001, Grover, Andrew wrote:
>
> APM is a lost cause, but the correct solution for ACPI systems is to use the
> PM timer.
This is _completely_ untrue.
The PM timer is (a) inaccurate and (b) slow as hell.
Linux uses TSC because we want high accuracy (nanosecond scale) without
having slow stuff.
But we've had other chips that were broken, and were marked as "don't use
the TSC" for real-time. They'll get worse results, but hey, if intel isn't
going to fix their TSC, that's all the more reason to buy AMD (or..)
Linus
^ permalink raw reply [flat|nested] 17+ messages in thread
* RE: CPU frequency shifting "problems"
2001-09-28 21:54 ` Linus Torvalds
@ 2001-09-29 0:37 ` Jonathan Morton
0 siblings, 0 replies; 17+ messages in thread
From: Jonathan Morton @ 2001-09-29 0:37 UTC (permalink / raw)
To: Linus Torvalds, Grover, Andrew; +Cc: 'Alan Cox', padraig, linux-kernel
> > APM is a lost cause, but the correct solution for ACPI systems is
>to use the
>> PM timer.
>
>This is _completely_ untrue.
>
>The PM timer is (a) inaccurate and (b) slow as hell.
>
>Linux uses TSC because we want high accuracy (nanosecond scale) without
>having slow stuff.
Please, don't confuse accuracy with precision. The TSC is precise
but not accurate. The 100Hz timer is more accurate, especially given
a SpeedStep CPU, but much less precise. It's a subtle distinction,
but an important one.
--
--------------------------------------------------------------
from: Jonathan "Chromatix" Morton
mail: chromi@cyberspace.org (not for attachments)
website: http://www.chromatix.uklinux.net/vnc/
geekcode: GCS$/E dpu(!) s:- a20 C+++ UL++ P L+++ E W+ N- o? K? w--- O-- M++$
V? PS PE- Y+ PGP++ t- 5- X- R !tv b++ DI+++ D G e+ h+ r++ y+(*)
tagline: The key to knowledge is not to rely on people to teach you it.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: CPU frequency shifting "problems"
2001-09-28 1:24 CPU frequency shifting "problems" Grover, Andrew
2001-09-28 21:54 ` Linus Torvalds
@ 2001-09-28 22:30 ` Alan Cox
2001-10-01 9:28 ` Pavel Machek
2 siblings, 0 replies; 17+ messages in thread
From: Alan Cox @ 2001-09-28 22:30 UTC (permalink / raw)
To: Grover, Andrew; +Cc: 'Alan Cox', torvalds, padraig, linux-kernel
> effective frequency at all. Even if you knew all the details of SpeedStep
> (and I've seen the same MS doc you have Alan and was surprised at its
> detail) you'd still be hosed if the CPU throttles...you'd be hosed in a
> *good* way because at least any delays would be longer (not shorter) than
> expected but your times would be off nonetheless.
Remember you get an interrupt from the transition that you can steal from
the ROM gunge, or is that another deep intel secret you can't comment on 8)
Just why are intel so obsessed by secrets about something every other vendor
does anyway ?
Alan
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: CPU frequency shifting "problems"
2001-09-28 1:24 CPU frequency shifting "problems" Grover, Andrew
2001-09-28 21:54 ` Linus Torvalds
2001-09-28 22:30 ` Alan Cox
@ 2001-10-01 9:28 ` Pavel Machek
2 siblings, 0 replies; 17+ messages in thread
From: Pavel Machek @ 2001-10-01 9:28 UTC (permalink / raw)
To: Grover, Andrew; +Cc: 'Alan Cox', torvalds, padraig, linux-kernel
Hi!
> > > For example, the Intel "SpeedStep" CPU's are completely broken under
> > > Linux, and real-time will advance at different speeds in DC
> > and AC modes,
> > > because Intel actually changes the frequency of the TSC
> > _and_ they don't
> > > document how to figure out that it changed.
> >
> > The change is APM or ACPI initiated. Intel won't tell anyone anything
> > useful but Microsoft have published some of the required
> > intel confidential
> > information which helps a bit
>
> APM is a lost cause, but the correct solution for ACPI systems is to use the
> PM timer. This totally obviates the need to really care about the CPU's
> effective frequency at all. Even if you knew all the details of SpeedStep
> (and I've seen the same MS doc you have Alan and was surprised at its
> detail) you'd still be hosed if the CPU throttles...you'd be hosed in a
> *good* way because at least any delays would be longer (not shorter) than
> expected but your times would be off nonetheless.
And if it is thermal-throttledduring bogomips calibration...? [Well possible,
acpi is not active that early]
--
Philips Velo 1: 1"x4"x8", 300gram, 60, 12MB, 40bogomips, linux, mutt,
details at http://atrey.karlin.mff.cuni.cz/~pavel/velo/index.html.
^ permalink raw reply [flat|nested] 17+ messages in thread
[parent not found: <8FB7D6BCE8A2D511B88C00508B68C2081971E4@orsmsx102.jf.intel.com>]
* Re: CPU frequency shifting "problems"
[not found] <8FB7D6BCE8A2D511B88C00508B68C2081971E4@orsmsx102.jf.intel.com>
@ 2001-09-28 23:09 ` Alan Cox
0 siblings, 0 replies; 17+ messages in thread
From: Alan Cox @ 2001-09-28 23:09 UTC (permalink / raw)
To: Grover, Andrew; +Cc: 'Alan Cox', torvalds, padraig, linux-kernel
> > We do 5uS per transition 4 transitions per bit, 64bits. So thats 1.2mS
> > or using the PM timer thats 0.25 seconds
>
> OK ya lost me...;-)
I got my maths wrong by a slight factor of 1000, ignore me - there is a
reason I didnt do maths at university 8)
> Both Windows and FreeBSD-CURRENT use the PM timer for udelays. It is 3579545
> Hz. ~2.71 ticks per usec. Read the PM timer, add (2.71 * 5), loop on reading
> the PM timer until it reaches that, and (give or take) you have a 5us delay
> that does not depend on the TSC.
4MHz is not actually too bad at all, providing the reading overhead is
low
^ permalink raw reply [flat|nested] 17+ messages in thread
* RE: CPU frequency shifting "problems"
@ 2001-09-28 22:47 Grover, Andrew
2001-09-29 1:10 ` Gerhard Mack
0 siblings, 1 reply; 17+ messages in thread
From: Grover, Andrew @ 2001-09-28 22:47 UTC (permalink / raw)
To: 'Alan Cox'; +Cc: torvalds, padraig, linux-kernel
> From: Alan Cox [mailto:alan@lxorguk.ukuu.org.uk]
> Remember you get an interrupt from the transition that you
> can steal from
> the ROM gunge, or is that another deep intel secret you can't
> comment on 8)
>
> Just why are intel so obsessed by secrets about something
> every other vendor
> does anyway ?
I agree and have said the very thing internally, but TPTB have determined
that the benefit of an open source driver is outweighed by the perceived
competitive advantage of keeping it a trade secret. :(
-- Andy
^ permalink raw reply [flat|nested] 17+ messages in thread
* RE: CPU frequency shifting "problems"
2001-09-28 22:47 Grover, Andrew
@ 2001-09-29 1:10 ` Gerhard Mack
0 siblings, 0 replies; 17+ messages in thread
From: Gerhard Mack @ 2001-09-29 1:10 UTC (permalink / raw)
To: Grover, Andrew; +Cc: 'Alan Cox', torvalds, padraig, linux-kernel
On Fri, 28 Sep 2001, Grover, Andrew wrote:
>
> I agree and have said the very thing internally, but TPTB have determined
> that the benefit of an open source driver is outweighed by the perceived
> competitive advantage of keeping it a trade secret. :(
Can you ask them what the competitive advantage is of effectively handing
the competition a speed advantage by forcing Linux users to not use the
TSC ?
I wonder how that would show up on the benchmarks...
Gerhard
--
Gerhard Mack
gmack@innerfire.net
<>< As a computer I find your faith in technology amusing.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Locking comment on shrink_caches()
@ 2001-09-26 18:24 Linus Torvalds
2001-09-26 18:40 ` Dave Jones
0 siblings, 1 reply; 17+ messages in thread
From: Linus Torvalds @ 2001-09-26 18:24 UTC (permalink / raw)
To: Dave Jones; +Cc: Alan Cox, David S. Miller, bcrl, marcelo, andrea, linux-kernel
On Wed, 26 Sep 2001, Dave Jones wrote:
> On Wed, 26 Sep 2001, Alan Cox wrote:
>
> > VIA Cyrix CIII (original generation 0.18u)
> >
> > nothing: 28 cycles
> > locked add: 29 cycles
> > cpuid: 72 cycles
>
> Interesting. From a newer C3..
>
> nothing: 30 cycles
> locked add: 31 cycles
> cpuid: 79 cycles
>
> Only slightly worse, but I'd not expected this.
That difference can easily be explained by the compiler and options.
You should use "gcc -O2" at least, in order to avoid having gcc do
unnecessary spills to memory in between the timings. And there may be some
versions of gcc that en dup spilling even then.
Linus
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Locking comment on shrink_caches()
2001-09-26 18:24 Locking comment on shrink_caches() Linus Torvalds
@ 2001-09-26 18:40 ` Dave Jones
2001-09-26 19:12 ` Linus Torvalds
0 siblings, 1 reply; 17+ messages in thread
From: Dave Jones @ 2001-09-26 18:40 UTC (permalink / raw)
To: Linus Torvalds
Cc: Alan Cox, David S. Miller, bcrl, marcelo, andrea, linux-kernel
On Wed, 26 Sep 2001, Linus Torvalds wrote:
> > > cpuid: 72 cycles
> > cpuid: 79 cycles
> > Only slightly worse, but I'd not expected this.
> That difference can easily be explained by the compiler and options.
Actually repeated runs of the test on that box show it deviating by up
to 10 cycles, making it match the results that Alan posted.
-O2 made no difference, these deviations still occur. They seem more
prominent on the C3 than other boxes I've tried, even with the same
compiler toolchain.
regards,
Dave.
--
| Dave Jones. http://www.suse.de/~davej
| SuSE Labs
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Locking comment on shrink_caches()
2001-09-26 18:40 ` Dave Jones
@ 2001-09-26 19:12 ` Linus Torvalds
2001-09-27 12:22 ` CPU frequency shifting "problems" Padraig Brady
0 siblings, 1 reply; 17+ messages in thread
From: Linus Torvalds @ 2001-09-26 19:12 UTC (permalink / raw)
To: linux-kernel
In article <Pine.LNX.4.30.0109262036480.8655-100000@Appserv.suse.de>,
Dave Jones <davej@suse.de> wrote:
>On Wed, 26 Sep 2001, Linus Torvalds wrote:
>
>> > > cpuid: 72 cycles
>> > cpuid: 79 cycles
>> > Only slightly worse, but I'd not expected this.
>> That difference can easily be explained by the compiler and options.
>
>Actually repeated runs of the test on that box show it deviating by up
>to 10 cycles, making it match the results that Alan posted.
>-O2 made no difference, these deviations still occur. They seem more
>prominent on the C3 than other boxes I've tried, even with the same
>compiler toolchain.
Does the C3 do any kind of frequency shifting?
For example, on a transmeta CPU, the TSC will run at a constant
"nominal" speed (the highest the CPU can go), although the real CPU
speed will depend on the load of the machine and temperature etc. So on
a crusoe CPU you'll see varying speeds (and it depends on the speed
grade, because that in turn depends on how many longrun steps are being
actively used).
For example, on a mostly idle machine I get
torvalds@kiwi:~ > ./a.out
nothing: 54 cycles
locked add: 54 cycles
cpuid: 91 cycles
while if I have another window that does an endless loop to keep the CPU
busy, the _real_ frequency of the CPU scales up, and the machine
basically becomes faster:
torvalds@kiwi:~ > ./a.out
nothing: 36 cycles
locked add: 36 cycles
cpuid: 54 cycles
(The reason why the "nothing" TSC read is expensive on crusoe is because
of the scaling of the TSC - rdtsc literally has to do a floating point
multiply-add to scale the clock to the right "nominal" frequency. Of
course, "expensive" is still a lot less than the inexplicable 80 cycles
on a P4).
(That's a 600MHz part going down to to 400MHz in idle, btw)
On a 633MHz part (I don't actually have access to any of the high speed
grades ;) it ends up being
fast:
nothing: 39 cycles
locked add: 40 cycles
cpuid: 68 cycles
slow:
nothing: 82 cycles
locked add: 84 cycles
cpuid: 122 cycles
which corresponds to a 633MHz part going down to 300MHz in idle.
And of course, you can get pretty much anything in between, depending on
what the load is...
Linus
^ permalink raw reply [flat|nested] 17+ messages in thread
* CPU frequency shifting "problems"
2001-09-26 19:12 ` Linus Torvalds
@ 2001-09-27 12:22 ` Padraig Brady
2001-09-27 12:44 ` Dave Jones
2001-09-27 23:23 ` Linus Torvalds
0 siblings, 2 replies; 17+ messages in thread
From: Padraig Brady @ 2001-09-27 12:22 UTC (permalink / raw)
To: Linus Torvalds; +Cc: linux-kernel
Linus Torvalds wrote:
>In article <Pine.LNX.4.30.0109262036480.8655-100000@Appserv.suse.de>,
>Dave Jones <davej@suse.de> wrote:
>
>>On Wed, 26 Sep 2001, Linus Torvalds wrote:
>>
>>>>>cpuid: 72 cycles
>>>>>
>>>>cpuid: 79 cycles
>>>>Only slightly worse, but I'd not expected this.
>>>>
>>>That difference can easily be explained by the compiler and options.
>>>
>>Actually repeated runs of the test on that box show it deviating by up
>>to 10 cycles, making it match the results that Alan posted.
>>-O2 made no difference, these deviations still occur. They seem more
>>prominent on the C3 than other boxes I've tried, even with the same
>>compiler toolchain.
>>
>
>Does the C3 do any kind of frequency shifting?
>
Not automatic, but you can set the multiplier dynamically by setting the
msr.
Russell King has been working on an arch independent framework for this
kind of thing and support for the C3 has recently been added by Dave Jones.
The code is available @:
cvs -d :pserver:cvs@pubcvs.arm.linux.org.uk:/mnt/src/cvsroot login
cvs -d :pserver:cvs@pubcvs.arm.linux.org.uk:/mnt/src/cvsroot co cpufreq
>
>For example, on a transmeta CPU, the TSC will run at a constant
>"nominal" speed (the highest the CPU can go), although the real CPU
>speed will depend on the load of the machine and temperature etc.
>
As does the P4 from what I understand. So a question..
What are the software dependencies on this auto/manual frequency shifting?
The code referenced above scales jiffies appropriately when a manual
frequency change is requested. I'm not sure about the possible consequences
of this for e.g. could there be races introduced with various busy loop
locking etc.
A quick check for the use of jiffies in the kernel:
[padraig@pixelbeat linux]$ find -name "*.[ch]" | xargs grep jiffies | wc -l
3992
Also with the auto shifting of the transmeta/P4, wont this invalidate
the jiffies
value? Also how does this affect the rtLinux guys (and realtime software
in general).
cheers,
Padraig.
> So on
>a crusoe CPU you'll see varying speeds (and it depends on the speed
>grade, because that in turn depends on how many longrun steps are being
>actively used).
>
>For example, on a mostly idle machine I get
>
> torvalds@kiwi:~ > ./a.out
> nothing: 54 cycles
> locked add: 54 cycles
> cpuid: 91 cycles
>
>while if I have another window that does an endless loop to keep the CPU
>busy, the _real_ frequency of the CPU scales up, and the machine
>basically becomes faster:
>
> torvalds@kiwi:~ > ./a.out
> nothing: 36 cycles
> locked add: 36 cycles
> cpuid: 54 cycles
>
>(The reason why the "nothing" TSC read is expensive on crusoe is because
>of the scaling of the TSC - rdtsc literally has to do a floating point
>multiply-add to scale the clock to the right "nominal" frequency. Of
>course, "expensive" is still a lot less than the inexplicable 80 cycles
>on a P4).
>
>(That's a 600MHz part
>going down to to 400MHz in idle, btw)
>
>On a 633MHz part (I don't actually have access to any of the high speed
>grades ;) it ends up being
>
>fast:
> nothing: 39 cycles
> locked add: 40 cycles
> cpuid: 68 cycles
>
>slow:
> nothing: 82 cycles
> locked add: 84 cycles
> cpuid: 122 cycles
>
>which corresponds to a 633MHz part going down to 300MHz in idle.
>
>And of course, you can get pretty much anything in between, depending on
>what the load is...
>
> Linus
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: CPU frequency shifting "problems"
2001-09-27 12:22 ` CPU frequency shifting "problems" Padraig Brady
@ 2001-09-27 12:44 ` Dave Jones
2001-09-27 23:23 ` Linus Torvalds
1 sibling, 0 replies; 17+ messages in thread
From: Dave Jones @ 2001-09-27 12:44 UTC (permalink / raw)
To: Padraig Brady; +Cc: Linux Kernel Mailing List
On Thu, 27 Sep 2001, Padraig Brady wrote:
> >Does the C3 do any kind of frequency shifting?
> Not automatic, but you can set the multiplier dynamically by setting the
> msr.
> Russell King has been working on an arch independent framework for this
> kind of thing and support for the C3 has recently been added by Dave Jones.
If you're going to try this out on a C3 btw, heed the warning at the
top of the code :) This still needs quite a bit of work.
I just need to find the time to sit down and finish it.
(The x86 bits are all thats preventing Russell from saying
"This is ready" iirc, so I should get that finished at some point soon)
I'd like to add Transmeta Longrun support to it too, but that can
come later, when I get access to one.
regards,
Dave.
--
| Dave Jones. http://www.suse.de/~davej
| SuSE Labs
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: CPU frequency shifting "problems"
2001-09-27 12:22 ` CPU frequency shifting "problems" Padraig Brady
2001-09-27 12:44 ` Dave Jones
@ 2001-09-27 23:23 ` Linus Torvalds
2001-09-28 0:55 ` Alan Cox
2001-09-28 8:55 ` Jamie Lokier
1 sibling, 2 replies; 17+ messages in thread
From: Linus Torvalds @ 2001-09-27 23:23 UTC (permalink / raw)
To: Padraig Brady; +Cc: linux-kernel
On Thu, 27 Sep 2001, Padraig Brady wrote:
>
> >
> >For example, on a transmeta CPU, the TSC will run at a constant
> >"nominal" speed (the highest the CPU can go), although the real CPU
> >speed will depend on the load of the machine and temperature etc.
>
> As does the P4 from what I understand.
That might explain why the P4 "rdtsc" is so slow.
> So a question..
> What are the software dependencies on this auto/manual frequency shifting?
None. At least not as long as the CPU _does_ do it automatically, and the
TSC appears to run at a constant speed even if the CPU does not.
For example, the Intel "SpeedStep" CPU's are completely broken under
Linux, and real-time will advance at different speeds in DC and AC modes,
because Intel actually changes the frequency of the TSC _and_ they don't
document how to figure out that it changed.
With a CPU that does makes TSC appear constant-frequency, the fact that
the CPU itself can go faster/slower doesn't matter - from a kernel
perspective that's pretty much equivalent to the different speeds you get
from cache miss behaviour etc.
Linus
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: CPU frequency shifting "problems"
2001-09-27 23:23 ` Linus Torvalds
@ 2001-09-28 0:55 ` Alan Cox
2001-09-28 2:12 ` Stefan Smietanowski
2001-09-28 8:55 ` Jamie Lokier
1 sibling, 1 reply; 17+ messages in thread
From: Alan Cox @ 2001-09-28 0:55 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Padraig Brady, linux-kernel
> For example, the Intel "SpeedStep" CPU's are completely broken under
> Linux, and real-time will advance at different speeds in DC and AC modes,
> because Intel actually changes the frequency of the TSC _and_ they don't
> document how to figure out that it changed.
The change is APM or ACPI initiated. Intel won't tell anyone anything
useful but Microsoft have published some of the required intel confidential
information which helps a bit
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: CPU frequency shifting "problems"
2001-09-28 0:55 ` Alan Cox
@ 2001-09-28 2:12 ` Stefan Smietanowski
0 siblings, 0 replies; 17+ messages in thread
From: Stefan Smietanowski @ 2001-09-28 2:12 UTC (permalink / raw)
To: Alan Cox; +Cc: linux-kernel
Hey.
>>For example, the Intel "SpeedStep" CPU's are completely broken under
>>Linux, and real-time will advance at different speeds in DC and AC modes,
>>because Intel actually changes the frequency of the TSC _and_ they don't
>>document how to figure out that it changed.
>
> The change is APM or ACPI initiated. Intel won't tell anyone anything
> useful but Microsoft have published some of the required intel confidential
> information which helps a bit
Did you just say that Microsoft actually went and did something right
for a change? As in publishing specs I mean.
*Stands in awe*
:)
// Stefan
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: CPU frequency shifting "problems"
2001-09-27 23:23 ` Linus Torvalds
2001-09-28 0:55 ` Alan Cox
@ 2001-09-28 8:55 ` Jamie Lokier
2001-09-28 16:11 ` Linus Torvalds
1 sibling, 1 reply; 17+ messages in thread
From: Jamie Lokier @ 2001-09-28 8:55 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Padraig Brady, linux-kernel
Linus Torvalds wrote:
> With a CPU that does makes TSC appear constant-frequency, the fact that
> the CPU itself can go faster/slower doesn't matter - from a kernel
> perspective that's pretty much equivalent to the different speeds you get
> from cache miss behaviour etc.
On a Transmeta chip, does the TSC clock advance _exactly_ uniformly, or
is there a cumulative error due to speed changes?
I'll clarify. I imagine that the internal clocks are driven by PLLs,
DLLs or something similar. Unless multiple oscillators are used, this
means that speed switching is gradual, over several hundred or many more
clock cycles.
You said that Crusoe does a floating point op to scale the TSC value.
Now suppose I have a 600MHz Crusoe. I calibrate the clock and it comes
out as 600.01MHz.
I can now use `rdtsc' to measure time in userspace, rather more
accurately than gettimeofday(). (In fact I have worked with programs
that do this, for network traffic injection.). I can do this over a
period of minutes, expecting the clock to match "wall clock" time
reasonably accurately.
Suppose the CPU clock speed changes. Can I be confident that
600.01*10^6 (+/- small tolerance) cycles will still be counted per
second, or is there a cumulative error due to the gradual clock speed
change and the floating-point scale factor not integrating the gradual
change precisely?
(One hardware implementation that doesn't have this problem is to run a
small counter, say 3 or 4 bits, at the nominal clock speed all the time,
and have the slower core sample that. But it may use a little more
power, and your note about FP scaling tells me you don't do that).
thanks,
-- Jamie
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: CPU frequency shifting "problems"
2001-09-28 8:55 ` Jamie Lokier
@ 2001-09-28 16:11 ` Linus Torvalds
2001-09-28 20:29 ` Eric W. Biederman
0 siblings, 1 reply; 17+ messages in thread
From: Linus Torvalds @ 2001-09-28 16:11 UTC (permalink / raw)
To: Jamie Lokier; +Cc: Padraig Brady, linux-kernel
On Fri, 28 Sep 2001, Jamie Lokier wrote:
>
> On a Transmeta chip, does the TSC clock advance _exactly_ uniformly, or
> is there a cumulative error due to speed changes?
>
> I'll clarify. I imagine that the internal clocks are driven by PLLs,
> DLLs or something similar. Unless multiple oscillators are used, this
> means that speed switching is gradual, over several hundred or many more
> clock cycles.
Basically, there's the "slow" timer, and the fast one. The slow one always
runs, and fast one gives the precision but runs at CPU speed.
So yes, there are multiple oscillators, and no, they should not drift on
frequency shifting, because the slow and constant one is used to scale the
fast one. So no cumulative errors.
HOWEVER, anybody who believes that TSC is a "truly accurate clock" will be
sadly mistaken on any machine. Even PLL's drift over time, and as
mentioned, Intel already broke the "you can use TSC as wall time" in their
SpeedStep implementation. Who knows what their future CPU's will do..
> I can now use `rdtsc' to measure time in userspace, rather more
> accurately than gettimeofday(). (In fact I have worked with programs
> that do this, for network traffic injection.). I can do this over a
> period of minutes, expecting the clock to match "wall clock" time
> reasonably accurately.
It will work on Crusoe.
> (One hardware implementation that doesn't have this problem is to run a
> small counter, say 3 or 4 bits, at the nominal clock speed all the time,
> and have the slower core sample that. But it may use a little more
> power, and your note about FP scaling tells me you don't do that).
We do that, but the other way around. The thing is, the "nominal clock
speed" doesn't even _exist_ when running normally.
What does exist is the bus clock (well, a multiple of it, but you get the
idea), and that one is stable. I bet PCI devices don't like to be randomly
driven at frequencies "somewhere between 12 and 33MHz" depending on load ;)
But because the stable frequency is the _slow_ one, you can't just scale
that up (well, you could - you could just run your cycle counter at 66MHz
all the time, and you couldn't measure smaller intervals, and people would
be really disappointed). So you need the scaling of the fast one..
Linus
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: CPU frequency shifting "problems"
2001-09-28 16:11 ` Linus Torvalds
@ 2001-09-28 20:29 ` Eric W. Biederman
2001-09-28 22:24 ` Jamie Lokier
0 siblings, 1 reply; 17+ messages in thread
From: Eric W. Biederman @ 2001-09-28 20:29 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Jamie Lokier, Padraig Brady, linux-kernel
Linus Torvalds <torvalds@transmeta.com> writes:
> What does exist is the bus clock (well, a multiple of it, but you get the
> idea), and that one is stable. I bet PCI devices don't like to be randomly
> driven at frequencies "somewhere between 12 and 33MHz" depending on load ;)
I doubt they would like it but it is perfectly legal (PCI spec..) to
vary the pci clock, depending upon load.
Eric
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: CPU frequency shifting "problems"
2001-09-28 20:29 ` Eric W. Biederman
@ 2001-09-28 22:24 ` Jamie Lokier
0 siblings, 0 replies; 17+ messages in thread
From: Jamie Lokier @ 2001-09-28 22:24 UTC (permalink / raw)
To: Eric W. Biederman; +Cc: Linus Torvalds, Padraig Brady, linux-kernel
Eric W. Biederman wrote:
> > What does exist is the bus clock (well, a multiple of it, but you get the
> > idea), and that one is stable. I bet PCI devices don't like to be randomly
> > driven at frequencies "somewhere between 12 and 33MHz" depending on load ;)
>
> I doubt they would like it but it is perfectly legal (PCI spec..) to
> vary the pci clock, depending upon load.
Yes it is. Also, the PCI clock is frequency modulated to reduce
electrical interference. (Or on a more cynical note, to pass the
official emissions tests ;-)
However it's common practice to PLL to the PCI clock, for clock
distribution on a board, so varying the frequency must be done in a
strictly constrained fashion.
-- Jamie
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2001-10-02 21:34 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-28 1:24 CPU frequency shifting "problems" Grover, Andrew
2001-09-28 21:54 ` Linus Torvalds
2001-09-29 0:37 ` Jonathan Morton
2001-09-28 22:30 ` Alan Cox
2001-10-01 9:28 ` Pavel Machek
[not found] <8FB7D6BCE8A2D511B88C00508B68C2081971E4@orsmsx102.jf.intel.com>
2001-09-28 23:09 ` Alan Cox
-- strict thread matches above, loose matches on Subject: below --
2001-09-28 22:47 Grover, Andrew
2001-09-29 1:10 ` Gerhard Mack
2001-09-26 18:24 Locking comment on shrink_caches() Linus Torvalds
2001-09-26 18:40 ` Dave Jones
2001-09-26 19:12 ` Linus Torvalds
2001-09-27 12:22 ` CPU frequency shifting "problems" Padraig Brady
2001-09-27 12:44 ` Dave Jones
2001-09-27 23:23 ` Linus Torvalds
2001-09-28 0:55 ` Alan Cox
2001-09-28 2:12 ` Stefan Smietanowski
2001-09-28 8:55 ` Jamie Lokier
2001-09-28 16:11 ` Linus Torvalds
2001-09-28 20:29 ` Eric W. Biederman
2001-09-28 22:24 ` Jamie Lokier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®