[libvirt] [PATCH 09/10] nodeinfo: Use a bitmap to keep track of node CPUs
Peter Krempa
pkrempa at redhat.com
Mon Jul 20 13:47:36 UTC 2015
On Fri, Jul 17, 2015 at 18:13:28 +0200, Andrea Bolognani wrote:
> Keep track of what CPUs belong to the current node while walking
> through the sysfs node entry, so we don't need to do it a second
> time immediately afterwards.
>
> This also allows us to loop through all CPUs that are part of a
> node in guaranteed ascending order, which is something that is
> required for some upcoming changes.
> ---
> src/nodeinfo.c | 26 ++++++++++++++++----------
> 1 file changed, 16 insertions(+), 10 deletions(-)
>
...
> @@ -480,13 +490,11 @@ virNodeParseNode(const char *sysfs_prefix,
> if (!(cores_maps[i] = virBitmapNew(ID_MAX + 1)))
> goto cleanup;
>
> - /* iterate over all CPU's in the node */
> - rewinddir(cpudir);
> - while ((direrr = virDirRead(cpudir, &cpudirent, node)) > 0) {
> - if (sscanf(cpudirent->d_name, "cpu%u", &cpu) != 1)
> - continue;
> + /* Iterate over all CPUs in the node, in ascending order */
> + for (cpu = 0; cpu < npresent_cpus; cpu++) {
>
> - if (!virBitmapIsBitSet(present_cpumap, cpu))
> + /* Skip CPUs that are not part of the current node */
> + if (!virBitmapIsBitSet(node_cpus_map, cpu))
Perhaps you can use virBitmapNextSetBit to simplify the iteration.
> continue;
>
> if (!virBitmapIsBitSet(online_cpus_map, cpu)) {
ACK with or without the iteration modified.
Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150720/03201136/attachment-0001.sig>
More information about the libvir-list
mailing list