Try to read CPU clock from cpufreq/scaling_cur_freq instead of /proc/cpuinfo

Authored by fvogt on Oct 5 2017, 5:12 PM.



From kernel 4.13 on, /proc/cpuinfo always reports the static normative
CPU clock and not the current one. So try to read the frequency from
cpufreq and only fall back to cpuinfo it that fails.

BUG: 382561

Test Plan

Started ksysguard, frequency now changes. If the file is not
readable, the frequency is read from cpuinfo as expected.

Diff Detail

R106 KSysguard
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
fvogt created this revision.Oct 5 2017, 5:12 PM
Restricted Application added a project: Plasma. · View Herald TranscriptOct 5 2017, 5:12 PM
fvogt added a comment.Oct 5 2017, 5:39 PM

I could also open all sysfs files only once and then fseek+fscanf when the value is requested, but that would only exchange a continuous fopen+fclose with fseek+more complexity IMO.
I'm fine with both approaches, but I favor KISS here.

sebas accepted this revision.Oct 6 2017, 12:44 PM
This revision is now accepted and ready to land.Oct 6 2017, 12:44 PM
This revision was automatically updated to reflect the committed changes.
sitter added a subscriber: sitter.Nov 9 2017, 12:37 PM

Mh. Please make sure to merge into master as well next time ;)