4

I need to find out in my script if a (potentially legacy) CPU supports dynamic speed setting, and eventually get value of maximum and current speed. What makes it more complicated is that I need to support RHEL5 (kernel 2.6.18-371) as well, where tools like lscpu are not available, and also less common architectures like PowerPC or S390.

For example, I know that for x86 architectures, some features can be read from "flags" in /proc/cpuinfo, but how do I know what to search for?. Also on a ppc64 machine I have for testing, this flags field is missing, instead there is a similar looking field "features".

So what is the (most) universal approach? Is there a way that would work even on less common architectures like s390 or ppc?

What I tried (on Pentium III) was to just load all modules that have something to do with cpufreq (i.e. grepping through modules folder) and look if /sys/devices/system/cpu/cpu0/cpufreq exists after that. However, I wonder if this is all I can do before saying it's not supported.

Alois Mahdal
  • 4,330
  • 11
  • 40
  • 62
  • You can parse [some flags in `/proc/cpuinfo`](http://unix.stackexchange.com/questions/43539/what-do-the-flags-in-proc-cpuinfo-mean/43563#43563), but that's obviously architecture-dependent, and there are several different CPU features that allow a variable size and I don't know if they're all listed there on x86 (and they aren't on ARM). – Gilles 'SO- stop being evil' Jun 06 '14 at 00:30

1 Answers1

1

This should work on RHEL 5.3:

dmidecode --type processor

and look for Max Speed and Current Speed info

Joshua Huber
  • 728
  • 6
  • 16
  • I can't check on rhel5 right now, but on Fedora with i7, it does not work properly: it mentions only 1 CPU with current speed = maximum speed. cpufreq reports 4 different current/maximum pairs. – Alois Mahdal Jun 05 '14 at 17:52
  • ...also on rhel5 dmidecode is only available for Itanium or x86 processors, not PowerPC or s390 – Alois Mahdal Jun 05 '14 at 18:41