All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@hp.com>
To: xen-devel@lists.xensource.com
Cc: ryanh@us.ibm.com, Keir Fraser <keir@xensource.com>
Subject: [PATCH] Re: [Xen-staging] [xen-unstable] Extended the physinfo sysctl to export NUMA cpu_to_node topology info.
Date: Mon, 09 Jul 2007 23:36:17 -0600	[thread overview]
Message-ID: <1184045777.13469.20.camel@bling> (raw)
In-Reply-To: <200707061514.l66FEMix029568@latara.uk.xensource.com>

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

      parent reply	other threads:[~2007-07-10  5:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200707061514.l66FEMix029568@latara.uk.xensource.com>
2007-07-10  3:57 ` [Xen-staging] [xen-unstable] Extended the physinfo sysctl to export NUMA cpu_to_node topology info Alex Williamson
2007-07-10  8:35   ` Keir Fraser
2007-07-10  5:36 ` Alex Williamson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1184045777.13469.20.camel@bling \
    --to=alex.williamson@hp.com \
    --cc=keir@xensource.com \
    --cc=ryanh@us.ibm.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.