Alex Williamson
2007-Jul-10 05:36 UTC
[Xen-devel] [PATCH] Re: [Xen-staging] [xen-unstable] Extended the physinfo sysctl to export NUMA cpu_to_node topology info.
On Fri, 2007-07-06 at 16:14 +0100, Xen staging patchbot-unstable wrote:> # HG changeset patch > # User kfraser@localhost.localdomain > # Date 1183734727 -3600 > # Node ID 89d2192942befb0daf56e730be61d3a3c06926dd > # Parent 538c3d8aa4b14833174423ec506284279d5a33ab > Extended the physinfo sysctl to export NUMA cpu_to_node topology info. > Print this in ''xm info''....> diff -r 538c3d8aa4b1 -r 89d2192942be tools/python/xen/xend/XendNode.py > --- a/tools/python/xen/xend/XendNode.py Fri Jul 06 15:01:20 2007 +0100 > +++ b/tools/python/xen/xend/XendNode.py Fri Jul 06 16:12:07 2007 +0100...> + def format_pairs(self,pairs): > + if not pairs: > + return "no cpus"We add support here for nodes w/o cpus, but the existing code blindly assumes all nodes have cpus later on: info[''nr_cpus''] = (info[''nr_nodes''] * info[''sockets_per_node''] * info[''cores_per_socket''] * info[''threads_per_core'']) How about we count the cpus in the node_to_cpu list to avoid mistakes? Here''s the output on a system where this gave strange results before: nr_cpus : 8 nr_nodes : 3 sockets_per_node : 4 cores_per_socket : 1 threads_per_core : 1 ... node_to_cpu : node0:0-3 node1:4-7 node2:no cpus BTW, I don''t know a case where it fails, but assuming sockets_per_node is a constant for the system seems risky. Thanks, Alex Count CPUs rather than relying on a static nodes/sockets/cores/threads relationship. Signed-off-by: Alex Williamson <alex.williamson@hp.com> --- diff -r ef0a5778e3ac tools/python/xen/xend/XendNode.py --- a/tools/python/xen/xend/XendNode.py Mon Jul 09 10:59:56 2007 -0600 +++ b/tools/python/xen/xend/XendNode.py Mon Jul 09 23:12:33 2007 -0600 @@ -580,14 +580,17 @@ 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''] = (info[''nr_nodes''] * - info[''sockets_per_node''] * - info[''cores_per_socket''] * - info[''threads_per_core'']) + info[''nr_cpus''] = self.count_cpus(info) info[''cpu_mhz''] = info[''cpu_khz''] / 1000 # physinfo is in KiB, need it in MiB _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel