Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / tools / testing / selftests / vm / run_vmtests
blobd2561895a021a4fc87822938c4485fcf85aff933
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 #please run as root
5 #we need 256M, below is the size in kB
6 needmem=262144
7 mnt=./huge
8 exitcode=0
10 #get pagesize and freepages from /proc/meminfo
11 while read name size unit; do
12 if [ "$name" = "HugePages_Free:" ]; then
13 freepgs=$size
15 if [ "$name" = "Hugepagesize:" ]; then
16 pgsize=$size
18 done < /proc/meminfo
20 #set proper nr_hugepages
21 if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then
22 nr_hugepgs=`cat /proc/sys/vm/nr_hugepages`
23 needpgs=`expr $needmem / $pgsize`
24 tries=2
25 while [ $tries -gt 0 ] && [ $freepgs -lt $needpgs ]; do
26 lackpgs=$(( $needpgs - $freepgs ))
27 echo 3 > /proc/sys/vm/drop_caches
28 echo $(( $lackpgs + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages
29 if [ $? -ne 0 ]; then
30 echo "Please run this test as root"
31 exit 1
33 while read name size unit; do
34 if [ "$name" = "HugePages_Free:" ]; then
35 freepgs=$size
37 done < /proc/meminfo
38 tries=$((tries - 1))
39 done
40 if [ $freepgs -lt $needpgs ]; then
41 printf "Not enough huge pages available (%d < %d)\n" \
42 $freepgs $needpgs
43 exit 1
45 else
46 echo "no hugetlbfs support in kernel?"
47 exit 1
50 mkdir $mnt
51 mount -t hugetlbfs none $mnt
53 echo "---------------------"
54 echo "running hugepage-mmap"
55 echo "---------------------"
56 ./hugepage-mmap
57 if [ $? -ne 0 ]; then
58 echo "[FAIL]"
59 exitcode=1
60 else
61 echo "[PASS]"
64 shmmax=`cat /proc/sys/kernel/shmmax`
65 shmall=`cat /proc/sys/kernel/shmall`
66 echo 268435456 > /proc/sys/kernel/shmmax
67 echo 4194304 > /proc/sys/kernel/shmall
68 echo "--------------------"
69 echo "running hugepage-shm"
70 echo "--------------------"
71 ./hugepage-shm
72 if [ $? -ne 0 ]; then
73 echo "[FAIL]"
74 exitcode=1
75 else
76 echo "[PASS]"
78 echo $shmmax > /proc/sys/kernel/shmmax
79 echo $shmall > /proc/sys/kernel/shmall
81 echo "-------------------"
82 echo "running map_hugetlb"
83 echo "-------------------"
84 ./map_hugetlb
85 if [ $? -ne 0 ]; then
86 echo "[FAIL]"
87 exitcode=1
88 else
89 echo "[PASS]"
92 echo "NOTE: The above hugetlb tests provide minimal coverage. Use"
93 echo " https://github.com/libhugetlbfs/libhugetlbfs.git for"
94 echo " hugetlb regression testing."
96 echo "-------------------"
97 echo "running userfaultfd"
98 echo "-------------------"
99 ./userfaultfd anon 128 32
100 if [ $? -ne 0 ]; then
101 echo "[FAIL]"
102 exitcode=1
103 else
104 echo "[PASS]"
107 echo "---------------------------"
108 echo "running userfaultfd_hugetlb"
109 echo "---------------------------"
110 # 256MB total huge pages == 128MB src and 128MB dst
111 ./userfaultfd hugetlb 128 32 $mnt/ufd_test_file
112 if [ $? -ne 0 ]; then
113 echo "[FAIL]"
114 exitcode=1
115 else
116 echo "[PASS]"
118 rm -f $mnt/ufd_test_file
120 echo "-------------------------"
121 echo "running userfaultfd_shmem"
122 echo "-------------------------"
123 ./userfaultfd shmem 128 32
124 if [ $? -ne 0 ]; then
125 echo "[FAIL]"
126 exitcode=1
127 else
128 echo "[PASS]"
131 #cleanup
132 umount $mnt
133 rm -rf $mnt
134 echo $nr_hugepgs > /proc/sys/vm/nr_hugepages
136 echo "-----------------------"
137 echo "running compaction_test"
138 echo "-----------------------"
139 ./compaction_test
140 if [ $? -ne 0 ]; then
141 echo "[FAIL]"
142 exitcode=1
143 else
144 echo "[PASS]"
147 echo "----------------------"
148 echo "running on-fault-limit"
149 echo "----------------------"
150 sudo -u nobody ./on-fault-limit
151 if [ $? -ne 0 ]; then
152 echo "[FAIL]"
153 exitcode=1
154 else
155 echo "[PASS]"
158 echo "--------------------"
159 echo "running mlock2-tests"
160 echo "--------------------"
161 ./mlock2-tests
162 if [ $? -ne 0 ]; then
163 echo "[FAIL]"
164 exitcode=1
165 else
166 echo "[PASS]"
169 echo "-----------------------------"
170 echo "running virtual_address_range"
171 echo "-----------------------------"
172 ./virtual_address_range
173 if [ $? -ne 0 ]; then
174 echo "[FAIL]"
175 exitcode=1
176 else
177 echo "[PASS]"
180 echo "-----------------------------"
181 echo "running virtual address 128TB switch test"
182 echo "-----------------------------"
183 ./va_128TBswitch
184 if [ $? -ne 0 ]; then
185 echo "[FAIL]"
186 exitcode=1
187 else
188 echo "[PASS]"
191 exit $exitcode