Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu.Info() returns error when clock speed not available #282

Closed
tmm1 opened this issue Nov 18, 2016 · 8 comments · Fixed by #335
Closed

cpu.Info() returns error when clock speed not available #282

tmm1 opened this issue Nov 18, 2016 · 8 comments · Fixed by #335

Comments

@tmm1
Copy link
Contributor

tmm1 commented Nov 18, 2016

I'm getting the following error from cpu.Info():

open /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq: no such file or directory

on an ARM device that has no clock speed entry in/proc/cpuinfo:

$ cat /proc/cpuinfo
Processor	: Marvell PJ4Bv7 Processor rev 2 (v7l)
processor	: 0
BogoMIPS	: 1332.01

processor	: 1
BogoMIPS	: 1332.01

Features	: swp half thumb fastmult vfp edsp vfpv3 tls
CPU implementer	: 0x56
CPU architecture: 7
CPU variant	: 0x2
CPU part	: 0x584
CPU revision	: 2

Hardware	: Marvell Armada XP Development Board
Revision	: 0000
Serial	: 0000000000000000

and no cpufreq node available under /sys/.../cpu:

$ ls /sys/devices/system/cpu/cpu0/
cpuidle online topology

In this case, I think it would be useful to return the known information about the CPUs, even if the Mhz field is set to 0.

@tmm1
Copy link
Contributor Author

tmm1 commented Nov 18, 2016

This specific device is a Synology branded RS815 NAS. The admin web UI for the device shows a clock speed of 1.33ghz, so perhaps gopsutil should fallback to the BogoMIPS entry in /proc/cpuinfo when no other clock speed information is available?

@tmm1
Copy link
Contributor Author

tmm1 commented Feb 22, 2017

FYI I found another device running linux 3.2.26 where /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq is reported in Hz instead of KHz.

@schmichael
Copy link
Contributor

From the little bit of work I've done on ARM it seems that missing cpufreq is common and likely never going to be fully covered.

So on systems lacking cpufreq it might be worth falling back to dmidecode -s processor-frequency which works in the two test cases I have available.

There are 3 significant downsides to this:

  1. dmidecode is rarely if ever installed by default on systems
  2. dmidecode seems to require root (or at least read access to pseudo-files that are only readable by root on my system)
  3. dmidecode's man page has a big warning about how untrustworthy it is:

More often than not, information contained in the DMI tables is inaccurate, incomplete or simply wrong.

Still seems worth trying in a fallback.

@shirou
Copy link
Owner

shirou commented Mar 20, 2017

@tmm1 Sorry for very very late response. I created #335 which just ignore error. Does this resolve your problem?

@schmichael Thank you for researching. I agree your downside view about dmidecode, especially it needs root.

@schmichael
Copy link
Contributor

@shirou Seems reasonable to me. Could I open a new issue (and maybe a PR someday soon) for adding a dmidecode fallback? I know it's of extremely limited usefulness, so feel free to say "no thanks."

@tmm1
Copy link
Contributor Author

tmm1 commented Mar 20, 2017

@shirou Thanks, that resolves my issue. I also have some other changes locally which you might find useful:

fancybits/gopsutil@8abfc8b parse bogomips values
fancybits/gopsutil@d3bf1ea use processor name as model fallback
fancybits/gopsutil@70e6762 handle older kernels which list cpu speed in hz

@schmichael Thanks for the dmidecode tip. Unfortunately none of the ARM systems which I have seen have that tool installed, and most don't allow me to run things as root. So this particular workaround would not be very useful to me, atleast.

@shirou
Copy link
Owner

shirou commented Mar 23, 2017

@tmm1 sorry, when I close #335, also closed this issue.
And thank you for your commit. according to your valuable commits, I did two commit. I didn't include parse bogomips values commit, because Bogomips is too linux specific.

3499dec
a63f1ae
I have wanted to make a PR in order to note your name, but I failed push branch. very sad. sorry. But I really thank you for these.

@tmm1
Copy link
Contributor Author

tmm1 commented Mar 23, 2017

@shirou Thank you. No problem, I am glad they are included in master now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants