2 # SPDX-License-Identifier: GPL-2.0
5 #we need 256M, below is the size in kB
10 #get pagesize and freepages from /proc/meminfo
11 while read name size unit
; do
12 if [ "$name" = "HugePages_Free:" ]; then
15 if [ "$name" = "Hugepagesize:" ]; then
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`
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
30 echo "Please run this test as root"
33 while read name size unit
; do
34 if [ "$name" = "HugePages_Free:" ]; then
40 if [ $freepgs -lt $needpgs ]; then
41 printf "Not enough huge pages available (%d < %d)\n" \
46 echo "no hugetlbfs support in kernel?"
51 mount
-t hugetlbfs none
$mnt
53 echo "---------------------"
54 echo "running hugepage-mmap"
55 echo "---------------------"
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 "--------------------"
78 echo $shmmax > /proc
/sys
/kernel
/shmmax
79 echo $shmall > /proc
/sys
/kernel
/shmall
81 echo "-------------------"
82 echo "running map_hugetlb"
83 echo "-------------------"
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
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
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
134 echo $nr_hugepgs > /proc
/sys
/vm
/nr_hugepages
136 echo "-----------------------"
137 echo "running compaction_test"
138 echo "-----------------------"
140 if [ $?
-ne 0 ]; then
147 echo "----------------------"
148 echo "running on-fault-limit"
149 echo "----------------------"
150 sudo
-u nobody .
/on-fault-limit
151 if [ $?
-ne 0 ]; then
158 echo "--------------------"
159 echo "running mlock2-tests"
160 echo "--------------------"
162 if [ $?
-ne 0 ]; then
169 echo "-----------------------------"
170 echo "running virtual_address_range"
171 echo "-----------------------------"
172 .
/virtual_address_range
173 if [ $?
-ne 0 ]; then
180 echo "-----------------------------"
181 echo "running virtual address 128TB switch test"
182 echo "-----------------------------"
184 if [ $?
-ne 0 ]; then