1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3#please run as root 4 5# Kselftest framework requirement - SKIP code is 4. 6ksft_skip=4 7 8mnt=./huge 9exitcode=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##filter 64bit architectures 62#ARCH64STR="arm64 ia64 mips64 parisc64 ppc64 riscv64 s390x sh64 sparc64 x86_64" 63#if [ -z $ARCH ]; then 64# ARCH=`uname -m 2>/dev/null | sed -e 's/aarch64.*/arm64/'` 65#fi 66#VADDR64=0 67#echo "$ARCH64STR" | grep $ARCH && VADDR64=1 68# 69#mkdir $mnt 70#mount -t hugetlbfs none $mnt 71# 72#echo "---------------------" 73#echo "running hugepage-mmap" 74#echo "---------------------" 75#./hugepage-mmap 76#if [ $? -ne 0 ]; then 77# echo "[FAIL]" 78# exitcode=1 79#else 80# echo "[PASS]" 81#fi 82# 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 "--------------------" 90#./hugepage-shm 91#if [ $? -ne 0 ]; then 92# echo "[FAIL]" 93# exitcode=1 94#else 95# echo "[PASS]" 96#fi 97#echo $shmmax > /proc/sys/kernel/shmmax 98#echo $shmall > /proc/sys/kernel/shmall 99# 100#echo "-------------------" 101#echo "running map_hugetlb" 102#echo "-------------------" 103#./map_hugetlb 104#if [ $? -ne 0 ]; then 105# echo "[FAIL]" 106# exitcode=1 107#else 108# echo "[PASS]" 109#fi 110# 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." 114# 115#echo "-------------------" 116#echo "running userfaultfd" 117#echo "-------------------" 118#./userfaultfd anon 128 32 119#if [ $? -ne 0 ]; then 120# echo "[FAIL]" 121# exitcode=1 122#else 123# echo "[PASS]" 124#fi 125# 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 133# echo "[FAIL]" 134# exitcode=1 135#else 136# echo "[PASS]" 137#fi 138#rm -f $mnt/ufd_test_file 139# 140#echo "-------------------------" 141#echo "running userfaultfd_shmem" 142#echo "-------------------------" 143#./userfaultfd shmem 128 32 144#if [ $? -ne 0 ]; then 145# echo "[FAIL]" 146# exitcode=1 147#else 148# echo "[PASS]" 149#fi 150# 151##cleanup 152#umount $mnt 153#rm -rf $mnt 154#echo $nr_hugepgs > /proc/sys/vm/nr_hugepages 155# 156#echo "-----------------------" 157#echo "running compaction_test" 158#echo "-----------------------" 159#./compaction_test 160#if [ $? -ne 0 ]; then 161# echo "[FAIL]" 162# exitcode=1 163#else 164# echo "[PASS]" 165#fi 166 167echo "----------------------" 168echo "running on-fault-limit" 169echo "----------------------" 170sudo -u nobody ./on-fault-limit 171if [ $? -ne 0 ]; then 172 echo "[FAIL]" 173 exitcode=1 174else 175 echo "[PASS]" 176fi 177 178echo "--------------------" 179echo "running map_populate" 180echo "--------------------" 181./map_populate 182if [ $? -ne 0 ]; then 183 echo "[FAIL]" 184 exitcode=1 185else 186 echo "[PASS]" 187fi 188 189echo "--------------------" 190echo "running mlock2-tests" 191echo "--------------------" 192./mlock2-tests 193if [ $? -ne 0 ]; then 194 echo "[FAIL]" 195 exitcode=1 196else 197 echo "[PASS]" 198fi 199 200if [ $VADDR64 -ne 0 ]; then 201echo "-----------------------------" 202echo "running virtual_address_range" 203echo "-----------------------------" 204./virtual_address_range 205if [ $? -ne 0 ]; then 206 echo "[FAIL]" 207 exitcode=1 208else 209 echo "[PASS]" 210fi 211 212echo "-----------------------------" 213echo "running virtual address 128TB switch test" 214echo "-----------------------------" 215./va_128TBswitch 216if [ $? -ne 0 ]; then 217 echo "[FAIL]" 218 exitcode=1 219else 220 echo "[PASS]" 221fi 222fi # VADDR64 223 224echo "------------------------------------" 225echo "running vmalloc stability smoke test" 226echo "------------------------------------" 227./test_vmalloc.sh smoke 228ret_val=$? 229 230if [ $ret_val -eq 0 ]; then 231 echo "[PASS]" 232elif [ $ret_val -eq $ksft_skip ]; then 233 echo "[SKIP]" 234 exitcode=$ksft_skip 235else 236 echo "[FAIL]" 237 exitcode=1 238fi 239 240exit $exitcode 241