From: "Mike Rapoport (Microsoft)" Currently when running THP and HugeTLB tests, if HAVE_HUGEPAGES is set run_test() drops caches, compacts memory and runs the test. But if HAVE_HUGEPAGES is not set it skips the tests entirely, even if THP tests have nothing to do with HAVE_HUGEPAGES. Replace the check if HAVE_HUGEPAGES is set with a check of how much memory is available. If there is less than 256 MB of available memory, drop caches and run compaction and then continue to run a test regardless of HAVE_HUGEPAGES value. Signed-off-by: Mike Rapoport (Microsoft) --- tools/testing/selftests/mm/run_vmtests.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh index b9e520194634..b42d19036182 100755 --- a/tools/testing/selftests/mm/run_vmtests.sh +++ b/tools/testing/selftests/mm/run_vmtests.sh @@ -99,6 +99,9 @@ EOF exit 0 } +mem_available_kb=$(awk '/MemAvailable/ {print $2}' /proc/meminfo) +mem_available_Mb=$((mem_available_kb / 1024)) + RUN_ALL=false RUN_DESTRUCTIVE=false TAP_PREFIX="# " @@ -239,15 +242,12 @@ run_test() { # On memory constrainted systems some tests can fail to allocate hugepages. # perform some cleanup before the test for a higher success rate. if [ ${CATEGORY} == "thp" -o ${CATEGORY} == "hugetlb" ]; then - if [ "${HAVE_HUGEPAGES}" = "1" ]; then - echo 3 > /proc/sys/vm/drop_caches - sleep 2 - echo 1 > /proc/sys/vm/compact_memory - sleep 2 - else - echo "hugepages not supported" | tap_prefix - skip=1 - fi + if (( $mem_available_Mb < 256 )); then + echo 3 > /proc/sys/vm/drop_caches + sleep 2 + echo 1 > /proc/sys/vm/compact_memory + sleep 2 + fi fi local test=$(pretty_name "$*") -- 2.53.0