4 # Kselftest framework requirement - SKIP code is 4.
8 # To test memfd_create with hugetlbfs, there needs to be hpages_test
9 # huge pages free. Attempt to allocate enough pages to test.
14 # Get count of free huge pages from /proc/meminfo
16 while read name size unit
; do
17 if [ "$name" = "HugePages_Free:" ]; then
23 # If not enough free huge pages for test, attempt to increase
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`
29 if [ $UID != 0 ]; then
30 echo "Please run memfd with hugetlbfs test as root"
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
44 # If still not enough huge pages available, exit. But, give back any huge
45 # pages potentially allocated above.
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
52 printf "Not enough huge pages available (%d < %d)\n" \
58 # Run the hugetlbfs test
60 .
/memfd_test hugetlbfs
61 .
/run_fuse_test.sh hugetlbfs
64 # Give back any huge pages allocated for the test
66 if [ -n "$nr_hugepgs" ]; then
67 echo $nr_hugepgs > /proc
/sys
/vm
/nr_hugepages