Re: Question: monolitic_clock, timer_{tsc,hpet} and CPUFREQ

From: john stultz
Date: Fri Sep 05 2003 - 03:14:40 EST


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


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/