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.CpuInfo() return empty data on Raspberry Pi #88

Closed
ranjib opened this issue Oct 8, 2015 · 4 comments
Closed

cpu.CpuInfo() return empty data on Raspberry Pi #88

ranjib opened this issue Oct 8, 2015 · 4 comments

Comments

@ranjib
Copy link

ranjib commented Oct 8, 2015

cpu.CPUInfo() returns empty data on Raspberry Pi 2 (quadcore, ARM v7) running ubuntu 15.04 (kernel 3.17) . This is due to /proc/cpuinfo being differently formatted. Following is an example:

processor : 0
model name  : ARMv7 Processor rev 5 (v7l)
BogoMIPS  : 57.60
Features  : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part  : 0xc07
CPU revision  : 5

CPU frequency cant be obtained from /proc/cpuinfo on ARM. There are two ways to get this data:
a) Invoke lscpu and parse the resulting data
b) read /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq (one entry for each core)

I dont know whats the preferred way to implement this, @shirou if you can give some feedback, i'd be happy to implement this :-)
thanks for this awesome library

@shirou
Copy link
Owner

shirou commented Oct 8, 2015

Thank you for the report!
I confirmed about could not get CPUInfo on ARM v7, ubuntu 15.04 by using https://www.scaleway.com/.

I prefer more widely used way. I think your a) lscpu approach is major than b). I would appreciate you if you make some PR. Thank you.

@ranjib
Copy link
Author

ranjib commented Oct 8, 2015

@shirou awesome. i would love to contribute :-)
Question: lscpu output is fairly different than /proc/cpuinfo ,

  • it does not have things like flags, cpu family etc.
    • fields are inconsistent across arch. I'm posting examples of intel and arm lscpu data. e.g. CPU MHz has min & max fields on arm
    • lscpu data is aggregate output. i.e. unlike cpuinfo which has one entry per core, lscpu is summary of all cpu

I am thinking of several things, but not sure which one is best.

  • introduce a separate struct to expose lscpu info (consumer codes need to be updated)
  • interpret and build a array of CPUStats from lscpu data (not sure we'll get all logic right, or we;ll have all data.)
    comments?
    Intel lscpu output
  Architecture:          x86_64 
  CPU op-mode(s):        32-bit, 64-bit
  Byte Order:            Little Endian                                                                                                    
  CPU(s):                4                                                                                                                
  On-line CPU(s) list:   0-3                                                                                                              
  Thread(s) per core:    2                                                                                                                
  Core(s) per socket:    2                                                                                                                
  Socket(s):             1                                                                                                                
  NUMA node(s):          1
  Vendor ID:             GenuineIntel
  CPU family:            6
  Model:                 58
  Stepping:              9
  CPU MHz:               2932.519
  BogoMIPS:              4988.38
  Virtualization:        VT-x
  L1d cache:             32K                                                                                                              
  L1i cache:             32K                                                                                                              
  L2 cache:              256K                                                                                                             
  L3 cache:              4096K                                                                                                            
  NUMA node0 CPU(s):     0-3     

arm lscpu output



  Architecture:          armv7l                                                                                                           
  Byte Order:            Little Endian                                                                                                    
  CPU(s):                4                                                                                                                
  On-line CPU(s) list:   0-3                                                                                                              
  Thread(s) per core:    1                                                                                                                
  Core(s) per socket:    4                                                                                                                
  Socket(s):             1                                                                                                                
  Model name:            ARMv7 Processor rev 5 (v7l)                                                                                      
  CPU max MHz:           900.0000                                                                                                         
  CPU min MHz:           600.0000                   

@shirou
Copy link
Owner

shirou commented Oct 10, 2015

@ranjib Thank you for the information. On my understanding, only ARM can not get information from /proc/cpuinfo. So I think how about separating into two files cpu_linux.go and cpu_linux_arm.go such as

  • for amd, get from /proc/cpuinfo
  • for ARM, get from lscpu

Will that work?

@cbednarski
Copy link
Contributor

@shirou That sounds good to me! I am not familiar with arm on linux outside of Rasbpian but that's my primary use case for this feature. Let me know if you need help with this.

kardianos added a commit to kardianos/gopsutil that referenced this issue Oct 17, 2015
ARM CPUs don't include the same fields as  x86 and amd64 CPUs in
the /proc/cpuinfo list. Pull information from the /sys/...
device tree as well as updating when a CPU is done in cpuinfo.

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

No branches or pull requests

3 participants