File: checktopology

package info (click to toggle)
numactl 2.0.11-2.1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 1,912 kB
  • ctags: 922
  • sloc: sh: 11,860; ansic: 6,542; makefile: 104
file content (42 lines) | stat: -rwxr-xr-x 1,064 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
# check numactl --hardware output
# this checks most of the topology discovery in libnuma

testdir=`dirname "$0"`
: ${srcdir:=${testdir}/..}
: ${builddir:=${srcdir}}
export PATH=${builddir}:$PATH

numcpus=$(grep -c processor /proc/cpuinfo)
numnodes=$(ls -1d /sys/devices/system/node/node[0-9]* | wc -l)

nccpus=$(numactl --hardware | grep cpus | sed 's/node.*cpus://' | wc -w ) 
ncnodes=$(numactl --hardware | grep -c 'node.*size' ) 

if [ $numnodes != $ncnodes ] ; then
    echo "numactl --hardware doesnt report all nodes"
    exit 1
fi

if [ $numcpus != $nccpus -a \( $[$nccpus / $numnodes] != $numcpus \) ] ; then
    echo "numactl --hardware cpus look bogus"
    exit 1
fi

numactl --hardware | grep cpus | while read n ; do 
    node=${n/ cpus*/} 
    node=${node/ /}
    cpus=${n/*: /}
    k=0
    for i in $cpus ; do 
	if [ ! -h "/sys/devices/system/node/$node/cpu$i" ] ; then
	    echo "$node doesn't have cpu $i"
	    exit 1
	fi
	k=$[$k+1]
    done
    if [ $k != $(echo $cpus | wc -w) ] ; then
	echo "$node missing cpu"
	exit 1	
    fi
done