public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* gettimeofday() moving backwards
@ 2002-12-18 19:53 Paul Richards
       [not found] ` <1040241199.3e00d22fe594b-Y3tGgqFSo3OFxr2TtlUqVg@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Paul Richards @ 2002-12-18 19:53 UTC (permalink / raw)
  To: acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Hi,
I am using linux kernel v2.4.20 with ACPI patch dated 2002-12-05.

I have noticed that if my processor changes state (800Mhz up to 1200Mhz say)
then gettimeofday() behaves weirdly.  It runs smoothly but every now and again
(on the order of 10 times a second) it makes a correction.  If I have gone from
800Mhz to 1200Mhz then the correction is backwards, otherwise it makes a forward
jump..

I presume that this is because the kernel hasn't noticed that the cpu state has
changed and hasn't corrected the variables that control how the time is
calculated using the tsc.

Is there a patch for this..?  It doesn't sound like *too* big a thing.. ie just
recalculate a cpl of timing variables when the cpu state changes.. but ofc I
don't know the details :)

-- 
Paul Richards



-------------------------------------------------------
This SF.NET email is sponsored by: Order your Holiday Geek Presents Now!
Green Lasers, Hip Geek T-Shirts, Remote Control Tanks, Caffeinated Soap,
MP3 Players,  XBox Games,  Flying Saucers,  WebCams,  Smart Putty.
T H I N K G E E K . C O M       http://www.thinkgeek.com/sf/

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

* RE: gettimeofday() moving backwards
@ 2002-12-18 21:23 Grover, Andrew
       [not found] ` <EDC461A30AC4D511ADE10002A5072CAD04C7A5BB-OU+JdkIUtvd9zuciVAfUoVDQ4js95KgL@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Grover, Andrew @ 2002-12-18 21:23 UTC (permalink / raw)
  To: 'Paul Richards',
	acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

> From: Paul Richards [mailto:p.a.richards-Y3tGgqFSo3OFxr2TtlUqVg@public.gmane.org] 
> I am using linux kernel v2.4.20 with ACPI patch dated 2002-12-05.
> 
> I have noticed that if my processor changes state (800Mhz up 
> to 1200Mhz say)
> then gettimeofday() behaves weirdly.  It runs smoothly but 
> every now and again
> (on the order of 10 times a second) it makes a correction.  
> If I have gone from
> 800Mhz to 1200Mhz then the correction is backwards, otherwise 
> it makes a forward
> jump..

Hmm, can you mention this on the cpufreq mailing list?
cpufreq-1walMZg8u8rXmaaqVzeoHQ@public.gmane.org .

Thanks -- Regards -- Andy


-------------------------------------------------------
This SF.NET email is sponsored by: Order your Holiday Geek Presents Now!
Green Lasers, Hip Geek T-Shirts, Remote Control Tanks, Caffeinated Soap,
MP3 Players,  XBox Games,  Flying Saucers,  WebCams,  Smart Putty.
T H I N K G E E K . C O M       http://www.thinkgeek.com/sf/

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

* Re: gettimeofday() moving backwards
       [not found] ` <EDC461A30AC4D511ADE10002A5072CAD04C7A5BB-OU+JdkIUtvd9zuciVAfUoVDQ4js95KgL@public.gmane.org>
@ 2002-12-18 22:40   ` Dominik Brodowski
  0 siblings, 0 replies; 6+ messages in thread
From: Dominik Brodowski @ 2002-12-18 22:40 UTC (permalink / raw)
  To: Grover, Andrew
  Cc: 'Paul Richards',
	acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

On Wed, Dec 18, 2002 at 01:23:57PM -0800, Grover, Andrew wrote:
> > From: Paul Richards [mailto:p.a.richards-Y3tGgqFSo3OFxr2TtlUqVg@public.gmane.org] 
> > I am using linux kernel v2.4.20 with ACPI patch dated 2002-12-05.
> > 
> > I have noticed that if my processor changes state (800Mhz up 
> > to 1200Mhz say)
> > then gettimeofday() behaves weirdly.  It runs smoothly but 
> > every now and again
> > (on the order of 10 times a second) it makes a correction.  
> > If I have gone from
> > 800Mhz to 1200Mhz then the correction is backwards, otherwise 
> > it makes a forward
> > jump..
> 
> Hmm, can you mention this on the cpufreq mailing list?
> cpufreq-1walMZg8u8rXmaaqVzeoHQ@public.gmane.org .

