All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libxl: use xc_topologyinfo to figure out how many CPUs we actually have
@ 2012-05-09 11:03 Darrio Faggioli
  2012-05-09 11:11 ` Dario Faggioli
  2012-05-09 12:04 ` Ian Campbell
  0 siblings, 2 replies; 6+ messages in thread
From: Darrio Faggioli @ 2012-05-09 11:03 UTC (permalink / raw)
  To: xen-devel; +Cc: George Dunlap, Ian Jackson, Ian Campbell

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
@@ -2903,7 +2903,8 @@ libxl_cputopology *libxl_get_cpu_topolog
     }
 
     for (i = 0; i < max_cpus; i++) {
-#define V(map, i) (map[i] == INVALID_TOPOLOGY_ID) ? \
+#define V(map, i) (i > tinfo.max_cpu_index || \
+    map[i] == INVALID_TOPOLOGY_ID) ? \
     LIBXL_CPUTOPOLOGY_INVALID_ENTRY : map[i]
         ret[i].core = V(coremap, i);
         ret[i].socket = V(socketmap, i);

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-05-10  9:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-09 11:03 [PATCH] libxl: use xc_topologyinfo to figure out how many CPUs we actually have Darrio Faggioli
2012-05-09 11:11 ` Dario Faggioli
2012-05-09 15:23   ` Ian Jackson
2012-05-10  9:26     ` Dario Faggioli
2012-05-09 12:04 ` Ian Campbell
2012-05-09 12:45   ` Dario Faggioli

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.