[PATCH] libnuma: test/checkaffinity

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Cliff Wickman <cpw@xxxxxxx>

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@xxxxxxx>

---
 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
--
To unsubscribe from this list: send the line "unsubscribe linux-numa" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]     [Devices]

  Powered by Linux