In kernel 2.5.5x, gettimeofday() should work fine: ACPI uses the cpufreq
infrastructure, which adds -among other things- a hunk in
arch/i386/timer/tsc.c which updates some values on frequency transitions.
(see http://www.brodo.de/cpufreq/ for details on cpufreq).

As cpufreq isn't included in 2.4. kernels, and likely never will, the 2.4.
gettimeofday() call does cause strange results in 2.4.

	Dominik




-------------------------------------------------------
This SF.NET email is sponsored by: Order your Holiday Geek Presents Now!
Green Lasers, Hip Geek T-Shirts, Remote Control Tanks, Caffeinated Soap,
MP3 Players,  XBox Games,  Flying Saucers,  WebCams,  Smart Putty.
T H I N K G E E K . C O M       http://www.thinkgeek.com/sf/

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

* Re: gettimeofday() moving backwards
       [not found] ` <1040241199.3e00d22fe594b-Y3tGgqFSo3OFxr2TtlUqVg@public.gmane.org>
@ 2002-12-19  0:09   ` Pavel Machek
  0 siblings, 0 replies; 6+ messages in thread
From: Pavel Machek @ 2002-12-19  0:09 UTC (permalink / raw)
  To: Paul Richards; +Cc: acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Hi!

> I am using linux kernel v2.4.20 with ACPI patch dated 2002-12-05.
> 
> I have noticed that if my processor changes state (800Mhz up to 1200Mhz say)
> then gettimeofday() behaves weirdly.  It runs smoothly but every now and again
> (on the order of 10 times a second) it makes a correction.  If I have gone from
> 800Mhz to 1200Mhz then the correction is backwards, otherwise it makes a forward
> jump..
> 
> I presume that this is because the kernel hasn't noticed that the cpu state has
> changed and hasn't corrected the variables that control how the time is
> calculated using the tsc.
> 
> Is there a patch for this..?  It doesn't sound like *too* big a thing.. ie just
> recalculate a cpl of timing variables when the cpu state changes.. but ofc I
> don't know the details :)

Its actually pretty hard to do... Because at least at APM cpu can
change clock any time. And recalibration of delay loop takes quite
long... Still it might be good idea to recalibrate after clock change.

									Pavel
-- 
Worst form of spam? Adding advertisment signatures ala sourceforge.net.
What goes next? Inserting advertisment *into* email?


-------------------------------------------------------
This SF.NET email is sponsored by: Geek Gift Procrastinating?
Get the perfect geek gift now!  Before the Holidays pass you by.
T H I N K G E E K . C O M      http://www.thinkgeek.com/sf/

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

* Re: gettimeofday() moving backwards
@ 2002-12-19 10:01 Herbert Nachtnebel
       [not found] ` <B900970C7DD9474C972986EB3EC7C58F0D404F-PWLG29+z7hEKeIAE67mlpo2P0GrZ+RbP@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Herbert Nachtnebel @ 2002-12-19 10:01 UTC (permalink / raw)
  To: acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
  Cc: p.a.richards-Y3tGgqFSo3OFxr2TtlUqVg

In 2.4 there exists CONFIG_ASYNC_TSC to help with such things. 
I never tried it, but it should change the gettimeofday() 
system call to not use the TSC for time calculations. This 
results in a really slow system call since now it uses the PIT
for every access, but the system time should be smoothly again.

Regards, Herbert.

-----Ursprüngliche Nachricht-----
Von: Dominik Brodowski [mailto:linux-JhLEnvuH02M@public.gmane.org]
Gesendet: Mittwoch, 18. Dezember 2002 23:41
An: Grover, Andrew
Cc: 'Paul Richards'; acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Betreff: Re: [ACPI] gettimeofday() moving backwards


On Wed, Dec 18, 2002 at 01:23:57PM -0800, Grover, Andrew wrote:
> > From: Paul Richards [mailto:p.a.richards-Y3tGgqFSo3OFxr2TtlUqVg@public.gmane.org] 
> > I am using linux kernel v2.4.20 with ACPI patch dated 2002-12-05.
> > 
> > I have noticed that if my processor changes state (800Mhz up 
> > to 1200Mhz say)
> > then gettimeofday() behaves weirdly.  It runs smoothly but 
> > every now and again
> > (on the order of 10 times a second) it makes a correction.  
> > If I have gone from
> > 800Mhz to 1200Mhz then the correction is backwards, otherwise 
> > it makes a forward
> > jump..
> 
> Hmm, can you mention this on the cpufreq mailing list?
> cpufreq-1walMZg8u8rXmaaqVzeoHQ@public.gmane.org .

In kernel 2.5.5x, gettimeofday() should work fine: ACPI uses the cpufreq
infrastructure, which adds -among other things- a hunk in
arch/i386/timer/tsc.c which updates some values on frequency transitions.
(see http://www.brodo.de/cpufreq/ for details on cpufreq).

As cpufreq isn't included in 2.4. kernels, and likely never will, the 2.4.
gettimeofday() call does cause strange results in 2.4.

	Dominik




-------------------------------------------------------
This SF.NET email is sponsored by: Order your Holiday Geek Presents Now!
Green Lasers, Hip Geek T-Shirts, Remote Control Tanks, Caffeinated Soap,
MP3 Players,  XBox Games,  Flying Saucers,  WebCams,  Smart Putty.
T H I N K G E E K . C O M       http://www.thinkgeek.com/sf/
_______________________________________________
Acpi-devel mailing list
Acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/acpi-devel


-------------------------------------------------------
This SF.NET email is sponsored by: Geek Gift Procrastinating?
Get the perfect geek gift now!  Before the Holidays pass you by.
T H I N K G E E K . C O M      http://www.thinkgeek.com/sf/

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

* Re: gettimeofday() moving backwards
       [not found] ` <B900970C7DD9474C972986EB3EC7C58F0D404F-PWLG29+z7hEKeIAE67mlpo2P0GrZ+RbP@public.gmane.org>
@ 2002-12-19 11:39   ` Ducrot Bruno
  0 siblings, 0 replies; 6+ messages in thread
From: Ducrot Bruno @ 2002-12-19 11:39 UTC (permalink / raw)
  To: Herbert Nachtnebel
  Cc: acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	p.a.richards-Y3tGgqFSo3OFxr2TtlUqVg

On Thu, Dec 19, 2002 at 11:01:22AM +0100, Herbert Nachtnebel wrote:
> In 2.4 there exists CONFIG_ASYNC_TSC to help with such things. 

Warn.  Some libc are broken, and will hang.  Be sure to update.
And mplayer when using win32 dll will segfault, also..

> I never tried it, but it should change the gettimeofday() 
> system call to not use the TSC for time calculations. This 
> results in a really slow system call since now it uses the PIT
> for every access, but the system time should be smoothly again.

ACPI timer could help, I guess.


-- 
Ducrot Bruno

--  Which is worse:  ignorance or apathy?
--  Don't know.  Don't care.


-------------------------------------------------------
This SF.NET email is sponsored by: Geek Gift Procrastinating?
Get the perfect geek gift now!  Before the Holidays pass you by.
T H I N K G E E K . C O M      http://www.thinkgeek.com/sf/

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

end of thread, other threads:[~2002-12-19 11:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-18 21:23 gettimeofday() moving backwards Grover, Andrew
     [not found] ` <EDC461A30AC4D511ADE10002A5072CAD04C7A5BB-OU+JdkIUtvd9zuciVAfUoVDQ4js95KgL@public.gmane.org>
2002-12-18 22:40   ` Dominik Brodowski
  -- strict thread matches above, loose matches on Subject: below --
2002-12-19 10:01 Herbert Nachtnebel
     [not found] ` <B900970C7DD9474C972986EB3EC7C58F0D404F-PWLG29+z7hEKeIAE67mlpo2P0GrZ+RbP@public.gmane.org>
2002-12-19 11:39   ` Ducrot Bruno
2002-12-18 19:53 Paul Richards
     [not found] ` <1040241199.3e00d22fe594b-Y3tGgqFSo3OFxr2TtlUqVg@public.gmane.org>
2002-12-19  0:09   ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox