public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Question: monolitic_clock, timer_{tsc,hpet} and CPUFREQ
@ 2003-09-05  3:14 Dmitry Torokhov
  2003-09-05  8:13 ` john stultz
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Torokhov @ 2003-09-05  3:14 UTC (permalink / raw)
  To: linux-kernel

I noticed that although timer_tsc registers cpufreq notifier to detect
frequency changes and adjust cpu_khz it does not set cyc2ns_scale. Is
monotonic clocks supposed to be also accurate?

Will something like this suffice for timer_tsc (compiled, not yet booted):

--- 2.6.0-test4/arch/i386/kernel/timers/timer_tsc.c	2003-08-26 21:56:19.000000000 -0500
+++ linux-2.6.0-test4/arch/i386/kernel/timers/timer_tsc.c	2003-09-04 22:08:27.000000000 -0500
@@ -315,6 +315,7 @@
 		if (use_tsc) {
 			fast_gettimeoffset_quotient = cpufreq_scale(fast_gettimeoffset_ref, freq->new, ref_freq);
 			cpu_khz = cpufreq_scale(cpu_khz_ref, ref_freq, freq->new);
+			set_cyc2ns_scale(cpu_khz/1000);
 		}
 #endif
 	}

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

* Re: Question: monolitic_clock, timer_{tsc,hpet} and CPUFREQ
  2003-09-05  3:14 Question: monolitic_clock, timer_{tsc,hpet} and CPUFREQ Dmitry Torokhov
@ 2003-09-05  8:13 ` john stultz
  2003-09-07 18:57   ` Dominik Brodowski
  0 siblings, 1 reply; 4+ messages in thread
From: john stultz @ 2003-09-05  8:13 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: lkml, Andrew Morton

On Thu, 2003-09-04 at 20:14, Dmitry Torokhov wrote:
> I noticed that although timer_tsc registers cpufreq notifier to detect
> frequency changes and adjust cpu_khz it does not set cyc2ns_scale. Is
> monotonic clocks supposed to be also accurate?

You are correct, without adjusting the cyc2ns_scale value
monotonic_clock() will not be accurate on freq changing hardware.  


> Will something like this suffice for timer_tsc (compiled, not yet booted):
> 
> --- 2.6.0-test4/arch/i386/kernel/timers/timer_tsc.c	2003-08-26 21:56:19.000000000 -0500
> +++ linux-2.6.0-test4/arch/i386/kernel/timers/timer_tsc.c	2003-09-04 22:08:27.000000000 -0500
> @@ -315,6 +315,7 @@
>  		if (use_tsc) {
>  			fast_gettimeoffset_quotient = cpufreq_scale(fast_gettimeoffset_ref, freq->new, ref_freq);
>  			cpu_khz = cpufreq_scale(cpu_khz_ref, ref_freq, freq->new);
> +			set_cyc2ns_scale(cpu_khz/1000);
>  		}
>  #endif
>  	}

Looks fine to me. Although I don't have any cpufreq enabled hardware, so
I'm unable to test this (main cause I never added it myself). 

thanks
-john



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

* Re: Question: monolitic_clock, timer_{tsc,hpet} and CPUFREQ
  2003-09-05  8:13 ` john stultz
@ 2003-09-07 18:57   ` Dominik Brodowski
  2003-09-08 17:30     ` john stultz
  0 siblings, 1 reply; 4+ messages in thread
From: Dominik Brodowski @ 2003-09-07 18:57 UTC (permalink / raw)
  To: john stultz; +Cc: Dmitry Torokhov, lkml, Andrew Morton

On Fri, Sep 05, 2003 at 01:13:14AM -0700, john stultz wrote:
> On Thu, 2003-09-04 at 20:14, Dmitry Torokhov wrote:
> > I noticed that although timer_tsc registers cpufreq notifier to detect
> > frequency changes and adjust cpu_khz it does not set cyc2ns_scale. Is
> > monotonic clocks supposed to be also accurate?
> 
> You are correct, without adjusting the cyc2ns_scale value
> monotonic_clock() will not be accurate on freq changing hardware.  

Seems to be a necessary update. Thanks for noting this.


> Looks fine to me. Although I don't have any cpufreq enabled hardware, so
> I'm unable to test this (main cause I never added it myself). 

/me has cpufreq enabled hardware -- but how can I accurately debug
monotonic_ticks()?

	Dominik

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

* Re: Question: monolitic_clock, timer_{tsc,hpet} and CPUFREQ
  2003-09-07 18:57   ` Dominik Brodowski
@ 2003-09-08 17:30     ` john stultz
  0 siblings, 0 replies; 4+ messages in thread
From: john stultz @ 2003-09-08 17:30 UTC (permalink / raw)
  To: Dominik Brodowski; +Cc: Dmitry Torokhov, lkml, Andrew Morton

On Sun, 2003-09-07 at 11:57, Dominik Brodowski wrote:
> On Fri, Sep 05, 2003 at 01:13:14AM -0700, john stultz wrote:
> > Looks fine to me. Although I don't have any cpufreq enabled hardware, so
> > I'm unable to test this (main cause I never added it myself). 
> 
> /me has cpufreq enabled hardware -- but how can I accurately debug
> monotonic_ticks()?

Usually I hack up the hangcheck-timer module to be more verbose to
verify monotonic_clock() works. Also Oracle has a hangcheck-delay module
you can use to hang the system for a defined length of time. You can
then check the delta between gettimeofday and monotonic_clock to verify
its working as it should.

thanks
-john





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

end of thread, other threads:[~2003-09-08 17:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-05  3:14 Question: monolitic_clock, timer_{tsc,hpet} and CPUFREQ Dmitry Torokhov
2003-09-05  8:13 ` john stultz
2003-09-07 18:57   ` Dominik Brodowski
2003-09-08 17:30     ` john stultz

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