[libvirt] [PATCH] Get thread and socket information in virsh nodeinfo.
Eric Blake
eblake at redhat.com
Tue Mar 9 00:19:08 UTC 2010
On 03/05/2010 12:06 PM, Chris Lalancette wrote:
> +#define CPU_SYS_PATH "/sys/devices/system/cpu"
>
> + if (virAsprintf(&path, "%s/cpu%d/topology/thread_siblings", CPU_SYS_PATH,
> + cpu) < 0) {
Where is the documentation about what this file will contain? On my
system, I see:
$ cat /sys/devices/system/cpu/cpu0/topology/thread_siblings_list
0
$ cat /sys/devices/system/cpu/cpu0/topology/thread_siblings
00000001
$ cat /sys/devices/system/cpu/cpu1/topology/thread_siblings_list
1
$ cat /sys/devices/system/cpu/cpu1/topology/thread_siblings
00000002
That is, I'm guessing that topology/thread_siblings_list is
human-readable, while topology/thread_siblings is a hex bitmask. If it
is indeed a 32-bit mask, then:
> + if (fgets(str, sizeof(str), pathfp) == NULL) {
> + virReportSystemError(errno, _("cannot read from %s"), path);
> + goto cleanup;
> + }
> +
> + i = 0;
> + while (str[i] != '\0') {
> + if (str[i] != '\n' && str[i] != ',')
> + ret += count_one_bits(str[i] - '0');
> + i++;
> + }
...this loop is borked, since it is assuming that str[i] will be a
digit, and is not looking for a-f. And why skipping comma? Shouldn't
this instead be parsing the entire file contents as a single int, and
only then calling count_one_bits once on the result?
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 323 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100308/f16dacde/attachment-0001.sig>
More information about the libvir-list
mailing list