Replace sysctl.physinfo.sockets_per_node with more directly useful
authorKeir Fraser <keir@xensource.com>
Fri, 19 Oct 2007 17:00:10 +0000 (18:00 +0100)
committerKeir Fraser <keir@xensource.com>
Fri, 19 Oct 2007 17:00:10 +0000 (18:00 +0100)
sysctl.physinfo.nr_cpus. This also avoids miscalculation of
sockets_per_node by Xen where the number of CPUs in the system is
clipped.
From: Elizabeth Kon <eak@us.ibm.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
13 files changed:
docs/man/xm.pod.1
tools/python/xen/lowlevel/xc/xc.c
tools/python/xen/xend/XendNode.py
tools/python/xen/xm/main.py
tools/xenmon/xenbaked.c
tools/xenstat/libxenstat/src/xenstat.c
tools/xentrace/xentrace.c
tools/xm-test/lib/XmTestLib/Xm.py
tools/xm-test/lib/XmTestReport/OSReport.py
xen/arch/ia64/xen/dom0_ops.c
xen/arch/powerpc/sysctl.c
xen/arch/x86/sysctl.c
xen/include/public/sysctl.h

index 602993342c4f419d74846adabdd7cec7fb5b111a..72932dee93bb8db2139a3d0fc88a4d0c3c3adfa2 100644 (file)
@@ -446,7 +446,6 @@ page more readable):
  machine                : i686
  nr_cpus                : 2
  nr_nodes               : 1
- sockets_per_node       : 2
  cores_per_socket       : 1
  threads_per_core       : 1
  cpu_mhz                : 696
index 07dd574c5803b16c357fb65afac2632a13ea1669..5716dbf2ec8f36b5da1cf8060e7e2993947d3134 100644 (file)
@@ -801,7 +801,7 @@ static PyObject *pyxc_physinfo(XcObject *self)
                             "max_cpu_id",       info.max_cpu_id,
                             "threads_per_core", info.threads_per_core,
                             "cores_per_socket", info.cores_per_socket,
-                            "sockets_per_node", info.sockets_per_node,
+                            "nr_cpus",          info.nr_cpus, 
                             "total_memory",     pages_to_kib(info.total_pages),
                             "free_memory",      pages_to_kib(info.free_pages),
                             "scrub_memory",     pages_to_kib(info.scrub_pages),
index 969c72dbc7a6f6a21b96f53ecac818a849041f79..cde65142f1774a145f0da5391958bf5cc9984c13 100644 (file)
@@ -475,7 +475,7 @@ class XendNode:
 
         cpu_info = {
             "nr_nodes":         phys_info["nr_nodes"],
-            "sockets_per_node": phys_info["sockets_per_node"],
+            "nr_cpus":          phys_info["nr_cpus"],
             "cores_per_socket": phys_info["cores_per_socket"],
             "threads_per_core": phys_info["threads_per_core"]
             }
@@ -580,17 +580,9 @@ class XendNode:
             str='none\n'
         return str[:-1];
 
-    def count_cpus(self, pinfo):
-        count=0
-        node_to_cpu=pinfo['node_to_cpu']
-        for i in range(0, pinfo['nr_nodes']):
-            count+=len(node_to_cpu[i])
-        return count;
-
     def physinfo(self):
         info = self.xc.physinfo()
 
-        info['nr_cpus'] = self.count_cpus(info)
         info['cpu_mhz'] = info['cpu_khz'] / 1000
         
         # physinfo is in KiB, need it in MiB
