Re: [PATCH 1/3] qemu, lxc: Change host CPU detection logic.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/26/2012 07:19 AM, Viktor Mihajlovski wrote:
> The drivers for QEMU and LXC use virNodeGetInfo to determine the
> number of host CPUs. This approach can lead to a wrong (too small)
> number if one or more CPUs are offline.
> It is better to use virNodeGetCPUMap if available, which is the
> case here.

Hmm - ever since commit 4fbf322 added the simpler nodeGetCPUCount, that
function seems like a better option than calling virNodeGetCPUMap with
NULL arguments if all we need is the number of available (and possibly
offline) CPUs.

> 
> Signed-off-by: Viktor Mihajlovski <mihajlov@xxxxxxxxxxxxxxxxxx>
> ---
>  src/lxc/lxc_controller.c |  8 +++-----
>  src/qemu/qemu_driver.c   | 12 +++---------
>  src/qemu/qemu_process.c  | 10 ++++------
>  3 files changed, 10 insertions(+), 20 deletions(-)
> 
> diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
> index a41c903..e9720bc 100644
> --- a/src/lxc/lxc_controller.c
> +++ b/src/lxc/lxc_controller.c
> @@ -492,17 +492,15 @@ static int virLXCControllerSetupNUMAPolicy(virLXCControllerPtr ctrl)
>  static int virLXCControllerSetupCpuAffinity(virLXCControllerPtr ctrl)
>  {
>      int hostcpus, maxcpu = CPU_SETSIZE;
> -    virNodeInfo nodeinfo;
>      virBitmapPtr cpumap, cpumapToSet;
>  
>      VIR_DEBUG("Setting CPU affinity");
>  
> -    if (nodeGetInfo(NULL, &nodeinfo) < 0)
> -        return -1;
> -
>      /* setaffinity fails if you set bits for CPUs which
>       * aren't present, so we have to limit ourselves */
> -    hostcpus = VIR_NODEINFO_MAXCPUS(nodeinfo);
> +    if ((hostcpus = nodeGetCPUMap(NULL, NULL, NULL, 0)) < 0)
> +        return -1;
> +
>      if (maxcpu > hostcpus)
>          maxcpu = hostcpus;

But the idea of using the simplest function possible instead of calling
nodeGetInfo() and discarding the bulk of the struct makes sense.
Looking forward to v2.

> @@ -1923,7 +1921,7 @@ qemuPrepareCpumap(struct qemud_driver *driver,
>              bool result;
>              if (virBitmapGetBit(nodemask, i, &result) < 0) {
>                  virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> -                               _("Failed to covert nodeset to cpuset"));
> +                               _("Failed to convert nodeset to cpuset"));
>                  virBitmapFree(cpumap);

I noticed this one independently, and fixed it in commit dd0a704 before
even seeing this thread from you.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]