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

[Xen-devel] [PATCH 2/2] add thread and state info to XEN_SYSCTL_cputopoinfo



Today the topology information obtained via XEN_SYSCTL_cputopoinfo
doesn't contain the thread id. Add that.

As especially with the boot parameter "smt=0" offline cpus are more
common these days add a state indicator (online/offline) to the
returned information as well.

Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
 tools/libxl/libxl.c         | 13 +++++++++++++
 tools/libxl/libxl_types.idl |  8 ++++++++
 tools/xl/xl_info.c          |  8 +++++---
 xen/common/sysctl.c         |  4 ++++
 xen/include/public/sysctl.h |  6 +++++-
 5 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index b41ade9fda..fc38223a06 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -430,10 +430,23 @@ libxl_cputopology *libxl_get_cpu_topology(libxl_ctx *ctx, 
int *nb_cpu_out)
     for (i = 0; i < num_cpus; i++) {
 #define V(map, i, invalid) ( cputopo[i].map == invalid) ? \
    LIBXL_CPUTOPOLOGY_INVALID_ENTRY : cputopo[i].map
+        ret[i].thread = V(thread, i, XEN_INVALID_THREAD_ID);
         ret[i].core = V(core, i, XEN_INVALID_CORE_ID);
         ret[i].socket = V(socket, i, XEN_INVALID_SOCKET_ID);
         ret[i].node = V(node, i, XEN_INVALID_NODE_ID);
 #undef V
+        switch (cputopo[i].state) {
+        case XEN_TOPO_STATE_OFFLINE:
+            ret[i].state = LIBXL_CPUTOPOLOGY_STATE_TYPE_OFFLINE;
+            break;
+        case XEN_TOPO_STATE_ONLINE:
+            ret[i].state = LIBXL_CPUTOPOLOGY_STATE_TYPE_ONLINE;
+            break;
+        default:
+            LOGE(WARN, "Invalid cpu state");
+            ret[i].state = LIBXL_CPUTOPOLOGY_STATE_TYPE_UNKNOWN;
+            break;
+        }
     }
 
     *nb_cpu_out = num_cpus;
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 4a385801ba..b1a8950ec7 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -1076,10 +1076,18 @@ libxl_numainfo = Struct("numainfo", [
     ("dists", Array(uint32, "num_dists")),
     ], dir=DIR_OUT)
 
+libxl_cputopology_state_type = Enumeration("cputopology_state_type", [
+    (0, "unknown"),
+    (1, "offline"),
+    (2, "online")
+    ])
+
 libxl_cputopology = Struct("cputopology", [
+    ("thread", uint32),
     ("core", uint32),
     ("socket", uint32),
     ("node", uint32),
+    ("state", libxl_cputopology_state_type),
     ], dir=DIR_OUT)
 
 libxl_pcitopology = Struct("pcitopology", [
diff --git a/tools/xl/xl_info.c b/tools/xl/xl_info.c
index 6c8be26119..34ef483e49 100644
--- a/tools/xl/xl_info.c
+++ b/tools/xl/xl_info.c
@@ -280,12 +280,14 @@ static void output_topologyinfo(void)
     }
 
     printf("cpu_topology           :\n");
-    printf("cpu:    core    socket     node\n");
+    printf("cpu:  thread     core   socket     node    state\n");
 
     for (i = 0; i < nr; i++) {
         if (cpuinfo[i].core != LIBXL_CPUTOPOLOGY_INVALID_ENTRY)
-            printf("%3d:    %4d     %4d     %4d\n", i,
-                   cpuinfo[i].core, cpuinfo[i].socket, cpuinfo[i].node);
+            printf("%3d:    %4d     %4d     %4d     %4d    %s\n", i,
+                   cpuinfo[i].thread, cpuinfo[i].core, cpuinfo[i].socket,
+                   cpuinfo[i].node,
+                   libxl_cputopology_state_type_to_string(cpuinfo[i].state));
     }
 
     libxl_cputopology_list_free(cpuinfo, nr);
diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
index c0aa6bde4e..8b6263a067 100644
--- a/xen/common/sysctl.c
+++ b/xen/common/sysctl.c
@@ -360,6 +360,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) 
u_sysctl)
             {
                 if ( cpu_present(i) )
                 {
+                    cputopo.thread = cpu_to_thread(i);
                     cputopo.core = cpu_to_core(i);
                     cputopo.socket = cpu_to_socket(i);
                     cputopo.node = cpu_to_node(i);
@@ -368,10 +369,13 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) 
u_sysctl)
                 }
                 else
                 {
+                    cputopo.thread = XEN_INVALID_THREAD_ID;
                     cputopo.core = XEN_INVALID_CORE_ID;
                     cputopo.socket = XEN_INVALID_SOCKET_ID;
                     cputopo.node = XEN_INVALID_NODE_ID;
                 }
+                cputopo.state = cpu_online(i) ? XEN_TOPO_STATE_ONLINE
+                                              : XEN_TOPO_STATE_OFFLINE;
 
                 if ( copy_to_guest_offset(ti->cputopo, i, &cputopo, 1) )
                 {
diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h
index e439e00983..ffb750a212 100644
--- a/xen/include/public/sysctl.h
+++ b/xen/include/public/sysctl.h
@@ -36,7 +36,7 @@
 #include "physdev.h"
 #include "tmem.h"
 
-#define XEN_SYSCTL_INTERFACE_VERSION 0x00000011
+#define XEN_SYSCTL_INTERFACE_VERSION 0x00000012
 
 /*
  * Read console content from Xen buffer ring.
@@ -434,15 +434,19 @@ struct xen_sysctl_lockprof_op {
 };
 
 /* XEN_SYSCTL_cputopoinfo */
+#define XEN_TOPO_STATE_OFFLINE  0
+#define XEN_TOPO_STATE_ONLINE   1
 #define XEN_INVALID_THREAD_ID   (~0U)
 #define XEN_INVALID_CORE_ID     (~0U)
 #define XEN_INVALID_SOCKET_ID   (~0U)
 #define XEN_INVALID_NODE_ID     (~0U)
 
 struct xen_sysctl_cputopo {
+    uint32_t thread;
     uint32_t core;
     uint32_t socket;
     uint32_t node;
+    uint32_t state;
 };
 typedef struct xen_sysctl_cputopo xen_sysctl_cputopo_t;
 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cputopo_t);
-- 
2.16.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.