[libvirt] Fix wrong nodeinfo->mhz when cpufreq is enabled

Thomas Treutner thomas at scripty.at
Tue Feb 2 17:15:50 UTC 2010


Hi,

I've written a little patch to fix wrong nodeinfo->mhz when the Linux
kernel module cpufreq and a typical governor like ondemand are loaded.
nodeinfo->mhz is then too low as libvirt just reads /proc/cpuinfo,
entry "cpu MHz". This patch reads

        /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq

if existing and corrects nodeinfo->mhz if the value found is higher.
Using cpu0 is a crude hack but as discussed on IRC, considering different
governors/maximum frequencies per cpu/core would require changing the
nodeinfo struct, which would break the API.

Some more info: https://bugzilla.redhat.com/show_bug.cgi?id=559762

Please have a careful look at my patch, my last C is quite some time ago.
I tried to stick to linuxNodeInfoCPUPopulate, but f.e., checking for
"&& *p == '\0'" after virStrToLong_ui doesn't work and I'm wondering why
scaling_max_freq may not be terminated with by NUL? I also hope the file
handling is correct, but please have a look.

There is still some todo: Some logging would be helpful, maybe one of you
could point out which function best to use?

This is my first patch, so hopefully it follows in the next mail ;-)


kr,
tom




More information about the libvir-list mailing list