diff options
author | Peter Xu <peterx@redhat.com> | 2022-10-14 16:39:19 +0200 |
---|---|---|
committer | Andrew Morton <akpm@linux-foundation.org> | 2022-11-09 02:37:11 +0100 |
commit | 62f33fa228003a419a9484eed5133447a280387c (patch) | |
tree | 8dd230c5c2b19b3e7356e0ab638e30dfcdfeed1f | |
parent | selftests/vm: use memfd for uffd hugetlb tests (diff) | |
download | linux-62f33fa228003a419a9484eed5133447a280387c.tar.xz linux-62f33fa228003a419a9484eed5133447a280387c.zip |
selftests/vm: use memfd for hugetlb-madvise test
For dropping the hugetlb mountpoint in run_vmtests.sh. Since no parameter
is needed, drop USAGE too.
Link: https://lkml.kernel.org/r/20221014143921.93887-3-peterx@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r-- | tools/testing/selftests/vm/hugetlb-madvise.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/tools/testing/selftests/vm/hugetlb-madvise.c b/tools/testing/selftests/vm/hugetlb-madvise.c index 3c9943131881..f96435b70986 100644 --- a/tools/testing/selftests/vm/hugetlb-madvise.c +++ b/tools/testing/selftests/vm/hugetlb-madvise.c @@ -12,6 +12,7 @@ * directory. */ +#define _GNU_SOURCE #include <stdlib.h> #include <stdio.h> #include <unistd.h> @@ -19,7 +20,6 @@ #define __USE_GNU #include <fcntl.h> -#define USAGE "USAGE: %s <hugepagefile_name>\n" #define MIN_FREE_PAGES 20 #define NR_HUGE_PAGES 10 /* common number of pages to map/allocate */ @@ -103,11 +103,6 @@ int main(int argc, char **argv) int fd; int ret; - if (argc != 2) { - printf(USAGE, argv[0]); - exit(1); - } - huge_page_size = default_huge_page_size(); if (!huge_page_size) { printf("Unable to determine huge page size, exiting!\n"); @@ -125,9 +120,9 @@ int main(int argc, char **argv) exit(1); } - fd = open(argv[1], O_CREAT | O_RDWR, 0755); + fd = memfd_create(argv[0], MFD_HUGETLB); if (fd < 0) { - perror("Open failed"); + perror("memfd_create() failed"); exit(1); } @@ -406,6 +401,5 @@ int main(int argc, char **argv) (void)munmap(addr2, NR_HUGE_PAGES * huge_page_size); close(fd); - unlink(argv[1]); return 0; } |