From: Peter Xu <peterx@redhat.com>
To: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
peterx@redhat.com, Axel Rasmussen <axelrasmussen@google.com>,
Mike Kravetz <mike.kravetz@oracle.com>
Subject: [PATCH 2/4] selftests/vm: Use memfd for hugetlb-madvise test
Date: Tue, 4 Oct 2022 17:41:23 -0400 [thread overview]
Message-ID: <20221004214125.120993-3-peterx@redhat.com> (raw)
In-Reply-To: <20221004214125.120993-1-peterx@redhat.com>
For dropping the hugetlb mountpoint in run_vmtests.sh. Since no parameter
is needed, drop USAGE too.
Signed-off-by: Peter Xu <peterx@redhat.com>
---
tools/testing/selftests/vm/hugetlb-madvise.c | 12 +++---------
1 file 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;
}
--
2.37.3
next prev parent reply other threads:[~2022-10-04 21:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-04 21:41 [PATCH 0/4] selftests/vm: Drop hugetlb mntpoint in run_vmtests.sh Peter Xu
2022-10-04 21:41 ` [PATCH 1/4] selftests/vm: Use memfd for hugetlb tests Peter Xu
2022-10-04 22:04 ` Axel Rasmussen
2022-10-05 14:43 ` Peter Xu
2022-10-05 17:32 ` Axel Rasmussen
2022-10-04 21:41 ` Peter Xu [this message]
2022-10-04 21:43 ` [PATCH 3/4] selftests/vm: Use memfd for hugepage-mremap test Peter Xu
2022-10-04 21:43 ` [PATCH 4/4] selftests/vm: Drop mnt point for hugetlb in run_vmtests.sh Peter Xu
2022-10-04 22:04 ` Axel Rasmussen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221004214125.120993-3-peterx@redhat.com \
--to=peterx@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).