@@ -600,7 +592,6 @@ class XendNode:
 
         ITEM_ORDER = ['nr_cpus',
                       'nr_nodes',
-                      'sockets_per_node',
                       'cores_per_socket',
                       'threads_per_core',
                       'cpu_mhz',
index f728b858abd205839f8d0e9098b821c0eb9b1b01..929f7c1c1eded4b5caee48c06b7c9f3ae1af77d9 100644 (file)
@@ -1667,9 +1667,8 @@ def xm_info(args):
             "release":           getVal(["software_version", "release"]),
             "version":           getVal(["software_version", "version"]),
             "machine":           getVal(["software_version", "machine"]),
-            "nr_cpus":           len(getVal(["host_CPUs"], [])),
+            "nr_cpus":           getVal(["cpu_configuration", "nr_cpus"]),
             "nr_nodes":          getVal(["cpu_configuration", "nr_nodes"]),
-            "sockets_per_node":  getVal(["cpu_configuration", "sockets_per_node"]),
             "cores_per_socket":  getVal(["cpu_configuration", "cores_per_socket"]),
             "threads_per_core":  getVal(["cpu_configuration", "threads_per_core"]),
             "cpu_mhz":           getCpuMhz(),
index 35bc8a89e2bea5cb619fd5974a3cf9bb50e1547f..afca2f21688ccca08005b8eed2d8896e99ecd197 100644 (file)
@@ -460,10 +460,7 @@ unsigned int get_num_cpus(void)
     xc_interface_close(xc_handle);
     opts.cpu_freq = (double)physinfo.cpu_khz/1000.0;
 
-    return (physinfo.threads_per_core *
-            physinfo.cores_per_socket *
-            physinfo.sockets_per_node *
-            physinfo.nr_nodes);
+    return physinfo.nr_cpus;
 }
 
 
index 461806ec7d14746b88d0f71bcb4981b3a9320258..559fb9bec648a494054039facf928b0647a3d3f4 100644 (file)
@@ -155,9 +155,7 @@ xenstat_node *xenstat_get_node(xenstat_handle * handle, unsigned int flags)
        }
 
        node->cpu_hz = ((unsigned long long)physinfo.cpu_khz) * 1000ULL;
-       node->num_cpus =
-           (physinfo.threads_per_core * physinfo.cores_per_socket *
-            physinfo.sockets_per_node * physinfo.nr_nodes);
+        node->num_cpus = physinfo.nr_cpus;
        node->tot_mem = ((unsigned long long)physinfo.total_pages)
            * handle->page_size;
        node->free_mem = ((unsigned long long)physinfo.free_pages)
index fdb5d5e57f89b5c201f6fd6915c5ef3a9ca1dc80..17df72fe9d10378a44f5faadedc459e50442be05 100644 (file)
@@ -309,10 +309,7 @@ unsigned int get_num_cpus(void)
 
     xc_interface_close(xc_handle);
 
-    return (physinfo.threads_per_core *
-            physinfo.cores_per_socket *
-            physinfo.sockets_per_node *
-            physinfo.nr_nodes);
+    return physinfo.nr_cpus;
 }
 
 
index 6f1e33c153731af5245bd96304d15cd7403d7ff5..6eeab7bb9dbe9b0917d5c0718cbae3450892bffb 100644 (file)
@@ -218,11 +218,9 @@ def restartXend():
         return status
 
 def smpConcurrencyLevel():
-    cores = int(getInfo("cores_per_socket"))
-    threads = int(getInfo("threads_per_core"))
-    sockets = int(getInfo("sockets_per_node"))
+    nr_cpus = int(getInfo("nr_cpus"))
 
-    return cores * sockets * threads
+    return nr_cpus
 
 if __name__ == "__main__":
     if isDomainRunning("0"):
