xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Darrio Faggioli <raistlin@linux.it>
To: xen-devel@lists.xen.orgxen-devel@lists.xen.org
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Ian Campbell <Ian.Campbell@citrix.com>
Subject: [PATCH v2] libxl: use xc_topologyinfo to figure out how many CPUs we actually have
Date: Wed, 09 May 2012 14:46:20 +0200	[thread overview]
Message-ID: <95f7eacc32f0bf7ba281.1336567580@Solace> (raw)

Within libxl_get_cpu_topology(), considering all the CPUs the hypervisor
supports to be valid topology entries might lead to misleading and incorrect
behaviours, e.g., the output of `xl info -n' below on a 16 cores machine:
...
cpu_topology           :
cpu:    core    socket     node
  0:       0        1        0
  1:       0        1        0
  2:       1        1        0
  3:       1        1        0
  4:       9        1        0
  5:       9        1        0
  6:      10        1        0
  7:      10        1        0
  8:       0        0        1
  9:       0        0        1
 10:       1        0        1
 11:       1        0        1
 12:       9        0        1
 13:       9        0        1
 14:      10        0        1
 15:      10        0        1
 16:       0        0        0
 17:       0        0        0
 18:       0        0        0
 19:       0        0        0
 20:       0        0        0
 ...
 ...
 62:       0        0        0
 63:       0        0        0

However, xc_topologyinfo() tells us (in max_cpu_index) how many entries
arrays it returns corresponds to actually valid CPUs, so let's use that
information.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -2895,6 +2895,9 @@ libxl_cputopology *libxl_get_cpu_topolog
         goto fail;
     }
 
+    if (tinfo.max_cpu_index < max_cpus - 1)
+        max_cpus = tinfo.max_cpu_index + 1;
+
     ret = malloc(sizeof(libxl_cputopology) * max_cpus);
     if (ret == NULL) {
         LIBXL__LOG_ERRNOVAL(ctx, XTL_ERROR, ENOMEM,

             reply	other threads:[~2012-05-09 12:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-09 12:46 Darrio Faggioli [this message]
2012-05-11 11:40 ` [PATCH v2] libxl: use xc_topologyinfo to figure out how many CPUs we actually have Ian Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=95f7eacc32f0bf7ba281.1336567580@Solace \
    --to=raistlin@linux.it \
    --cc=Ian.Campbell@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=xen-devel@lists.xen.orgxen-devel \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).