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?"
62 mount
-t hugetlbfs none
$mnt
64 echo "---------------------"
65 echo "running hugepage-mmap"
66 echo "---------------------"
75 shmmax
=`cat /proc/sys/kernel/shmmax`
76 shmall
=`cat /proc/sys/kernel/shmall`
77 echo 268435456 > /proc
/sys
/kernel
/shmmax
78 echo 4194304 > /proc
/sys
/kernel
/shmall
79 echo "--------------------"
80 echo "running hugepage-shm"
81 echo "--------------------"
89 echo $shmmax > /proc
/sys
/kernel
/shmmax
90 echo $shmall > /proc
/sys
/kernel
/shmall
92 echo "-------------------"
93 echo "running map_hugetlb"
94 echo "-------------------"
103 echo "NOTE: The above hugetlb tests provide minimal coverage. Use"
104 echo " https://github.com/libhugetlbfs/libhugetlbfs.git for"
105 echo " hugetlb regression testing."
107 echo "-------------------"
108 echo "running userfaultfd"
109 echo "-------------------"
110 .
/userfaultfd anon
128 32
111 if [ $?
-ne 0 ]; then
118 echo "---------------------------"
119 echo "running userfaultfd_hugetlb"
120 echo "---------------------------"
121 # Test requires source and destination huge pages. Size of source
122 # (half_ufd_size_MB) is passed as argument to test.
123 .
/userfaultfd hugetlb
$half_ufd_size_MB 32 $mnt/ufd_test_file
124 if [ $?
-ne 0 ]; then
130 rm -f $mnt/ufd_test_file
132 echo "-------------------------"
133 echo "running userfaultfd_shmem"
134 echo "-------------------------"
135 .
/userfaultfd shmem
128 32
136 if [ $?
-ne 0 ]; then
146 echo $nr_hugepgs > /proc
/sys
/vm
/nr_hugepages
148 echo "-----------------------"
149 echo "running compaction_test"
150 echo "-----------------------"
152 if [ $?
-ne 0 ]; then
159 echo "----------------------"
160 echo "running on-fault-limit"
161 echo "----------------------"
162 sudo
-u nobody .
/on-fault-limit
163 if [ $?
-ne 0 ]; then
170 echo "--------------------"
171 echo "running map_populate"
172 echo "--------------------"
174 if [ $?
-ne 0 ]; then
181 echo "--------------------"
182 echo "running mlock2-tests"
183 echo "--------------------"
185 if [ $?
-ne 0 ]; then
192 echo "-----------------------------"
193 echo "running virtual_address_range"
194 echo "-----------------------------"
195 .
/virtual_address_range
196 if [ $?
-ne 0 ]; then
203 echo "-----------------------------"
204 echo "running virtual address 128TB switch test"
205 echo "-----------------------------"
207 if [ $?
-ne 0 ]; then
214 echo "------------------------------------"
215 echo "running vmalloc stability smoke test"
216 echo "------------------------------------"
217 .
/test_vmalloc.sh smoke
220 if [ $ret_val -eq 0 ]; then
222 elif [ $ret_val -eq $ksft_skip ]; then