index 80bb4bed53659c2aa47b284d5470d54d9bd6c9ce..4eaa20cae97c2975653234fc89636c08b5ec4957 100644 (file)
@@ -92,7 +92,6 @@ class Machine:
 
         xenValues = {"nr_cpus"          : "Unknown",
                      "nr_nodes"         : "Unknown",
-                     "sockets_per_node" : "Unknown",
                      "cores_per_socket" : "Unknown",
                      "threads_per_core" : "Unknown",
                      "cpu_mhz"          : "Unknown",
index 4f683561e28c2be7ee583891e40ab49161f1e86c..b92e51ba0e137d49940d3cc23ee1f2af642c6f80 100644 (file)
@@ -251,7 +251,7 @@ long arch_do_sysctl(xen_sysctl_t *op, XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl)
     {
     case XEN_SYSCTL_physinfo:
     {
-        int i, node_cpus = 0;
+        int i;
         uint32_t max_array_ent;
 
         xen_sysctl_physinfo_t *pi = &op->u.physinfo;
@@ -259,18 +259,8 @@ long arch_do_sysctl(xen_sysctl_t *op, XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl)
         pi->threads_per_core = cpus_weight(cpu_sibling_map[0]);
         pi->cores_per_socket =
             cpus_weight(cpu_core_map[0]) / pi->threads_per_core;
+        pi->nr_cpus          = (u32)num_online_cpus();
         pi->nr_nodes         = num_online_nodes();
-
-        /*
-         * Guess at a sockets_per_node value.  Use the maximum number of
-         * CPUs per node to avoid deconfigured CPUs breaking the average.
-         */
-        for_each_online_node(i)
-            node_cpus = max(node_cpus, cpus_weight(node_to_cpumask(i)));
-
-        pi->sockets_per_node = node_cpus / 
-            (pi->cores_per_socket * pi->threads_per_core);
-
         pi->total_pages      = total_pages; 
         pi->free_pages       = avail_domheap_pages();
         pi->scrub_pages      = avail_scrub_pages();
index cc1e23181aacb39805ac413ad6b917d0a743d3bf..b211d4f9f7ba9201c687100dcfb8579cdb494e20 100644 (file)
@@ -45,9 +45,7 @@ long arch_do_sysctl(struct xen_sysctl *sysctl,
             cpus_weight(cpu_sibling_map[0]);
         pi->cores_per_socket =
             cpus_weight(cpu_core_map[0]) / pi->threads_per_core;
-        pi->sockets_per_node = num_online_cpus() / 
-            (num_online_nodes() * pi->cores_per_socket * pi->threads_per_core);
-
+        pi->nr_cpus          = (u32)num_online_cpus();
         pi->nr_nodes         = num_online_nodes();
         pi->total_pages      = total_pages;
         pi->free_pages       = avail_domheap_pages();
index e518d4ce49484e988305ea8b097e69665c535c69..db94bfd812dfcde0365b0366a6a2b438daa3f08e 100644 (file)
@@ -51,10 +51,8 @@ long arch_do_sysctl(
             cpus_weight(cpu_sibling_map[0]);
         pi->cores_per_socket =
             cpus_weight(cpu_core_map[0]) / pi->threads_per_core;
+        pi->nr_cpus = (u32)num_online_cpus();
         pi->nr_nodes = num_online_nodes();
-        pi->sockets_per_node = num_online_cpus() / 
-            (pi->nr_nodes * pi->cores_per_socket * pi->threads_per_core);
-
         pi->total_pages      = total_pages;
         pi->free_pages       = avail_domheap_pages();
         pi->scrub_pages      = avail_scrub_pages();
index 1088a275e083fb4c51405f4bcb22ab6786e8f6b2..5e4ad0b01a1e58422598058d73945c76ded96b25 100644 (file)
@@ -34,7 +34,7 @@
 #include "xen.h"
 #include "domctl.h"
 
-#define XEN_SYSCTL_INTERFACE_VERSION 0x00000004
+#define XEN_SYSCTL_INTERFACE_VERSION 0x00000005
 
 /*
  * Read console content from Xen buffer ring.
@@ -79,7 +79,7 @@ struct xen_sysctl_physinfo {
     /* IN variables. */
     uint32_t threads_per_core;
     uint32_t cores_per_socket;
-    uint32_t sockets_per_node;
+    uint32_t nr_cpus;
     uint32_t nr_nodes;
     uint32_t cpu_khz;
     uint64_aligned_t total_pages;