I'm using a Debian 8 amd64 machine for benchmarking. During experimentation, I would like the CPU to operate at a fixed frequency (preferably the maximum possible). This will rule out the CPU clock speed as a source of variation in the results.
After some reading, it seems that the correct thing to do is to change the CPU governor to performance
, which is described here in the Linux kernel documentation:
The CPUfreq governor "performance" sets the CPU statically to the highest frequency within the borders of scaling_min_freq and scaling_max_freq.
Sadly, further details about scaling_min_freq
and scaling_max_freq
are not supplied. Hopefully it should not matter, as the CPU frequency used is the maximum value of the interval.
So I've enabled this governor using cpufreq-set:
$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor performance performance performance performance
And for good measure, I also disabled turbo boost mode in the bios:
$ cat /sys/devices/system/cpu/intel_pstate/no_turbo 1
Based on the above description of the performance governor, I would expect no fluctuation in the CPU clock speed. Yet if I repeatedly run cpufreq-info
, I see the clock speed fluctuating:
$ cpufreq-info | grep 'current CPU fr' current CPU frequency is 4.00 GHz. current CPU frequency is 3.99 GHz. current CPU frequency is 4.00 GHz. current CPU frequency is 4.00 GHz. $ cpufreq-info | grep 'current CPU fr' current CPU frequency is 4.00 GHz. current CPU frequency is 4.00 GHz. current CPU frequency is 4.00 GHz. current CPU frequency is 3.96 GHz. $ cpufreq-info | grep 'current CPU fr' current CPU frequency is 4.00 GHz. current CPU frequency is 4.00 GHz. current CPU frequency is 4.00 GHz. current CPU frequency is 3.94 GHz. $ cpufreq-info | grep 'current CPU fr' current CPU frequency is 4.01 GHz. current CPU frequency is 4.00 GHz. current CPU frequency is 4.00 GHz. current CPU frequency is 3.98 GHz.
Is this fluctuation due to hardware, the BIOS, the kernel, or some other factor? Is there a way to set the CPU frequency such that it doesn't fluctuate at all?