From: Li Wang <liwang@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 2/2] pkey01: disable hugetlb test if failed to reserve hugepage
Date: Thu, 5 Dec 2019 18:33:42 +0800 [thread overview]
Message-ID: <20191205103342.5980-2-liwang@redhat.com> (raw)
In-Reply-To: <20191205103342.5980-1-liwang@redhat.com>
To handle the false positive:
pkey01.c:69: BROK: nr_hugepages = 0, but expect 1
Signed-off-by: Li Wang <liwang@redhat.com>
---
testcases/kernel/syscalls/pkeys/pkey01.c | 27 ++++++------------------
1 file changed, 6 insertions(+), 21 deletions(-)
diff --git a/testcases/kernel/syscalls/pkeys/pkey01.c b/testcases/kernel/syscalls/pkeys/pkey01.c
index fa84e71f3..929be4e7c 100644
--- a/testcases/kernel/syscalls/pkeys/pkey01.c
+++ b/testcases/kernel/syscalls/pkeys/pkey01.c
@@ -36,12 +36,6 @@
#define PATH_VM_NRHPS "/proc/sys/vm/nr_hugepages"
static int size;
-static int no_hugepage;
-
-static const char * const save_restore[] = {
- "?/proc/sys/vm/nr_hugepages",
- NULL,
-};
static struct tcase {
unsigned long flags;
@@ -56,21 +50,12 @@ static void setup(void)
{
int i, fd;
- if (access("/sys/kernel/mm/hugepages/", F_OK)) {
- tst_res(TINFO, "Huge page is not supported");
+ check_pkey_support();
+
+ if (tst_no_hugepage)
size = getpagesize();
- no_hugepage = 1;
- } else {
- int val;
- SAFE_FILE_PRINTF(PATH_VM_NRHPS, "%d", 1);
- SAFE_FILE_SCANF(PATH_VM_NRHPS, "%d", &val);
- if (val != 1)
- tst_brk(TBROK, "nr_hugepages = %d, but expect %d",
- val, 1);
+ else
size = SAFE_READ_MEMINFO("Hugepagesize:") * 1024;
- }
-
- check_pkey_support();
fd = SAFE_OPEN(TEST_FILE, O_RDWR | O_CREAT, 0664);
for (i = 0; i < 128; i++)
@@ -147,7 +132,7 @@ static void pkey_test(struct tcase *tc, struct mmap_param *mpa)
int pkey, status;
int fd = mpa->fd;
- if (no_hugepage && (mpa->flags & MAP_HUGETLB)) {
+ if (tst_no_hugepage && (mpa->flags & MAP_HUGETLB)) {
tst_res(TINFO, "Skip test on (%s) buffer", flag_to_str(mpa->flags));
return;
}
@@ -236,5 +221,5 @@ static struct tst_test test = {
.forks_child = 1,
.test = verify_pkey,
.setup = setup,
- .save_restore = save_restore,
+ .needs_hugepages = 1,
};
--
2.20.1
next prev parent reply other threads:[~2019-12-05 10:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-05 10:33 [LTP] [PATCH v2 1/2] lib: add .needs_hugepages to reserve hugepage Li Wang
2019-12-05 10:33 ` Li Wang [this message]
2019-12-05 11:57 ` Cyril Hrubis
2019-12-11 6:59 ` Li Wang
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=20191205103342.5980-2-liwang@redhat.com \
--to=liwang@redhat.com \
--cc=ltp@lists.linux.it \
/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