[vbox-dev] /proc/cpuinfo in VirtualBox
Klaus Espenlaub
klaus.espenlaub at oracle.com
Wed Sep 15 08:50:18 GMT 2010
On 11.09.2010 07:01, Stéphane Charette wrote:
> I have 2 virtualbox guest instances where the /proc/cpuinfo reports the
> CPU as 0.0 MHz. This is causing problems for an app that is parsing the
> /proc/cpuinfo and getting hung up on that value. (It actually is
> causing a divide-by-zero since the app is using that value to do some
> calculations.)
>
> The host is Ubuntu 10.04 64-bit, and both of the guests are also Ubuntu
> 10.04 64-bit. I'm using VB v3.2.8r64453.
>
> Is this normal, or should there be a value in that field? I understand
> how when virtualized the cpu speed is a loose number, and if a system is
> idle it does't get any physical CPU cycles. But I'm wondering if there
> should still be something in that field, or whether this app needs to
> get the cpu speed from some other source to make in work in VirtualBox.
I assume Linux reads this information from some CPU MSR, and VirtualBox
deliberately sets only a selected number of MSRs - essentially the bare
minimum. All others return 0.
From my point of view the fact that an app misbehaves if this
information isn't present is a bug in the application. I really wonder
what legitimate use it can make of the CPU clock frequency (especially
when taking it from /proc/cpuinfo, which cannot possibly be 100%
accurate given how fast today's CPUs change clock frequencies for power
management reasons).
> See here for an example output from the first guest. The 2nd guest is
> identical with the exception of a slightly higher bogomips:
>
> stephane at vm-1:~$ uname -a
> Linux as1k-vm-33 2.6.32-24-server #39-Ubuntu SMP Wed Jul 28 06:21:40 UTC
> 2010 x86_64 GNU/Linux
> stephane at vm-1:~$ cat /proc/cpuinfo
> processor : 0
> vendor_id : GenuineIntel
> cpu family : 6
> model : 15
> model name : Intel(R) Core(TM)2 Duo CPU T7500 @ 2.20GHz
> stepping : 10
> cpu MHz : 0.000
[...]
> Thanks for any help you can offer.
I've tried this with a "Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz"
and a Linux 2.6.28.4 kernel (VT-x enabled for the VM), and it apparently
measures the CPU frequency somehow. For a single-core VM the value was
very accurate (2400.653), and for a quad-core VM the value it was about
50% too high: 3231.627. However in all cases I had a non-zero "cpu MHz"
value.
Not sure what that says about my MSR theory above. Linux kernels change
all the time, sometimes in surprising ways...
Klaus
> Stéphane Charette
>
>
>
> _______________________________________________
> vbox-dev mailing list
> vbox-dev at virtualbox.org
> http://vbox.innotek.de/mailman/listinfo/vbox-dev
More information about the vbox-dev
mailing list