Home | History | Annotate | Download | only in vm
      1 #!/bin/bash
      2 # SPDX-License-Identifier: GPL-2.0
      3 #please run as root
      4 
      5 # Kselftest framework requirement - SKIP code is 4.
      6 ksft_skip=4
      7 
      8 mnt=./huge
      9 exitcode=0
     10 
     11 ##get huge pagesize and freepages from /proc/meminfo
     12 #while read name size unit; do
     13 #	if [ "$name" = "HugePages_Free:" ]; then
     14 #		freepgs=$size
     15 #	fi
     16 #	if [ "$name" = "Hugepagesize:" ]; then
     17 #		hpgsize_KB=$size
     18 #	fi
     19 #done < /proc/meminfo
     20 #
     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.
     26 #nr_cpus=$(nproc)
     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))
     30 #
     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))
     35 #	tries=2
     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
     40 #		if [ $? -ne 0 ]; then
     41 #			echo "Please run this test as root"
     42 #			exit $ksft_skip
     43 #		fi
     44 #		while read name size unit; do
     45 #			if [ "$name" = "HugePages_Free:" ]; then
     46 #				freepgs=$size
     47 #			fi
     48 #		done < /proc/meminfo
     49 #		tries=$((tries - 1))
     50 #	done
     51 #	if [ $freepgs -lt $needpgs ]; then
     52 #		printf "Not enough huge pages available (%d < %d)\n" \
     53 #		       $freepgs $needpgs
     54 #		exit 1
     55 #	fi
     56 #else
     57 #	echo "no hugetlbfs support in kernel?"
     58 #	exit 1
     59 #fi
     60 #
     61 #mkdir $mnt
     62 #mount -t hugetlbfs none $mnt
     63 #
     64 #echo "---------------------"
     65 #echo "running hugepage-mmap"
     66 #echo "---------------------"
     67 #./hugepage-mmap
     68 #if [ $? -ne 0 ]; then
     69 #	echo "[FAIL]"
     70 #	exitcode=1
     71 #else
     72 #	echo "[PASS]"
     73 #fi
     74 #
     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 "--------------------"
     82 #./hugepage-shm
     83 #if [ $? -ne 0 ]; then
     84 #	echo "[FAIL]"
     85 #	exitcode=1
     86 #else
     87 #	echo "[PASS]"
     88 #fi
     89 #echo $shmmax > /proc/sys/kernel/shmmax
     90 #echo $shmall > /proc/sys/kernel/shmall
     91 #
     92 #echo "-------------------"
     93 #echo "running map_hugetlb"
     94 #echo "-------------------"
     95 #./map_hugetlb
     96 #if [ $? -ne 0 ]; then
     97 #	echo "[FAIL]"
     98 #	exitcode=1
     99 #else
    100 #	echo "[PASS]"
    101 #fi
    102 #
    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."
    106 #
    107 #echo "-------------------"
    108 #echo "running userfaultfd"
    109 #echo "-------------------"
    110 #./userfaultfd anon 128 32
    111 #if [ $? -ne 0 ]; then
    112 #	echo "[FAIL]"
    113 #	exitcode=1
    114 #else
    115 #	echo "[PASS]"
    116 #fi
    117 #
    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
    125 #	echo "[FAIL]"
    126 #	exitcode=1
    127 #else
    128 #	echo "[PASS]"
    129 #fi
    130 #rm -f $mnt/ufd_test_file
    131 #
    132 #echo "-------------------------"
    133 #echo "running userfaultfd_shmem"
    134 #echo "-------------------------"
    135 #./userfaultfd shmem 128 32
    136 #if [ $? -ne 0 ]; then
    137 #	echo "[FAIL]"
    138 #	exitcode=1
    139 #else
    140 #	echo "[PASS]"
    141 #fi
    142 #
    143 ##cleanup
    144 #umount $mnt
    145 #rm -rf $mnt
    146 #echo $nr_hugepgs > /proc/sys/vm/nr_hugepages
    147 #
    148 #echo "-----------------------"
    149 #echo "running compaction_test"
    150 #echo "-----------------------"
    151 #./compaction_test
    152 #if [ $? -ne 0 ]; then
    153 #	echo "[FAIL]"
    154 #	exitcode=1
    155 #else
    156 #	echo "[PASS]"
    157 #fi
    158 
    159 echo "----------------------"
    160 echo "running on-fault-limit"
    161 echo "----------------------"
    162 sudo -u nobody ./on-fault-limit
    163 if [ $? -ne 0 ]; then
    164 	echo "[FAIL]"
    165 	exitcode=1
    166 else
    167 	echo "[PASS]"
    168 fi
    169 
    170 echo "--------------------"
    171 echo "running map_populate"
    172 echo "--------------------"
    173 ./map_populate
    174 if [ $? -ne 0 ]; then
    175 	echo "[FAIL]"
    176 	exitcode=1
    177 else
    178 	echo "[PASS]"
    179 fi
    180 
    181 echo "--------------------"
    182 echo "running mlock2-tests"
    183 echo "--------------------"
    184 ./mlock2-tests
    185 if [ $? -ne 0 ]; then
    186 	echo "[FAIL]"
    187 	exitcode=1
    188 else
    189 	echo "[PASS]"
    190 fi
    191 
    192 echo "-----------------------------"
    193 echo "running virtual_address_range"
    194 echo "-----------------------------"
    195 ./virtual_address_range
    196 if [ $? -ne 0 ]; then
    197 	echo "[FAIL]"
    198 	exitcode=1
    199 else
    200 	echo "[PASS]"
    201 fi
    202 
    203 echo "-----------------------------"
    204 echo "running virtual address 128TB switch test"
    205 echo "-----------------------------"
    206 ./va_128TBswitch
    207 if [ $? -ne 0 ]; then
    208     echo "[FAIL]"
    209     exitcode=1
    210 else
    211     echo "[PASS]"
    212 fi
    213 
    214 exit $exitcode
    215