Curiosity of cpu running frequency output from sysctl -a vs sysctl dev.cpu.$d.freq

Hi guys,
I am curious if anyone can help to explain the dscrepancies of sysctl output of cpu frequency whenever I tried to run the sysctl -a |grep freq vs sysctl -a dev.cpu.$d.freq.

I could not find any related info from the driver man page or internet highlight the causes of the differences.

I am using Lenovo laptop X1-carbon 20kk with Intel CPU i7-8650U that support "Intel Speed Shfit".

I have disabled powerd to let hwpstate_driver to auto adjust the cpu frequency and power usage. It is newly fresh install FreeBSD 14.3.



# sysctl -a|grep freq\:
------
dev.cpu.7.freq: 3620
dev.cpu.5.freq: 3920
dev.cpu.3.freq: 3922
dev.cpu.1.freq: 3922
dev.cpu.6.freq: 3922
dev.cpu.4.freq: 3622
dev.cpu.2.freq: 3643
dev.cpu.0.freq: 3922


but when I ran each of the oid, the output seems difference.

# sysctl dev.cpu.0.freq dev.cpu.1.freq dev.cpu.2.freq dev.cpu.3.freq dev.cpu.4.freq dev.cpu.5.freq dev.cpu.6.freq dev.cpu.7.freq
---------------------
dev.cpu.0.freq: 802
dev.cpu.1.freq: 802
dev.cpu.2.freq: 802
dev.cpu.3.freq: 802
dev.cpu.4.freq: 803
dev.cpu.5.freq: 802
dev.cpu.6.freq: 803
dev.cpu.7.freq: 802
 
This is expected. sysctl -a | grep freq reads the complete sysctl database and searches all occurences of the regular expression "freq". This is "heavy" work for the CPU. In contrast, sysctl dev.cpu.0.freq is a "simple" lookup.

You are now in the realm of quantum physics: observing the CPU frequency actually changes the CPU frequency :-)
 
Back
Top