I have a program that provides benchmarks, but its OS agnostic and does not know how to read CPU frequencies. The test program is driven through a script. If I provide the CPU frequency, then the program can calculate throughput of operations.
I thought I would provide the current CPU frequency (for the most accurate reading), but it appears the value is read-only for root and no access for others:
$ ls -Al /sys/devices/system/cpu/cpu0/cpufreq/
total 0
-r--r--r-- 1 root root 4096 Jan 27 23:19 affected_cpus
-r-------- 1 root root 4096 Jan 27 23:19 cpuinfo_cur_freq
-r--r--r-- 1 root root 4096 Jan 27 23:19 cpuinfo_max_freq
-r--r--r-- 1 root root 4096 Jan 27 23:19 cpuinfo_min_freq
...
-rw-r--r-- 1 root root 4096 Jan 27 23:19 scaling_max_freq
-rw-r--r-- 1 root root 4096 Jan 27 23:19 scaling_min_freq
-rw-r--r-- 1 root root 4096 Jan 27 23:19 scaling_setspeed
As ls -l
shows, cpuinfo_cur_freq
is the only object with that particular ACL. The other entries are mostly 0444
(0644
for some).
Why is current CPU frequency read-only for root and no access for others?
/sys/devices/system/cpu/cpu0/online
exist? if not, then your system doesn't support certain actions on that particular core (some architectures have dependencies on cpu0, so you cannot take it offline, etc). see the yellowbox warning here: cyberciti.biz/faq/debian-rhel-centos-redhat-suse-hotplug-cpu/… . If the permissions are more lenient on cpu1 then it is very likely that the issue is specific to that core.cat: /sys/devices/system/cpu/cpu0/online: No such file or directory
.sudo chmod a+r
changes permissions ok. Also seeing scaling_cur_freq values randomly bouncing around -+10% or more, while cpuinfo_cur_freq & /proc/cpuinfo & cpufreq_info are all steady & apparently correct.