2 # SPDX-License-Identifier: GPL-2.0
5 # Kselftest framework requirement - SKIP code is 4.
11 #get huge pagesize and freepages from /proc/meminfo
12 while read name size unit
; do
13 if [ "$name" = "HugePages_Free:" ]; then
16 if [ "$name" = "Hugepagesize:" ]; then
21 # Simple hugetlbfs tests have a hardcoded minimum requirement of
22 # huge pages totaling 256MB (262144KB) in size. The userfaultfd
23 # hugetlb test requires a minimum of 2 * nr_cpus huge pages. Take
24 # both of these requirements into account and attempt to increase
25 # number of huge pages available.
27 hpgsize_MB
=$
((hpgsize_KB
/ 1024))
28 half_ufd_size_MB
=$
((((nr_cpus
* hpgsize_MB
+ 127) / 128) * 128))
29 needmem_KB
=$
((half_ufd_size_MB
* 2 * 1024))
31 #set proper nr_hugepages
32 if [ -n "$freepgs" ] && [ -n "$hpgsize_KB" ]; then
33 nr_hugepgs
=`cat /proc/sys/vm/nr_hugepages`
34 needpgs
=$
((needmem_KB
/ hpgsize_KB
))
36 while [ $tries -gt 0 ] && [ $freepgs -lt $needpgs ]; do
37 lackpgs
=$
(( $needpgs - $freepgs ))
38 echo 3 > /proc
/sys
/vm
/drop_caches
39 echo $
(( $lackpgs + $nr_hugepgs )) > /proc
/sys
/vm
/nr_hugepages
41 echo "Please run this test as root"
44 while read name size unit
; do
45 if [ "$name" = "HugePages_Free:" ]; then
51 if [ $freepgs -lt $needpgs ]; then
52 printf "Not enough huge pages available (%d < %d)\n" \
57 echo "no hugetlbfs support in kernel?"
61 #filter 64bit architectures
62 ARCH64STR
="arm64 ia64 mips64 parisc64 ppc64 riscv64 s390x sh64 sparc64 x86_64"
64 ARCH
=`uname -m 2>/dev/null | sed -e 's/aarch64.*/arm64/'`
67 echo "$ARCH64STR" |
grep $ARCH && VADDR64
=1
70 mount
-t hugetlbfs none
$mnt
72 echo "---------------------"
73 echo "running hugepage-mmap"
74 echo "---------------------"
83 shmmax
=`cat /proc/sys/kernel/shmmax`
84 shmall
=`cat /proc/sys/kernel/shmall`
85 echo 268435456 > /proc
/sys
/kernel
/shmmax
86 echo 4194304 > /proc
/sys
/kernel
/shmall
87 echo "--------------------"
88 echo "running hugepage-shm"
89 echo "--------------------"
97 echo $shmmax > /proc
/sys
/kernel
/shmmax
98 echo $shmall > /proc
/sys
/kernel
/shmall
100 echo "-------------------"
101 echo "running map_hugetlb"
102 echo "-------------------"
104 if [ $?
-ne 0 ]; then
111 echo "NOTE: The above hugetlb tests provide minimal coverage. Use"
112 echo " https://github.com/libhugetlbfs/libhugetlbfs.git for"
113 echo " hugetlb regression testing."
115 echo "-------------------"
116 echo "running userfaultfd"
117 echo "-------------------"
118 .
/userfaultfd anon
128 32
119 if [ $?
-ne 0 ]; then
126 echo "---------------------------"
127 echo "running userfaultfd_hugetlb"
128 echo "---------------------------"
129 # Test requires source and destination huge pages. Size of source
130 # (half_ufd_size_MB) is passed as argument to test.
131 .
/userfaultfd hugetlb
$half_ufd_size_MB 32 $mnt/ufd_test_file
132 if [ $?
-ne 0 ]; then
138 rm -f $mnt/ufd_test_file
140 echo "-------------------------"
141 echo "running userfaultfd_shmem"
142 echo "-------------------------"
143 .
/userfaultfd shmem
128 32
144 if [ $?
-ne 0 ]; then
154 echo $nr_hugepgs > /proc
/sys
/vm
/nr_hugepages
156 echo "-----------------------"
157 echo "running compaction_test"
158 echo "-----------------------"
160 if [ $?
-ne 0 ]; then
167 echo "----------------------"
168 echo "running on-fault-limit"
169 echo "----------------------"
170 sudo
-u nobody .
/on-fault-limit
171 if [ $?
-ne 0 ]; then
178 echo "--------------------"
179 echo "running map_populate"
180 echo "--------------------"
182 if [ $?
-ne 0 ]; then
189 echo "--------------------"
190 echo "running mlock2-tests"
191 echo "--------------------"
193 if [ $?
-ne 0 ]; then
200 if [ $VADDR64 -ne 0 ]; then
201 echo "-----------------------------"
202 echo "running virtual_address_range"
203 echo "-----------------------------"
204 .
/virtual_address_range
205 if [ $?
-ne 0 ]; then
212 echo "-----------------------------"
213 echo "running virtual address 128TB switch test"
214 echo "-----------------------------"
216 if [ $?
-ne 0 ]; then
224 echo "------------------------------------"
225 echo "running vmalloc stability smoke test"
226 echo "------------------------------------"
227 .
/test_vmalloc.sh smoke
230 if [ $ret_val -eq 0 ]; then
232 elif [ $ret_val -eq $ksft_skip ]; then