Re: [PATCH] selftests/vm: cleanup hugetlb file after mremap test

From: Muchun Song
Date: Wed Feb 02 2022 - 08:11:47 EST


On Tue, Feb 1, 2022 at 11:35 AM Mike Kravetz <mike.kravetz@xxxxxxxxxx> wrote:
>
> The hugepage-mremap test will create a file in a hugetlb filesystem.
> In a default 'run_vmtests' run, the file will contain all the hugetlb
> pages. After the test, the file remains and there are no free hugetlb
> pages for subsequent tests. This causes those hugetlb tests to fail.
>
> Change hugepage-mremap to take the name of the hugetlb file as an
> argument. Unlink the file within the test, and just to be sure remove
> the file in the run_vmtests script.
>
> Signed-off-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx>
> ---
[...]
> diff --git a/tools/testing/selftests/vm/run_vmtests.sh b/tools/testing/selftests/vm/run_vmtests.sh
> index e09040a3dc08..e10d50e0b8e8 100755
> --- a/tools/testing/selftests/vm/run_vmtests.sh
> +++ b/tools/testing/selftests/vm/run_vmtests.sh
> @@ -111,13 +111,14 @@ fi
> echo "-----------------------"
> echo "running hugepage-mremap"
> echo "-----------------------"
> -./hugepage-mremap 256
> +./hugepage-mremap $mnt/huge_mremap
> if [ $? -ne 0 ]; then
> echo "[FAIL]"
> exitcode=1
> else
> echo "[PASS]"
> fi
> +rm -f $mnt/huge_mremap
>

A little strange (since file creation and deletion are not in the same place).
I know $mnt/huge_mremap is created in hugepage-mremap. But I think
hugepage-mremap should do the housekeeping instead of deleting the file
here. Or we can create the file before doing the test. Like:

+ touch $mnt/huge_mremap
-./hugepage-mremap 256
+./hugepage-mremap $mnt/huge_mremap
+rm -f $mnt/huge_mremap

Otherwise LGTM.

Reviewed-by: Muchun Song <songmuchun@xxxxxxxxxxxxx>

Thanks.