linux-numa.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cliff Wickman <cpw@sgi.com>
To: linux-numa@vger.kernel.org
Subject: [PATCH] libnuma: test/checkaffinity
Date: Thu, 13 Jan 2011 08:22:41 -0600	[thread overview]
Message-ID: <E1PdO4X-0007Rb-So@eag09.americas.sgi.com> (raw)

From: Cliff Wickman <cpw@sgi.com>

Fix test/checkaffinity to be cpuset aware.
This test assumed that both cpus and nodes are numbered 0..N and therefore
can fail simply because it is run in a restrictive cpuset.

Use numactl --show to generate cpuset aware lists of accessible cpus and
nodes.  libnuma uses /proc/self/status to create the lists that --show
displays.

This may seem a bit "chicken and egg", i.e. using libnuma to test libnuma.
We might use /proc/self/cpuset and /dev/cpuset to generate the lists, if
you see a problem with the below approach.

Signed-off-by: Cliff Wickman <cpw@sgi.com>

---
 test/checkaffinity |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Index: numactl-dev/test/checkaffinity
===================================================================
--- numactl-dev.orig/test/checkaffinity
+++ numactl-dev/test/checkaffinity
@@ -5,10 +5,13 @@ BASE=`pwd`/..
 export LD_LIBRARY_PATH=$BASE
 export PATH=$BASE:$PATH
 
-numcpus=$(grep -c processor /proc/cpuinfo)
-numnodes=$(ls -1d /sys/devices/system/node/node[0-9]* | wc -l )
+S=`numactl --show | grep nodebind:`
+NODES=`echo $S | sed -e "s/nodebind://"`
 
-for i in $(seq 0 $[$numcpus - 1]) ; do
+S=`numactl --show | grep physcpubind:`
+CPUS=`echo $S | sed -e "s/physcpubind://"`
+
+for i in $CPUS ; do
     if [ "$(numactl --physcpubind=$i ./printcpu)" != "$i" ] ; then
        echo "--physcpubind for $i doesn't work"
        exit 1
@@ -19,7 +22,7 @@ for i in $(seq 0 $[$numcpus - 1]) ; do
     fi
 done
 
-for i in $(seq 0 $[$numnodes - 1]) ; do
+for i in $NODES ; do
     if [ $(numactl --cpunodebind=$i numactl --show | awk '/nodebind/ { print $2 }' ) != $i ] ; then
 	echo "--show doesn't agree with cpunodebind for node $i"
 	exit 1

                 reply	other threads:[~2011-01-13 14:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=E1PdO4X-0007Rb-So@eag09.americas.sgi.com \
    --to=cpw@sgi.com \
    --cc=linux-numa@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).