[RFC 0/1] ARM: print MHz in /proc/cpuinfo

Russell King - ARM Linux linux at armlinux.org.uk
Sun Jul 3 12:10:51 PDT 2016


On Sun, Jul 03, 2016 at 08:49:45PM +0200, Andrew Lunn wrote:
> On Sun, Jul 03, 2016 at 05:54:31PM +0100, Russell King - ARM Linux wrote:
> > Right, so having read all your email, there's no reason why we couldn't
> > just print:
> > 
> > cpu MHz  : 99999999.999
> 
> Since it is a float, how about using the value NaN? I think that
> nicely summaries it is a useless value.

;)

> However, i agree, we first need a technical justification for needing
> a value at all.

The only case where we've had a userspace "failure" is with the Jack
audio server, which wanted to parse the cpu MHz value to use it in
this calculation:

     static jack_time_t jack_get_microseconds_from_cycles (void) {
      return get_cycles() / __jack_cpu_mhz;
     }

Now, let's say that we did provide the CPU MHz, so __jack_cpu_mhz
reflects this value.  Great, Jack can initialise this value, but
there's two fundamental problems:

1. Jack is not aware of cpufreq, so the CPU MHz value it read at
   one point in time may not be the current CPU MHz - the CPU
   frequency can change at any moment depending on the governor's
   decisions.

2. get_cycles()... we have no userspace accessible CPU cycle counters
   on 32-bit ARM, which means knowing the CPU MHz for use like this
   gets you nowhere as get_cycles() can't return the number of CPU
   cycles.  It certainly can't return a number based on the CPU MHz.

Hence why this change to jack was the only sane thing to do:

https://github.com/jackaudio/jack2/commit/d425d8035b761b4a362c538c41eca874ff4

This wasn't even a kernel regression - the kernel never provided the
value on ARM, and in many cases the kernel doesn't know the right
value (as I've said previously in this thread.)

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.



More information about the linux-arm-kernel mailing list