WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] 6/7 xen: Add basic NUMA support - Physinfo nr_cpus

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] 6/7 xen: Add basic NUMA support - Physinfo nr_cpus
From: Ryan Harper <ryanh@xxxxxxxxxx>
Date: Fri, 16 Dec 2005 17:13:28 -0600
Cc: Ryan Grimm <grimm@xxxxxxxxxx>
Delivery-date: Fri, 16 Dec 2005 23:15:40 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.6+20040907i
This patch adds a new field to physinfo, nr_cpus, which previously has
been calculated by the following formula:

nr_cpus = nr_nodes * sockets_per_node * cores_per_socket * \
          threads_per_core

This formula makes an assumption about the symmetry of NUMA nodes.  For
instance, on my Dual Opteron, which is a two node system with one cpu in
each node, sockets_per_node is calculated as 2, but this is incorrect.
There isn't a single value for sockets per node, but rather, it should
be a list of values, which is generated by taking the Hamming weight of
each node's cpumask.

In Xen, there aren't a large number of uses for sockets_per_node other
than calculating the number of cpus booted in the hypervisor.  Instead
of dealing with making another array in physinfo, I've opted to add
nr_cpus which is based on num_online_cpus() and replaced all instances
of the nr_cpus formula with a reference to the proper nr_cpus value that
is now contained in the physinfo.

-- 
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
(512) 838-9253   T/L: 678-9253
ryanh@xxxxxxxxxx


diffstat output:
 tools/python/xen/lowlevel/xc/xc.c |    3 ++-
 tools/python/xen/xend/XendNode.py |    4 ----
 tools/xenmon/xenbaked.c           |    5 +----
 tools/xentrace/xentrace.c         |    5 +----
 xen/arch/ia64/xen/dom0_ops.c      |    1 +
 xen/arch/x86/dom0_ops.c           |    1 +
 xen/include/public/dom0_ops.h     |    1 +
 7 files changed, 7 insertions(+), 13 deletions(-)

Signed-off-by: Ryan Harper <ryanh@xxxxxxxxxx>
Signed-off-by: Ryan Grimm <grimm@xxxxxxxxxx>
---
diff -r 398a0cdf3e31 -r f9779dd3e52b tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Fri Dec 16 17:02:16 2005
+++ b/tools/python/xen/lowlevel/xc/xc.c Fri Dec 16 17:47:48 2005
@@ -623,10 +623,11 @@
     if(q>cpu_cap)
         *(q-1)=0;
     
-    ret_obj = Py_BuildValue("{s:i,s:i,s:i,s:l,s:l,s:i,s:s}",
+    ret_obj = Py_BuildValue("{s:i,s:i,s:i,s:i,s:l,s:l,s:i,s:s}",
                          "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_mb(info.total_pages),
                          "free_memory",      pages_to_mb(info.free_pages),
                          "cpu_khz",          info.cpu_khz,
diff -r 398a0cdf3e31 -r f9779dd3e52b tools/python/xen/xend/XendNode.py
--- a/tools/python/xen/xend/XendNode.py Fri Dec 16 17:02:16 2005
+++ b/tools/python/xen/xend/XendNode.py Fri Dec 16 17:47:48 2005
@@ -122,10 +122,6 @@
     def physinfo(self):
         info = self.xc.physinfo()
 
-        info['nr_cpus'] = (info['nr_nodes'] *
-                           info['sockets_per_node'] *
-                           info['cores_per_socket'] *
-                           info['threads_per_core'])
         info['cpu_mhz'] = info['cpu_khz'] / 1000
         info['mem_chunks'] = self.format_memchunks(info)
         info['node_to_cpu'] = self.format_node_to_cpu(info)
diff -r 398a0cdf3e31 -r f9779dd3e52b tools/xenmon/xenbaked.c
--- a/tools/xenmon/xenbaked.c   Fri Dec 16 17:02:16 2005
+++ b/tools/xenmon/xenbaked.c   Fri Dec 16 17:47:48 2005
@@ -399,10 +399,7 @@
     xc_interface_close(xc_handle);
     opts.cpu_freq = (double)op.u.physinfo.cpu_khz/1000.0;
 
-    return (op.u.physinfo.threads_per_core *
-            op.u.physinfo.cores_per_socket *
-            op.u.physinfo.sockets_per_node *
-            op.u.physinfo.nr_nodes);
+    return op.u.physinfo.nr_cpus;
 }
 
 
diff -r 398a0cdf3e31 -r f9779dd3e52b tools/xentrace/xentrace.c
--- a/tools/xentrace/xentrace.c Fri Dec 16 17:02:16 2005
+++ b/tools/xentrace/xentrace.c Fri Dec 16 17:47:48 2005
@@ -277,10 +277,7 @@
 
     xc_interface_close(xc_handle);
 
-    return (op.u.physinfo.threads_per_core *
-            op.u.physinfo.cores_per_socket *
-            op.u.physinfo.sockets_per_node *
-            op.u.physinfo.nr_nodes);
+    return op.u.physinfo.nr_cpus;
 }
 
 
diff -r 398a0cdf3e31 -r f9779dd3e52b xen/arch/ia64/xen/dom0_ops.c
--- a/xen/arch/ia64/xen/dom0_ops.c      Fri Dec 16 17:02:16 2005
+++ b/xen/arch/ia64/xen/dom0_ops.c      Fri Dec 16 17:47:48 2005
@@ -204,6 +204,7 @@
         pi->sockets_per_node = 
             num_online_cpus() / (pi->threads_per_core * pi->cores_per_socket);
         pi->nr_nodes         = 1;
+        pi->nr_cpus          = (u32)num_online_cpus();
         pi->total_pages      = 99;  // FIXME
         pi->free_pages       = avail_domheap_pages();
         pi->cpu_khz          = 100;  // FIXME cpu_khz;
diff -r 398a0cdf3e31 -r f9779dd3e52b xen/arch/x86/dom0_ops.c
--- a/xen/arch/x86/dom0_ops.c   Fri Dec 16 17:02:16 2005
+++ b/xen/arch/x86/dom0_ops.c   Fri Dec 16 17:47:48 2005
@@ -188,6 +188,7 @@
         pi->cores_per_socket = boot_cpu_data.x86_num_cores;
         pi->sockets_per_node = 
             num_online_cpus() / (pi->threads_per_core * pi->cores_per_socket);
+        pi->nr_cpus          = (u32)num_online_cpus();
         pi->total_pages      = total_pages;
         pi->free_pages       = avail_domheap_pages();
         pi->cpu_khz          = cpu_khz;
diff -r 398a0cdf3e31 -r f9779dd3e52b xen/include/public/dom0_ops.h
--- a/xen/include/public/dom0_ops.h     Fri Dec 16 17:02:16 2005
+++ b/xen/include/public/dom0_ops.h     Fri Dec 16 17:47:48 2005
@@ -200,6 +200,7 @@
     uint32_t cores_per_socket;
     uint32_t sockets_per_node;
     uint32_t nr_nodes;
+    uint32_t nr_cpus;
     uint32_t cpu_khz;
     unsigned long total_pages;
     unsigned long free_pages;

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] 6/7 xen: Add basic NUMA support - Physinfo nr_cpus, Ryan Harper <=