~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/memfd/run_hugetlbfs_test.sh

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/bash
  2 # please run as root
  3 
  4 # Kselftest framework requirement - SKIP code is 4.
  5 ksft_skip=4
  6 
  7 #
  8 # To test memfd_create with hugetlbfs, there needs to be hpages_test
  9 # huge pages free.  Attempt to allocate enough pages to test.
 10 #
 11 hpages_test=8
 12 
 13 #
 14 # Get count of free huge pages from /proc/meminfo
 15 #
 16 while read name size unit; do
 17         if [ "$name" = "HugePages_Free:" ]; then
 18                 freepgs=$size
 19         fi
 20 done < /proc/meminfo
 21 
 22 #
 23 # If not enough free huge pages for test, attempt to increase
 24 #
 25 if [ -n "$freepgs" ] && [ $freepgs -lt $hpages_test ]; then
 26         nr_hugepgs=`cat /proc/sys/vm/nr_hugepages`
 27         hpages_needed=`expr $hpages_test - $freepgs`
 28 
 29         if [ $UID != 0 ]; then
 30                 echo "Please run memfd with hugetlbfs test as root"
 31                 exit $ksft_skip
 32         fi
 33 
 34         echo 3 > /proc/sys/vm/drop_caches
 35         echo $(( $hpages_needed + $nr_hugepgs )) > /proc/sys/vm/nr_hugepages
 36         while read name size unit; do
 37                 if [ "$name" = "HugePages_Free:" ]; then
 38                         freepgs=$size
 39                 fi
 40         done < /proc/meminfo
 41 fi
 42 
 43 #
 44 # If still not enough huge pages available, exit.  But, give back any huge
 45 # pages potentially allocated above.
 46 #
 47 if [ $freepgs -lt $hpages_test ]; then
 48         # nr_hugepgs non-zero only if we attempted to increase
 49         if [ -n "$nr_hugepgs" ]; then
 50                 echo $nr_hugepgs > /proc/sys/vm/nr_hugepages
 51         fi
 52         printf "Not enough huge pages available (%d < %d)\n" \
 53                 $freepgs $needpgs
 54         exit $ksft_skip
 55 fi
 56 
 57 #
 58 # Run the hugetlbfs test
 59 #
 60 ./memfd_test hugetlbfs
 61 ./run_fuse_test.sh hugetlbfs
 62 
 63 #
 64 # Give back any huge pages allocated for the test
 65 #
 66 if [ -n "$nr_hugepgs" ]; then
 67         echo $nr_hugepgs > /proc/sys/vm/nr_hugepages
 68 fi

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php