Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Peter Xu and committed by
Andrew Morton
62f33fa2 de2baa88

+3 -9
+3 -9
tools/testing/selftests/vm/hugetlb-madvise.c
··· 12 12 * directory. 13 13 */ 14 14 15 + #define _GNU_SOURCE 15 16 #include <stdlib.h> 16 17 #include <stdio.h> 17 18 #include <unistd.h> ··· 20 19 #define __USE_GNU 21 20 #include <fcntl.h> 22 21 23 - #define USAGE "USAGE: %s <hugepagefile_name>\n" 24 22 #define MIN_FREE_PAGES 20 25 23 #define NR_HUGE_PAGES 10 /* common number of pages to map/allocate */ 26 24 ··· 103 103 int fd; 104 104 int ret; 105 105 106 - if (argc != 2) { 107 - printf(USAGE, argv[0]); 108 - exit(1); 109 - } 110 - 111 106 huge_page_size = default_huge_page_size(); 112 107 if (!huge_page_size) { 113 108 printf("Unable to determine huge page size, exiting!\n"); ··· 120 125 exit(1); 121 126 } 122 127 123 - fd = open(argv[1], O_CREAT | O_RDWR, 0755); 128 + fd = memfd_create(argv[0], MFD_HUGETLB); 124 129 if (fd < 0) { 125 - perror("Open failed"); 130 + perror("memfd_create() failed"); 126 131 exit(1); 127 132 } 128 133 ··· 401 406 (void)munmap(addr2, NR_HUGE_PAGES * huge_page_size); 402 407 403 408 close(fd); 404 - unlink(argv[1]); 405 409 return 0; 406 410 }