linux-stable/tools/testing/selftests/memfd
Mike Kravetz fda153c89a selftests/memfd: clean up mapping in mfd_fail_write
Running the memfd script ./run_hugetlbfs_test.sh will often end in error
as follows:

    memfd-hugetlb: CREATE
    memfd-hugetlb: BASIC
    memfd-hugetlb: SEAL-WRITE
    memfd-hugetlb: SEAL-FUTURE-WRITE
    memfd-hugetlb: SEAL-SHRINK
    fallocate(ALLOC) failed: No space left on device
    ./run_hugetlbfs_test.sh: line 60: 166855 Aborted                 (core dumped) ./memfd_test hugetlbfs
    opening: ./mnt/memfd
    fuse: DONE

If no hugetlb pages have been preallocated, run_hugetlbfs_test.sh will
allocate 'just enough' pages to run the test.  In the SEAL-FUTURE-WRITE
test the mfd_fail_write routine maps the file, but does not unmap.  As a
result, two hugetlb pages remain reserved for the mapping.  When the
fallocate call in the SEAL-SHRINK test attempts allocate all hugetlb
pages, it is short by the two reserved pages.

Fix by making sure to unmap in mfd_fail_write.

Link: https://lkml.kernel.org/r/20220219004340.56478-1-mike.kravetz@oracle.com
Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Joel Fernandes <joel@joelfernandes.org>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2022-02-26 09:51:17 -08:00
..
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
common.c memfd-test: move common code to a shared unit 2018-01-31 17:18:39 -08:00
common.h memfd-test: move common code to a shared unit 2018-01-31 17:18:39 -08:00
config selftests: memfd: add config fragment for fuse 2018-02-13 14:13:53 -07:00
fuse_mnt.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
fuse_test.c selftests/memfd: Fix implicit declaration warnings 2020-11-10 14:42:04 -07:00
Makefile selftests: add build/cross-build dependency check script 2020-04-23 17:23:20 -06:00
memfd_test.c selftests/memfd: clean up mapping in mfd_fail_write 2022-02-26 09:51:17 -08:00
run_fuse_test.sh memfd-test: run fuse test on hugetlb backend memory 2018-01-31 17:18:39 -08:00
run_hugetlbfs_test.sh selftests: memfd: split regular and hugetlbfs tests 2018-05-30 15:29:06 -06:00