-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_hugepage_pingpong.sh
108 lines (98 loc) · 2.95 KB
/
setup_hugepage_pingpong.sh
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
105
106
107
108
#!/bin/bash
check_and_define_tp hugepage_pingpong
TESTFILE=${WDIR}/testfile
kill_test_programs() {
pkill -9 -f $hugepage_pingpong
return 0
}
prepare_hugepage_pingpong() {
if ! [ "$NUMNODE" -gt 1 ] ; then
echo "No NUMA system" | tee -a ${OFILE}
return 1
fi
kill_test_programs 2> /dev/null
ipcrm --all > /dev/null 2>&1
rm -rf ${WDIR}/mount/* 2> /dev/null
umount -f ${WDIR}/mount 2> /dev/null
hugetlb_empty_check
get_kernel_message_before
sysctl vm.nr_hugepages=10 # $HPNUM
mkdir -p ${WDIR}/mount
mount -t hugetlbfs none ${WDIR}/mount
}
cleanup_hugepage_pingpong() {
kill_test_programs 2> /dev/null
ipcrm --all > /dev/null 2>&1
echo "remove hugetlbfs files" | tee -a ${OFILE}
rm -rf ${WDIR}/mount/*
echo "umount hugetlbfs" | tee -a ${OFILE}
umount -f ${WDIR}/mount
sysctl vm.nr_hugepages=0
sleep 1
hugetlb_empty_check
get_kernel_message_after
get_kernel_message_diff | tee -a ${OFILE}
}
control_hugepage_pingpong() {
echo "start hugepage_pingpong" | tee -a ${OFILE}
$hugepage_pingpong -n 10 -t 0xff > ${TMPF}.fuz.out 2>&1 &
local pid=$!
echo "pid $pid"
sleep 10
pkill -SIGUSR1 $pid
set_return_code EXIT
}
control_hugepage_pingpong_race() {
local nr_proc=$PINGPONG_NR_PROC
local nr_hps=$PINGPONG_NR_HPS
local type=$PINGPONG_ALLOC_TYPES
local i=
local pids=""
echo "start $nr_proc hugepage_pingpong processes" | tee -a ${OFILE}
for i in $(seq $nr_proc) ; do
$hugepage_pingpong -n $nr_hps -t $type > ${TMPF}.fuz.out$i 2>&1 &
pids="$pids $!"
done
sleep 10
kill -SIGUSR1 $pids
set_return_code EXIT
}
NUMA_MAPS_READER=${TMPF}.read_numa_maps.sh
cat <<EOF > ${NUMA_MAPS_READER}
for pid in \$@ true ; do
cat /proc/\$pid/numa_maps > /dev/null 2>&1
done
EOF
control_hugepage_pingpong_race_with_numa_maps() {
local nr_proc=$PINGPONG_NR_PROC
local nr_hps=$PINGPONG_NR_HPS
local type=$PINGPONG_ALLOC_TYPES
[ ! "$nr_proc" ] && echo "you must give PINGPONG_NR_PROC= in recipe" && return 1
[ ! "$nr_hps" ] && echo "you must give PINGPONG_NR_HPS= in recipe" && return 1
[ ! "$type" ] && echo "you must give PINGPONG_ALLOC_TYPES= in recipe" && return 1
local i=0
local cmd="bash ${NUMA_MAPS_READER}"
local pids=""
local reader_pid=
echo "start $nr_proc hugepage_pingpong processes" | tee -a ${OFILE}
for i in $(seq $nr_proc) ; do
$hugepage_pingpong -n $nr_hps -t $type > ${TMPF}.fuz.out$i 2>&1 &
pids="$pids $!"
done
# eval "$cmd $pids" &
# reader_pid=$!
sleep 10
# kill -SIGKILL $reader_pid
kill -SIGUSR1 $pids
set_return_code EXIT
}
# inside cheker you must tee output in you own.
check_hugepage_pingpong() {
check_kernel_message -v "failed"
check_kernel_message_nobug
check_return_code "${EXPECTED_RETURN_CODE}"
__check_hugepage_pingpong
}
__check_hugepage_pingpong() {
echo "check done." | tee -a ${OFILE}
}