[LTP] [PATCH v3 3/3] syscalls/shmget*: Convert into new api
Cyril Hrubis
chrubis@suse.cz
Thu Jul 22 12:51:57 CEST 2021
Hi!
> diff --git a/testcases/kernel/syscalls/ipc/shmget/shmget02.c b/testcases/kernel/syscalls/ipc/shmget/shmget02.c
> index 4436ca7f8..6be8d8157 100644
> --- a/testcases/kernel/syscalls/ipc/shmget/shmget02.c
> +++ b/testcases/kernel/syscalls/ipc/shmget/shmget02.c
...
> +static struct tst_test test = {
> + .needs_tmpdir = 1,
> + .needs_root = 1,
> + .forks_child = 1,
> + .setup = setup,
> + .cleanup = cleanup,
> + .test = do_test,
> + .tcnt = ARRAY_SIZE(tcases),
> + .request_hugepages = 0,
> +};
We got some test failures for the ENOMEM hugepage test and then I we
realized that setting .request_hugepages = 0 is no-op since zero is the
default value when it's not initialized and we ignore it the tst_test.c.
Thinking of possible solutions I guess that the easiest would be to add
a special value that would tell the library to set the pool size to 0.
Something as:
diff --git a/include/tst_test.h b/include/tst_test.h
index c7d77eb09..5f05e3a33 100644
--- a/include/tst_test.h
+++ b/include/tst_test.h
@@ -125,6 +125,8 @@ struct tst_tag {
extern unsigned int tst_variant;
+#define TST_NO_HUGEPAGES ((unsigned long)-1)
+
struct tst_test {
/* number of tests available in test() function */
unsigned int tcnt;
diff --git a/lib/tst_hugepage.c b/lib/tst_hugepage.c
index 1d0e62e5b..ef93afc61 100644
--- a/lib/tst_hugepage.c
+++ b/lib/tst_hugepage.c
@@ -34,6 +34,11 @@ unsigned long tst_request_hugepages(unsigned long hpages)
else
tst_hugepages = hpages;
+ if (hpages == TST_NO_HUGEPAGES) {
+ hpages = 0;
+ goto set_hugepages;
+ }
+
SAFE_FILE_PRINTF("/proc/sys/vm/drop_caches", "3");
max_hpages = SAFE_READ_MEMINFO("MemFree:") / SAFE_READ_MEMINFO("Hugepagesize:");
@@ -47,6 +52,8 @@ unsigned long tst_request_hugepages(unsigned long hpages)
goto out;
}
+set_hugepages:
+
tst_sys_conf_save("?/proc/sys/vm/nr_hugepages");
SAFE_FILE_PRINTF(PATH_NR_HPAGES, "%lu", tst_hugepages);
SAFE_FILE_SCANF(PATH_NR_HPAGES, "%lu", &val);
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list