[libvirt] [PATCH 1/2] Get cpuMhz of virNodeGetInfo() from cpufreq/cpuinfo_max_freq, if exist

Minoru Usui usui at mxm.nes.nec.co.jp
Thu Feb 10 01:38:14 UTC 2011


Hi, Eric

On Tue, 1 Feb 2011 10:26:36 +0900
Minoru Usui <usui at mxm.nes.nec.co.jp> wrote:

> Hi, Eric
> 
> On Mon, 31 Jan 2011 15:46:39 -0700
> Eric Blake <eblake at redhat.com> wrote:
> 
> > On 01/27/2011 02:51 AM, Minoru Usui wrote:
> > > virNodeGetInfo() gets from
> > > /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq, first.
> > > 
> > > Signed-off-by: Minoru Usui <usui at mxm.nes.nec.co.jp>
> > 
> > I haven't looked closely at this series yet...
> > 
> > > +    /*
> > > +     * nodeinfo->mhz should return maximum frequency,
> > > +     * but "cpu MHz" of /proc/cpuinfo is scaled by power saving feature.
> > > +     * So it gets cpufreq/cpuinfo_max_freq, if possible.
> > > +     */
> > > +    ret = get_cpu_value(0, "cpufreq/cpuinfo_max_freq", true);
> > > +    if (ret < 0)
> > > +	return -1;
> > > +    else if (ret != 1) {
> > > +	/* convert unit */
> > > +	cpu_mhz = ret / 1000;
> > 
> > But which units is this converting between, and should it truncate or
> > round up?
> 
> I think it divide by 1000 is collect, because my machine returns below values.
> 
> -----------------------------------------------------------------
> # cat /sys/devices/system/cpu/cpu?/cpufreq/cpuinfo_max_freq 
> 2333331
> 2333331
> 2333331
> 2333331
> 2333331
> 2333331
> 2333331
> 2333331
>  
> # grep 'cpu MHz' /proc/cpuinfo
> cpu MHz         : 2333.331
> cpu MHz         : 2333.331
> cpu MHz         : 2333.331
> cpu MHz         : 2333.331
> cpu MHz         : 2333.331
> cpu MHz         : 2333.331
> cpu MHz         : 2333.331
> cpu MHz         : 2333.331
> -----------------------------------------------------------------
> 
> On the other hand, I don't have clear opinion about truncate or round up. 
> Present implementation of linuxNodeInfoCPUPopulate() selects truncate,
> so I implement to truncate logic.

Are my explanations enough?
If not or I'm misunderstanding something, please let me know.

-- 
Minoru Usui <usui at mxm.nes.nec.co.jp>




More information about the libvir-list mailing list