]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
generic/759,760: skip test if we can't set up a hugepage for IO
authorDarrick J. Wong <djwong@kernel.org>
Tue, 4 Feb 2025 19:15:49 +0000 (11:15 -0800)
committerZorro Lang <zlang@kernel.org>
Tue, 18 Feb 2025 04:42:39 +0000 (12:42 +0800)
On an arm64 VM with 64k base pages and a paltry 8G of RAM, this test
will frequently fail like this:

>  QA output created by 759
>  fsx -N 10000 -l 500000 -h
> -fsx -N 10000 -o 8192 -l 500000 -h
> -fsx -N 10000 -o 128000 -l 500000 -h
> +Seed set to 1
> +madvise collapse for buf: Cannot allocate memory
> +init_hugepages_buf failed for good_buf: Cannot allocate memory

This system has a 512MB hugepage size, which means that there's a good
chance that memory is so fragmented that we won't be able to create a
huge page (in 1/16th the available DRAM).  Create a _run_hugepage_fsx
helper that will detect this situation at the start of the test and skip
it, having refactored run_fsx into a properly namespaced version that
won't exit the test on failure.

Cc: <fstests@vger.kernel.org> # v2025.02.02
Cc: joannelkoong@gmail.com
Fixes: 627289232371e3 ("generic: add tests for read/writes from hugepages-backed buffers")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Joanne Koong <joannelkoong@gmail.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/rc
ltp/fsx.c
tests/generic/759
tests/generic/760

index 357320ba41fae015804a9e9e2bcc6ade66c53d9c..c4c934ed8bb02fd12b08372b843abd8aef0cdb9b 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -4982,20 +4982,46 @@ _require_hugepage_fsx()
                _notrun "fsx binary does not support MADV_COLLAPSE"
 }
 
-run_fsx()
+_run_fsx()
 {
-       echo fsx $@
+       echo "fsx $*"
        local args=`echo $@ | sed -e "s/ BSIZE / $bsize /g" -e "s/ PSIZE / $psize /g"`
        set -- $here/ltp/fsx $args $FSX_AVOID $TEST_DIR/junk
        echo "$@" >>$seqres.full
        rm -f $TEST_DIR/junk
        "$@" 2>&1 | tee -a $seqres.full >$tmp.fsx
-       if [ ${PIPESTATUS[0]} -ne 0 ]; then
+       local res=${PIPESTATUS[0]}
+       if [ $res -ne 0 ]; then
                cat $tmp.fsx
                rm -f $tmp.fsx
-               exit 1
+               return $res
        fi
        rm -f $tmp.fsx
+       return 0
+}
+
+# Run fsx with -h(ugepage buffers).  If we can't set up a hugepage then skip
+# the test, but if any other error occurs then exit the test.
+_run_hugepage_fsx() {
+       _run_fsx "$@" -h &> $tmp.hugepage_fsx
+       local res=$?
+       if [ $res -eq 103 ]; then
+               # According to the MADV_COLLAPSE manpage, these three errors
+               # can happen if the kernel could not collapse a collection of
+               # pages into a single huge page.
+               grep -q -E ' for hugebuf: (Cannot allocate memory|Device or resource busy|Resource temporarily unavailable)' $tmp.hugepage_fsx && \
+                       _notrun "Could not set up huge page for test"
+       fi
+       cat $tmp.hugepage_fsx
+       rm -f $tmp.hugepage_fsx
+       test $res -ne 0 && exit 1
+       return 0
+}
+
+# run fsx or exit the test
+run_fsx()
+{
+       _run_fsx "$@" || exit 1
 }
 
 _require_statx()
index cf9502a74c17a744054558e860eb9aba62f31139..d1b0f245582b315c4977591bca883d59d26bb538 100644 (file)
--- a/ltp/fsx.c
+++ b/ltp/fsx.c
@@ -2974,13 +2974,15 @@ init_hugepages_buf(unsigned len, int hugepage_size, int alignment, long *buf_siz
 
        ret = posix_memalign(&buf, hugepage_size, size);
        if (ret) {
-               prterr("posix_memalign for buf");
+               /* common/rc greps this error message */
+               prterr("posix_memalign for hugebuf");
                return NULL;
        }
        memset(buf, '\0', size);
        ret = madvise(buf, size, MADV_COLLAPSE);
        if (ret) {
-               prterr("madvise collapse for buf");
+               /* common/rc greps this error message */
+               prterr("madvise collapse for hugebuf");
                free(buf);
                return NULL;
        }
index a7dec155056abc60054b73610c5186f79d9c183d..49c02214559a5543e44284f8a154d849e5c58cb5 100755 (executable)
@@ -15,9 +15,9 @@ _require_test
 _require_thp
 _require_hugepage_fsx
 
-run_fsx -N 10000            -l 500000 -h
-run_fsx -N 10000  -o 8192   -l 500000 -h
-run_fsx -N 10000  -o 128000 -l 500000 -h
+_run_hugepage_fsx -N 10000            -l 500000
+_run_hugepage_fsx -N 10000  -o 8192   -l 500000
+_run_hugepage_fsx -N 10000  -o 128000 -l 500000
 
 status=0
 exit
index 4781a8d1eec4ecfd949f04b04efdf13d6eb12646..f270636e56a3771d204516ee52665ab47175582f 100755 (executable)
@@ -19,9 +19,9 @@ _require_hugepage_fsx
 psize=`$here/src/feature -s`
 bsize=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`
 
-run_fsx -N 10000            -l 500000 -r PSIZE -t BSIZE -w BSIZE -Z -R -W -h
-run_fsx -N 10000  -o 8192   -l 500000 -r PSIZE -t BSIZE -w BSIZE -Z -R -W -h
-run_fsx -N 10000  -o 128000 -l 500000 -r PSIZE -t BSIZE -w BSIZE -Z -R -W -h
+_run_hugepage_fsx -N 10000            -l 500000 -r PSIZE -t BSIZE -w BSIZE -Z -R -W
+_run_hugepage_fsx -N 10000  -o 8192   -l 500000 -r PSIZE -t BSIZE -w BSIZE -Z -R -W
+_run_hugepage_fsx -N 10000  -o 128000 -l 500000 -r PSIZE -t BSIZE -w BSIZE -Z -R -W
 
 status=0
 exit