[libvirt] [PATCH] libvirt: Change maximum CPU per node calculation.
Daniel P. Berrange
berrange at redhat.com
Wed Oct 10 12:23:01 UTC 2012
On Wed, Oct 10, 2012 at 02:05:25PM +0200, Viktor Mihajlovski wrote:
> The macro VIR_NODEINFO_MAXCPUS computes the maximum number of supported
> CPUs for a node as the product of sockets, cores and threads from the
> virNodeInfo structure.
> Since topology cannot be discovered for offline CPUs, any of the values
> for sockets, cores or threads can be wrong (too small).
> As a consequence the per-VCPU CPU masks are truncated incorrectly and
> it's impossible to correlate the bits in the masks with actual CPUs on
> the host.
>
> Example:
> Host has 3 logical CPUs, 1 socket, 3 cores, 1 thread.
> Guest has 1 virtual CPU and is started while all 3 host CPUs are
> online.
>
> $ virsh vcpuinfo guest
> VCPU: 0
> CPU: 0
> State: running
> CPU time: 35.4s
> CPU Affinity: yyy
>
> $ echo 0 > /sys/devices/system/cpu/cpu1/online
>
> $ virsh vcpuinfo guest
> VCPU: 0
> CPU: 0
> State: running
> CPU time: 35.5s
> CPU Affinity: y-
>
> The correct display for CPU affinity would have been y-y, as the guest
> continues to use CPUs 0 and 2.
> This is not a display problem only, because it is also not possible to
> explicitly pin the virtual CPU to host CPUs 0 and 2, due to the
> truncated CPU mask.
>
> To prevent this, the following changes have been made:
>
> 1. In virNodeParseNode count all logical CPUs, offline or online
> and pass them back in a new argument 'maxcpus'.
> 2. Extend the virNodeInfo struct with a new member 'maxcpus'
> containing the number of all logical CPUs, online and offline.
> 3. Change the macro VIR_NODEINFO_MAXCPUS to return virNodeInfo.maxpus
>
> Signed-off-by: Viktor Mihajlovski <mihajlov at linux.vnet.ibm.com>
> ---
> include/libvirt/libvirt.h.in | 3 ++-
> src/nodeinfo.c | 17 +++++++++++++----
> src/remote/remote_protocol.x | 1 +
> src/remote_protocol-structs | 1 +
> 4 files changed, 17 insertions(+), 5 deletions(-)
>
> diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
> index 81f12a4..16265b5 100644
> --- a/include/libvirt/libvirt.h.in
> +++ b/include/libvirt/libvirt.h.in
> @@ -445,6 +445,7 @@ struct _virNodeInfo {
> total number of CPU sockets otherwise */
> unsigned int cores; /* number of cores per socket */
> unsigned int threads;/* number of threads per core */
> + unsigned int maxcpus;/* number of maximum cpus - online and offline */
> };
NACK, this breaks ABI compatibility of the public API
> diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
> index b0b530c..40883d0 100644
> --- a/src/remote/remote_protocol.x
> +++ b/src/remote/remote_protocol.x
> @@ -465,6 +465,7 @@ struct remote_node_get_info_ret { /* insert at 1 */
> int sockets;
> int cores;
> int threads;
> + int maxcpus;
> };
>
NACK, this breaks ABI compatibility of the wire protocol
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
More information about the libvir-list
mailing list