5 # Normal tests requiring no special resources
11 # To test memfd_create with hugetlbfs, there needs to be hpages_test
12 # huge pages free. Attempt to allocate enough pages to test.
17 # Get count of free huge pages from /proc/meminfo
19 while read name size unit
; do
20 if [ "$name" = "HugePages_Free:" ]; then
26 # If not enough free huge pages for test, attempt to increase
28 if [ -n "$freepgs" ] && [ $freepgs -lt $hpages_test ]; then
29 nr_hugepgs
=`cat /proc/sys/vm/nr_hugepages`
30 hpages_needed
=`expr $hpages_test - $freepgs`
32 echo 3 > /proc
/sys
/vm
/drop_caches
33 echo $
(( $hpages_needed + $nr_hugepgs )) > /proc
/sys
/vm
/nr_hugepages
35 echo "Please run this test as root"
38 while read name size unit
; do
39 if [ "$name" = "HugePages_Free:" ]; then
46 # If still not enough huge pages available, exit. But, give back any huge
47 # pages potentially allocated above.
49 if [ $freepgs -lt $hpages_test ]; then
50 # nr_hugepgs non-zero only if we attempted to increase
51 if [ -n "$nr_hugepgs" ]; then
52 echo $nr_hugepgs > /proc
/sys
/vm
/nr_hugepages
54 printf "Not enough huge pages available (%d < %d)\n" \
60 # Run the hugetlbfs test
62 .
/memfd_test hugetlbfs
63 .
/run_fuse_test.sh hugetlbfs
66 # Give back any huge pages allocated for the test
68 if [ -n "$nr_hugepgs" ]; then
69 echo $nr_hugepgs > /proc
/sys
/vm
/nr_hugepages