mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* How does Linux measure CPU frequency?
@ 2008-04-06 16:30 Jack Harvard
  2008-04-06 16:37 ` dean gaudet
  0 siblings, 1 reply; 3+ messages in thread
From: Jack Harvard @ 2008-04-06 16:30 UTC (permalink / raw)
  To: linux-kernel

Hi,

I want to find out how Linux calibrates the frequency of CPUs, and
want to compare with the way how lmbench measures processor frequency.
I had a thorough google search of this topic but didn't get too much
useful results.

Thanks a lot,
Jack

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How does Linux measure CPU frequency?
  2008-04-06 16:30 How does Linux measure CPU frequency? Jack Harvard
@ 2008-04-06 16:37 ` dean gaudet
  2008-04-07 13:16   ` Jack Harvard
  0 siblings, 1 reply; 3+ messages in thread
From: dean gaudet @ 2008-04-06 16:37 UTC (permalink / raw)
  To: Jack Harvard; +Cc: linux-kernel

linux knows what style of cpu it is running on and uses non-portable 
techniques to read the time-stamp counter.

lmbench uses some really nice tricks to estimate the cpu frequency in a 
portable manner... all it requires is that at least two of the N code 
sequences it times take a co-prime number of cycles.

-dean

On Sun, 6 Apr 2008, Jack Harvard wrote:

> Hi,
> 
> I want to find out how Linux calibrates the frequency of CPUs, and
> want to compare with the way how lmbench measures processor frequency.
> I had a thorough google search of this topic but didn't get too much
> useful results.
> 
> Thanks a lot,
> Jack
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How does Linux measure CPU frequency?
  2008-04-06 16:37 ` dean gaudet
@ 2008-04-07 13:16   ` Jack Harvard
  0 siblings, 0 replies; 3+ messages in thread
From: Jack Harvard @ 2008-04-07 13:16 UTC (permalink / raw)
  To: dean gaudet; +Cc: linux-kernel

On Sun, Apr 6, 2008 at 5:37 PM, dean gaudet <dean@arctic.org> wrote:
> linux knows what style of cpu it is running on and uses non-portable
>  techniques to read the time-stamp counter.
>
>  lmbench uses some really nice tricks to estimate the cpu frequency in a
>  portable manner... all it requires is that at least two of the N code
>  sequences it times take a co-prime number of cycles.

 The MHZ measures time by gettimeofday( ), and
 this assumes that the function gettimeofday( ) returns the actual
 real-world time elapse in microseconds, instead of some scaled time.
 What I mean here by scaled time is, Linux kernel keeps time by reading
 a counter which is increased by one when an interrupt is generated
 from a physical timer, and Linux defines the default HZ = 100 which
 means an interrupt is generated every 10 milliseconds, but without
 knowing which clock the physical timer is clocked at it is impossible
 to correctly measure 10 milliseconds by the timer. Therefore, the
 results from MHZ could be scaled? please correct me if I am wrong.

And, I believe this is the same case for Linux TSC (time stamp
counter), as the time constant of ~50ms is also measured by a
programmable interval timer which can also be scaled.

>
>  -dean
>
>
>
>  On Sun, 6 Apr 2008, Jack Harvard wrote:
>
>  > Hi,
>  >
>  > I want to find out how Linux calibrates the frequency of CPUs, and
>  > want to compare with the way how lmbench measures processor frequency.
>  > I had a thorough google search of this topic but didn't get too much
>  > useful results.
>  >
>  > Thanks a lot,
>  > Jack
>  > --
>  > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>  > the body of a message to majordomo@vger.kernel.org
>  > More majordomo info at  http://vger.kernel.org/majordomo-info.html
>  > Please read the FAQ at  http://www.tux.org/lkml/
>  >
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-04-07 13:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-06 16:30 How does Linux measure CPU frequency? Jack Harvard
2008-04-06 16:37 ` dean gaudet
2008-04-07 13:16   ` Jack Harvard

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®