-
Notifications
You must be signed in to change notification settings - Fork 143
/
checktopology
executable file
·54 lines (47 loc) · 1.37 KB
/
checktopology
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
43
44
45
46
47
48
49
50
51
52
53
54
#!/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=$(nproc)
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' )
node_has_cpus=""
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
if [ -s /sys/devices/system/node/has_cpu ]; then
node_has_cpus=$(cat /sys/devices/system/node/has_cpu | sed 's/,/ /')
fi
numactl --hardware | grep cpus | while read n ; do
node=${n/ cpus*/}
node=${node/ /}
cpus=${n/*: /}
check_node=$(echo $node | sed 's/node//')
if [[ -n ${node_has_cpus} ]]; then
if ! [[ "${node_has_cpus}" == *"$check_node"* ]]; then
echo "Skipping cpu less $node"
continue
fi
fi
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