Port-amd64 archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Wrong CPU frequencies reported by cpu_get_tsc_freq() ?
On 26 Jul, 2015, at 04:24 , Nicolas Joly <njoly%pasteur.fr@localhost> wrote:
> njoly@raya [~]> dmesg | grep FREQ
> cpu0: cpu_get_tsc_freq: FREQ 2195181560
> cpu1: cpu_hatch: FREQ 2195181560
> cpu2: cpu_hatch: FREQ 2195181560
> cpu3: cpu_hatch: FREQ 2195181560
> cpu4: cpu_hatch: FREQ 2195181560
> cpu5: cpu_hatch: FREQ 2195181560
> cpu6: cpu_hatch: FREQ 2195181560
> cpu7: cpu_hatch: FREQ 2195181560
> cpu2: cpu_get_tsc_freq: FREQ 2296213330
> cpu3: cpu_get_tsc_freq: FREQ 2195418940
> cpu4: cpu_get_tsc_freq: FREQ 2341319790
> cpu5: cpu_get_tsc_freq: FREQ 2266578890
> cpu6: cpu_get_tsc_freq: FREQ 3400965260
> cpu1: cpu_get_tsc_freq: FREQ 4720276290
> cpu7: cpu_get_tsc_freq: FREQ 2195227320
>
> Any idea what's going on ?
I'm pretty sure it is telling you that i8254_delay() becomes grossly
inaccurate when all but one of the CPUs in the system sit in the tight
loop in there simultaneously reading the same timer register over and over.
On my system, where the TSC increments at a constant 3500 MHz on all
CPUs, I have right now:
$ grep MHz /proc/cpuinfo
cpu MHz : 3500.16
cpu MHz : 3576.35
cpu MHz : 4427.48
cpu MHz : 3571.25
cpu MHz : 3624.81
cpu MHz : 3721.51
cpu MHz : 4144.94
cpu MHz : 3697.54
cpu MHz : 6674.61
cpu MHz : 3684.25
cpu MHz : 3535.75
cpu MHz : 3866.39
The more interesting question why it bothers making per-cpu measurements
at all? The kernel uses the TSC as a clock source only when it thinks
that the TSC's frequency is constant with time and its rate of advance is
identical on all processors. The system that produced the above list
of frequencies is also using the TSC as its system clock, so clearly
the system believes the TSC frequency is identical for all CPUs and
hence that most of the frequencies it went to the trouble of measuring
above are bogus. Nothing I can find uses any of those numbers other than
the first.
At one point I thought about removing the calls to cpu_get_tsc_freq()
in cpu_hatch(), but since they were explicitly added in there in
revision 1.7 of sys/arch/x86/x86/cpu.c it seems like there must have
been some purpose for the addition. Since the per-cpu frequency
measurements couldn't have been the reason I guessed the 100 ms
delay that is a side effect of the measurement might be doing something
useful, and removing the calls might require figuring out what that is.
Dennis Ferguson
Home |
Main Index |
Thread Index |
Old Index