ia64/xen-unstable

changeset 16166:6df47366830c

Replace sysctl.physinfo.sockets_per_node with more directly useful
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>
author Keir Fraser <keir@xensource.com>
date Fri Oct 19 18:00:10 2007 +0100 (2007-10-19)
parents 975811798ffe
children 7231d971f78c
files 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
line diff
     1.1 --- a/docs/man/xm.pod.1	Fri Oct 19 17:47:12 2007 +0100
     1.2 +++ b/docs/man/xm.pod.1	Fri Oct 19 18:00:10 2007 +0100
     1.3 @@ -446,7 +446,6 @@ page more readable):
     1.4   machine                : i686
     1.5   nr_cpus                : 2
     1.6   nr_nodes               : 1
     1.7 - sockets_per_node       : 2
     1.8   cores_per_socket       : 1
     1.9   threads_per_core       : 1
    1.10   cpu_mhz                : 696
     2.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Fri Oct 19 17:47:12 2007 +0100
     2.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Fri Oct 19 18:00:10 2007 +0100
     2.3 @@ -801,7 +801,7 @@ static PyObject *pyxc_physinfo(XcObject 
     2.4                              "max_cpu_id",       info.max_cpu_id,
     2.5                              "threads_per_core", info.threads_per_core,
     2.6                              "cores_per_socket", info.cores_per_socket,
     2.7 -                            "sockets_per_node", info.sockets_per_node,
     2.8 +                            "nr_cpus",          info.nr_cpus, 
     2.9                              "total_memory",     pages_to_kib(info.total_pages),
    2.10                              "free_memory",      pages_to_kib(info.free_pages),
    2.11                              "scrub_memory",     pages_to_kib(info.scrub_pages),
     3.1 --- a/tools/python/xen/xend/XendNode.py	Fri Oct 19 17:47:12 2007 +0100
     3.2 +++ b/tools/python/xen/xend/XendNode.py	Fri Oct 19 18:00:10 2007 +0100
     3.3 @@ -475,7 +475,7 @@ class XendNode:
     3.4  
     3.5          cpu_info = {
     3.6              "nr_nodes":         phys_info["nr_nodes"],
     3.7 -            "sockets_per_node": phys_info["sockets_per_node"],
     3.8 +            "nr_cpus":          phys_info["nr_cpus"],
     3.9              "cores_per_socket": phys_info["cores_per_socket"],
    3.10              "threads_per_core": phys_info["threads_per_core"]
    3.11              }
    3.12 @@ -580,17 +580,9 @@ class XendNode:
    3.13              str='none\n'
    3.14          return str[:-1];
    3.15  
    3.16 -    def count_cpus(self, pinfo):
    3.17 -        count=0
    3.18 -        node_to_cpu=pinfo['node_to_cpu']
    3.19 -        for i in range(0, pinfo['nr_nodes']):
    3.20 -            count+=len(node_to_cpu[i])
    3.21 -        return count;
    3.22 -
    3.23      def physinfo(self):
    3.24          info = self.xc.physinfo()
    3.25  
    3.26 -        info['nr_cpus'] = self.count_cpus(info)
    3.27          info['cpu_mhz'] = info['cpu_khz'] / 1000
    3.28          
    3.29          # physinfo is in KiB, need it in MiB
    3.30 @@ -600,7 +592,6 @@ class XendNode:
    3.31  
    3.32          ITEM_ORDER = ['nr_cpus',
    3.33                        'nr_nodes',
    3.34 -                      'sockets_per_node',
    3.35                        'cores_per_socket',
    3.36                        'threads_per_core',
    3.37                        'cpu_mhz',
     4.1 --- a/tools/python/xen/xm/main.py	Fri Oct 19 17:47:12 2007 +0100
     4.2 +++ b/tools/python/xen/xm/main.py	Fri Oct 19 18:00:10 2007 +0100
     4.3 @@ -1667,9 +1667,8 @@ def xm_info(args):
     4.4              "release":           getVal(["software_version", "release"]),
     4.5              "version":           getVal(["software_version", "version"]),
     4.6              "machine":           getVal(["software_version", "machine"]),
     4.7 -            "nr_cpus":           len(getVal(["host_CPUs"], [])),
     4.8 +            "nr_cpus":           getVal(["cpu_configuration", "nr_cpus"]),
     4.9              "nr_nodes":          getVal(["cpu_configuration", "nr_nodes"]),
    4.10 -            "sockets_per_node":  getVal(["cpu_configuration", "sockets_per_node"]),
    4.11              "cores_per_socket":  getVal(["cpu_configuration", "cores_per_socket"]),
    4.12              "threads_per_core":  getVal(["cpu_configuration", "threads_per_core"]),
    4.13              "cpu_mhz":           getCpuMhz(),
     5.1 --- a/tools/xenmon/xenbaked.c	Fri Oct 19 17:47:12 2007 +0100
     5.2 +++ b/tools/xenmon/xenbaked.c	Fri Oct 19 18:00:10 2007 +0100
     5.3 @@ -460,10 +460,7 @@ unsigned int get_num_cpus(void)
     5.4      xc_interface_close(xc_handle);
     5.5      opts.cpu_freq = (double)physinfo.cpu_khz/1000.0;
     5.6  
     5.7 -    return (physinfo.threads_per_core *
     5.8 -            physinfo.cores_per_socket *
     5.9 -            physinfo.sockets_per_node *
    5.10 -            physinfo.nr_nodes);
    5.11 +    return physinfo.nr_cpus;
    5.12  }
    5.13  
    5.14  
     6.1 --- a/tools/xenstat/libxenstat/src/xenstat.c	Fri Oct 19 17:47:12 2007 +0100
     6.2 +++ b/tools/xenstat/libxenstat/src/xenstat.c	Fri Oct 19 18:00:10 2007 +0100
     6.3 @@ -155,9 +155,7 @@ xenstat_node *xenstat_get_node(xenstat_h
     6.4  	}
     6.5  
     6.6  	node->cpu_hz = ((unsigned long long)physinfo.cpu_khz) * 1000ULL;
     6.7 -	node->num_cpus =
     6.8 -	    (physinfo.threads_per_core * physinfo.cores_per_socket *
     6.9 -	     physinfo.sockets_per_node * physinfo.nr_nodes);
    6.10 +        node->num_cpus = physinfo.nr_cpus;
    6.11  	node->tot_mem = ((unsigned long long)physinfo.total_pages)
    6.12  	    * handle->page_size;
    6.13  	node->free_mem = ((unsigned long long)physinfo.free_pages)
     7.1 --- a/tools/xentrace/xentrace.c	Fri Oct 19 17:47:12 2007 +0100
     7.2 +++ b/tools/xentrace/xentrace.c	Fri Oct 19 18:00:10 2007 +0100
     7.3 @@ -309,10 +309,7 @@ unsigned int get_num_cpus(void)
     7.4  
     7.5      xc_interface_close(xc_handle);
     7.6  
     7.7 -    return (physinfo.threads_per_core *
     7.8 -            physinfo.cores_per_socket *
     7.9 -            physinfo.sockets_per_node *
    7.10 -            physinfo.nr_nodes);
    7.11 +    return physinfo.nr_cpus;
    7.12  }
    7.13  
    7.14  
     8.1 --- a/tools/xm-test/lib/XmTestLib/Xm.py	Fri Oct 19 17:47:12 2007 +0100
     8.2 +++ b/tools/xm-test/lib/XmTestLib/Xm.py	Fri Oct 19 18:00:10 2007 +0100
     8.3 @@ -218,11 +218,9 @@ def restartXend():
     8.4          return status
     8.5  
     8.6  def smpConcurrencyLevel():
     8.7 -    cores = int(getInfo("cores_per_socket"))
     8.8 -    threads = int(getInfo("threads_per_core"))
     8.9 -    sockets = int(getInfo("sockets_per_node"))
    8.10 +    nr_cpus = int(getInfo("nr_cpus"))
    8.11  
    8.12 -    return cores * sockets * threads
    8.13 +    return nr_cpus
    8.14  
    8.15  if __name__ == "__main__":
    8.16      if isDomainRunning("0"):
     9.1 --- a/tools/xm-test/lib/XmTestReport/OSReport.py	Fri Oct 19 17:47:12 2007 +0100
     9.2 +++ b/tools/xm-test/lib/XmTestReport/OSReport.py	Fri Oct 19 18:00:10 2007 +0100
     9.3 @@ -92,7 +92,6 @@ class Machine:
     9.4  
     9.5          xenValues = {"nr_cpus"          : "Unknown",
     9.6                       "nr_nodes"         : "Unknown",
     9.7 -                     "sockets_per_node" : "Unknown",
     9.8                       "cores_per_socket" : "Unknown",
     9.9                       "threads_per_core" : "Unknown",
    9.10                       "cpu_mhz"          : "Unknown",
    10.1 --- a/xen/arch/ia64/xen/dom0_ops.c	Fri Oct 19 17:47:12 2007 +0100
    10.2 +++ b/xen/arch/ia64/xen/dom0_ops.c	Fri Oct 19 18:00:10 2007 +0100
    10.3 @@ -251,7 +251,7 @@ long arch_do_sysctl(xen_sysctl_t *op, XE
    10.4      {
    10.5      case XEN_SYSCTL_physinfo:
    10.6      {
    10.7 -        int i, node_cpus = 0;
    10.8 +        int i;
    10.9          uint32_t max_array_ent;
   10.10  
   10.11          xen_sysctl_physinfo_t *pi = &op->u.physinfo;
   10.12 @@ -259,18 +259,8 @@ long arch_do_sysctl(xen_sysctl_t *op, XE
   10.13          pi->threads_per_core = cpus_weight(cpu_sibling_map[0]);
   10.14          pi->cores_per_socket =
   10.15              cpus_weight(cpu_core_map[0]) / pi->threads_per_core;
   10.16 +        pi->nr_cpus          = (u32)num_online_cpus();
   10.17          pi->nr_nodes         = num_online_nodes();
   10.18 -
   10.19 -        /*
   10.20 -         * Guess at a sockets_per_node value.  Use the maximum number of
   10.21 -         * CPUs per node to avoid deconfigured CPUs breaking the average.
   10.22 -         */
   10.23 -        for_each_online_node(i)
   10.24 -            node_cpus = max(node_cpus, cpus_weight(node_to_cpumask(i)));
   10.25 -
   10.26 -        pi->sockets_per_node = node_cpus / 
   10.27 -            (pi->cores_per_socket * pi->threads_per_core);
   10.28 -
   10.29          pi->total_pages      = total_pages; 
   10.30          pi->free_pages       = avail_domheap_pages();
   10.31          pi->scrub_pages      = avail_scrub_pages();
    11.1 --- a/xen/arch/powerpc/sysctl.c	Fri Oct 19 17:47:12 2007 +0100
    11.2 +++ b/xen/arch/powerpc/sysctl.c	Fri Oct 19 18:00:10 2007 +0100
    11.3 @@ -45,9 +45,7 @@ long arch_do_sysctl(struct xen_sysctl *s
    11.4              cpus_weight(cpu_sibling_map[0]);
    11.5          pi->cores_per_socket =
    11.6              cpus_weight(cpu_core_map[0]) / pi->threads_per_core;
    11.7 -        pi->sockets_per_node = num_online_cpus() / 
    11.8 -            (num_online_nodes() * pi->cores_per_socket * pi->threads_per_core);
    11.9 -
   11.10 +        pi->nr_cpus          = (u32)num_online_cpus();
   11.11          pi->nr_nodes         = num_online_nodes();
   11.12          pi->total_pages      = total_pages;
   11.13          pi->free_pages       = avail_domheap_pages();
    12.1 --- a/xen/arch/x86/sysctl.c	Fri Oct 19 17:47:12 2007 +0100
    12.2 +++ b/xen/arch/x86/sysctl.c	Fri Oct 19 18:00:10 2007 +0100
    12.3 @@ -51,10 +51,8 @@ long arch_do_sysctl(
    12.4              cpus_weight(cpu_sibling_map[0]);
    12.5          pi->cores_per_socket =
    12.6              cpus_weight(cpu_core_map[0]) / pi->threads_per_core;
    12.7 +        pi->nr_cpus = (u32)num_online_cpus();
    12.8          pi->nr_nodes = num_online_nodes();
    12.9 -        pi->sockets_per_node = num_online_cpus() / 
   12.10 -            (pi->nr_nodes * pi->cores_per_socket * pi->threads_per_core);
   12.11 -
   12.12          pi->total_pages      = total_pages;
   12.13          pi->free_pages       = avail_domheap_pages();
   12.14          pi->scrub_pages      = avail_scrub_pages();
    13.1 --- a/xen/include/public/sysctl.h	Fri Oct 19 17:47:12 2007 +0100
    13.2 +++ b/xen/include/public/sysctl.h	Fri Oct 19 18:00:10 2007 +0100
    13.3 @@ -34,7 +34,7 @@
    13.4  #include "xen.h"
    13.5  #include "domctl.h"
    13.6  
    13.7 -#define XEN_SYSCTL_INTERFACE_VERSION 0x00000004
    13.8 +#define XEN_SYSCTL_INTERFACE_VERSION 0x00000005
    13.9  
   13.10  /*
   13.11   * Read console content from Xen buffer ring.
   13.12 @@ -79,7 +79,7 @@ struct xen_sysctl_physinfo {
   13.13      /* IN variables. */
   13.14      uint32_t threads_per_core;
   13.15      uint32_t cores_per_socket;
   13.16 -    uint32_t sockets_per_node;
   13.17 +    uint32_t nr_cpus;
   13.18      uint32_t nr_nodes;
   13.19      uint32_t cpu_khz;
   13.20      uint64_aligned_t total_pages;