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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
#!/bin/sh
# basic shared memory policy test
# hugetlbfs and tmpfs must be mounted on these mount points
TMPFS=/dev/shm
HUGE=/huge
#valgrind 3.0.1 doesn't implement mbind() yet on x86-64
#VALGRIND="valgrind --tool=memcheck"
VALGRIND=
set -e
export PATH=`pwd`/..:$PATH
numactl() {
$VALGRIND ../numactl "$@"
}
failure() {
numastat > after
set +e
diff -u before after
echo
echo TEST FAILED
exit 1
}
success() {
echo test succeeded
}
checkpoint() {
numastat > before
}
trap failure EXIT
basictest() {
echo initial
checkpoint
numactl --length=20m $1 --dump
echo interleave
checkpoint
numactl --offset=2m --length=2m $1 --strict --interleave=0,1 --verify --dump
echo interleave verify
checkpoint
numactl $1 --dump
echo membind setup
checkpoint
numactl --offset 4m --length=2m $1 --strict --membind=1 --verify --dump
echo membind verify
checkpoint
numactl $1 --dump
echo preferred setup
checkpoint
numactl --offset 6m --length 2m $1 --strict --preferred=1 --verify --dump
echo preferred verify
checkpoint
numactl $1 --dump
# check overlaps here
}
cleanupshm() {
if [ -f $1 ] ; then
ipcrm -M `./ftok $1` || true
rm $1
fi
}
banner() {
echo
echo ++++++++++++ $1 +++++++++++++++
echo
}
banner shm
cleanupshm A
basictest --shm=A
cleanupshm A
banner hugeshm
cleanupshm B
basictest "--huge --shm=B"
cleanupshm B
banner tmpfs
basictest "--file $TMPFS/B"
rm $TMPFS/B
# first need a way to create holey hugetlbfs files.
#banner hugetlbfs
#basictest "--file $HUGE/B"
#rm /hugetlbfs/B
rm before
trap success EXIT
|