linux-stable/tools/testing
Mike Kravetz f1f5d089fc selftests/memfd: clean up mapping in mfd_fail_write
[ Upstream commit fda153c89a ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-03-16 14:16:01 +01:00
..
fault-injection
ktest tweewide: Fix most Shebang lines 2021-05-22 11:40:55 +02:00
kunit tweewide: Fix most Shebang lines 2021-05-22 11:40:55 +02:00
nvdimm device-dax: add dis-contiguous resource support 2020-10-13 18:38:28 -07:00
radix-tree idr test suite: Create anchor before launching throbber 2021-04-16 11:43:21 +02:00
scatterlist tools/testing/scatterlist: Fix test to compile and run 2020-11-17 20:02:20 -04:00
selftests selftests/memfd: clean up mapping in mfd_fail_write 2022-03-16 14:16:01 +01:00
vsock