* [LTP] [PATCH 1/2] lib: add .min_mem_avail in tst_test struct
@ 2022-02-09 8:56 Li Wang
2022-02-09 8:57 ` [LTP] [PATCH 2/2] kernel: make use of .min_mem_avail Li Wang
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Li Wang @ 2022-02-09 8:56 UTC (permalink / raw)
To: ltp
As the name implies, this new field is mainly to set the minimum size
of MemAvailable for LTP testcase. If system available memory are less
than .min_mem_avail, test will be exit with TCONF.
And, it also helps to reduce OOM occurring in test parallel run. Due
to running more than one process that consumes a significant amount
of memory at the same time.
Signed-off-by: Li Wang <liwang@redhat.com>
---
doc/c-test-api.txt | 6 ++++++
include/tst_test.h | 3 +++
lib/tst_test.c | 3 +++
3 files changed, 12 insertions(+)
diff --git a/doc/c-test-api.txt b/doc/c-test-api.txt
index 51dac58ae..dfbb453e1 100644
--- a/doc/c-test-api.txt
+++ b/doc/c-test-api.txt
@@ -2321,6 +2321,12 @@ static struct tst_test test = {
};
-------------------------------------------------------------------------------
+1.40 Require minimum size of MemAvailable for a testcase
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Some tests require more than specific size(MB) of MemAvailable. It can be defined
+with `.min_mem_avail = N`.
+
2. Common problems
------------------
diff --git a/include/tst_test.h b/include/tst_test.h
index a7aaedcff..bac5e52ba 100644
--- a/include/tst_test.h
+++ b/include/tst_test.h
@@ -185,6 +185,9 @@ struct tst_test {
/* Minimum number of online CPU required by the test */
unsigned long min_cpus;
+ /* Minimum size(MB) of MemAvailable required by the test */
+ unsigned long min_mem_avail;
+
/*
* If set non-zero number of request_hugepages, test will try to reserve the
* expected number of hugepage for testing in setup phase. If system does not
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 1fd238cf5..191a9deab 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -1090,6 +1090,9 @@ static void do_setup(int argc, char *argv[])
if (tst_test->min_cpus > (unsigned long)tst_ncpus())
tst_brk(TCONF, "Test needs at least %lu CPUs online", tst_test->min_cpus);
+ if (tst_test->min_mem_avail > (unsigned long)(tst_available_mem() / 1024))
+ tst_brk(TCONF, "Test needs at least %luMB MemAvailable", tst_test->min_mem_avail);
+
if (tst_test->request_hugepages)
tst_request_hugepages(tst_test->request_hugepages);
--
2.31.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [LTP] [PATCH 2/2] kernel: make use of .min_mem_avail
2022-02-09 8:56 [LTP] [PATCH 1/2] lib: add .min_mem_avail in tst_test struct Li Wang
@ 2022-02-09 8:57 ` Li Wang
2022-02-09 9:50 ` [LTP] [PATCH 1/2] lib: add .min_mem_avail in tst_test struct xuyang2018.jy
2022-02-09 10:53 ` Jan Stancek
2 siblings, 0 replies; 5+ messages in thread
From: Li Wang @ 2022-02-09 8:57 UTC (permalink / raw)
To: ltp
Set the minimum size of MemAvailable for tests.
Signed-off-by: Li Wang <liwang@redhat.com>
---
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c | 7 ++-----
testcases/kernel/mem/swapping/swapping01.c | 5 +----
testcases/kernel/syscalls/getrusage/getrusage03.c | 10 +---------
3 files changed, 4 insertions(+), 18 deletions(-)
diff --git a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c
index b76da93a1..128671051 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c
@@ -81,20 +81,16 @@ static void shared_hugepage(void)
static void setup(void)
{
- long mem_total, hpage_size, orig_hugepages;
+ long hpage_size, orig_hugepages;
if (tst_hugepages == 0)
tst_brk(TCONF, "Not enough hugepages for testing.");
orig_hugepages = get_sys_tune("nr_hugepages");
- mem_total = SAFE_READ_MEMINFO("MemTotal:");
SAFE_FILE_SCANF(PATH_SHMMAX, "%ld", &orig_shmmax);
SAFE_FILE_PRINTF(PATH_SHMMAX, "%ld", (long)SIZE);
SAFE_FILE_SCANF(PATH_SHMMAX, "%ld", &new_shmmax);
- if (mem_total < 2L*1024*1024)
- tst_brk(TCONF, "Needed > 2GB RAM, have: %ld", mem_total);
-
if (new_shmmax < SIZE)
tst_brk(TCONF, "shmmax too low, have: %ld", new_shmmax);
@@ -122,6 +118,7 @@ static struct tst_test test = {
.needs_tmpdir = 1,
.tcnt = 3,
.test = test_hugeshmat,
+ .min_mem_avail = 2048,
.setup = setup,
.cleanup = cleanup,
.request_hugepages = 1,
diff --git a/testcases/kernel/mem/swapping/swapping01.c b/testcases/kernel/mem/swapping/swapping01.c
index 6db0f9866..1a494bf69 100644
--- a/testcases/kernel/mem/swapping/swapping01.c
+++ b/testcases/kernel/mem/swapping/swapping01.c
@@ -95,10 +95,6 @@ static void init_meminfo(void)
mem_over = mem_available_init * COE_SLIGHT_OVER;
mem_over_max = mem_available_init * COE_DELTA;
- /* at least 10MB available physical memory needed */
- if (mem_available_init < 10240)
- tst_brk(TCONF, "Not enough available mem to test.");
-
if (swap_free_init < mem_over_max)
tst_brk(TCONF, "Not enough swap space to test: swap_free_init(%ldkB) < mem_over_max(%ldkB)",
swap_free_init, mem_over_max);
@@ -162,6 +158,7 @@ static void check_swapping(void)
static struct tst_test test = {
.needs_root = 1,
.forks_child = 1,
+ .min_mem_avail = 10,
.test_all = test_swapping,
.tags = (const struct tst_tag[]) {
{"linux-git", "50a15981a1fa"},
diff --git a/testcases/kernel/syscalls/getrusage/getrusage03.c b/testcases/kernel/syscalls/getrusage/getrusage03.c
index 201d258fa..676fea1c9 100644
--- a/testcases/kernel/syscalls/getrusage/getrusage03.c
+++ b/testcases/kernel/syscalls/getrusage/getrusage03.c
@@ -173,24 +173,16 @@ static void run(unsigned int i)
}
}
-static void setup(void)
-{
- long long mem_avail = tst_available_mem();
-
- if (mem_avail < 512L*1024)
- tst_brk(TCONF, "Needed > 512MB available, only have: %ld kB", mem_avail);
-}
-
static struct tst_test test = {
.forks_child = 1,
.child_needs_reinit = 1,
.resource_files = resource,
.min_kver = "2.6.32",
+ .min_mem_avail = 512,
.tags = (const struct tst_tag[]) {
{"linux-git", "1f10206cf8e9"},
{}
},
- .setup = setup,
.test = run,
.tcnt = ARRAY_SIZE(testfunc_list),
};
--
2.31.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH 1/2] lib: add .min_mem_avail in tst_test struct
2022-02-09 8:56 [LTP] [PATCH 1/2] lib: add .min_mem_avail in tst_test struct Li Wang
2022-02-09 8:57 ` [LTP] [PATCH 2/2] kernel: make use of .min_mem_avail Li Wang
@ 2022-02-09 9:50 ` xuyang2018.jy
2022-02-09 10:53 ` Jan Stancek
2 siblings, 0 replies; 5+ messages in thread
From: xuyang2018.jy @ 2022-02-09 9:50 UTC (permalink / raw)
To: Li Wang; +Cc: ltp
Hi Li
This patch series looks simple and obviously ok.
So Reviewed-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Best Regards
Yang Xu
> As the name implies, this new field is mainly to set the minimum size
> of MemAvailable for LTP testcase. If system available memory are less
> than .min_mem_avail, test will be exit with TCONF.
>
> And, it also helps to reduce OOM occurring in test parallel run. Due
> to running more than one process that consumes a significant amount
> of memory at the same time.
>
> Signed-off-by: Li Wang<liwang@redhat.com>
> ---
> doc/c-test-api.txt | 6 ++++++
> include/tst_test.h | 3 +++
> lib/tst_test.c | 3 +++
> 3 files changed, 12 insertions(+)
>
> diff --git a/doc/c-test-api.txt b/doc/c-test-api.txt
> index 51dac58ae..dfbb453e1 100644
> --- a/doc/c-test-api.txt
> +++ b/doc/c-test-api.txt
> @@ -2321,6 +2321,12 @@ static struct tst_test test = {
> };
> -------------------------------------------------------------------------------
>
> +1.40 Require minimum size of MemAvailable for a testcase
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +Some tests require more than specific size(MB) of MemAvailable. It can be defined
> +with `.min_mem_avail = N`.
> +
> 2. Common problems
> ------------------
>
> diff --git a/include/tst_test.h b/include/tst_test.h
> index a7aaedcff..bac5e52ba 100644
> --- a/include/tst_test.h
> +++ b/include/tst_test.h
> @@ -185,6 +185,9 @@ struct tst_test {
> /* Minimum number of online CPU required by the test */
> unsigned long min_cpus;
>
> + /* Minimum size(MB) of MemAvailable required by the test */
> + unsigned long min_mem_avail;
> +
> /*
> * If set non-zero number of request_hugepages, test will try to reserve the
> * expected number of hugepage for testing in setup phase. If system does not
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index 1fd238cf5..191a9deab 100644
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -1090,6 +1090,9 @@ static void do_setup(int argc, char *argv[])
> if (tst_test->min_cpus> (unsigned long)tst_ncpus())
> tst_brk(TCONF, "Test needs at least %lu CPUs online", tst_test->min_cpus);
>
> + if (tst_test->min_mem_avail> (unsigned long)(tst_available_mem() / 1024))
> + tst_brk(TCONF, "Test needs at least %luMB MemAvailable", tst_test->min_mem_avail);
> +
> if (tst_test->request_hugepages)
> tst_request_hugepages(tst_test->request_hugepages);
>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH 1/2] lib: add .min_mem_avail in tst_test struct
2022-02-09 8:56 [LTP] [PATCH 1/2] lib: add .min_mem_avail in tst_test struct Li Wang
2022-02-09 8:57 ` [LTP] [PATCH 2/2] kernel: make use of .min_mem_avail Li Wang
2022-02-09 9:50 ` [LTP] [PATCH 1/2] lib: add .min_mem_avail in tst_test struct xuyang2018.jy
@ 2022-02-09 10:53 ` Jan Stancek
2022-02-10 9:28 ` Li Wang
2 siblings, 1 reply; 5+ messages in thread
From: Jan Stancek @ 2022-02-09 10:53 UTC (permalink / raw)
To: Li Wang; +Cc: LTP List
On Wed, Feb 9, 2022 at 9:57 AM Li Wang <liwang@redhat.com> wrote:
>
> As the name implies, this new field is mainly to set the minimum size
> of MemAvailable for LTP testcase. If system available memory are less
> than .min_mem_avail, test will be exit with TCONF.
>
> And, it also helps to reduce OOM occurring in test parallel run. Due
> to running more than one process that consumes a significant amount
> of memory at the same time.
>
> Signed-off-by: Li Wang <liwang@redhat.com>
Acked-by: Jan Stancek <jstancek@redhat.com>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH 1/2] lib: add .min_mem_avail in tst_test struct
2022-02-09 10:53 ` Jan Stancek
@ 2022-02-10 9:28 ` Li Wang
0 siblings, 0 replies; 5+ messages in thread
From: Li Wang @ 2022-02-10 9:28 UTC (permalink / raw)
To: LTP List
[-- Attachment #1.1: Type: text/plain, Size: 30 bytes --]
Pushed.
--
Regards,
Li Wang
[-- Attachment #1.2: Type: text/html, Size: 240 bytes --]
[-- Attachment #2: Type: text/plain, Size: 60 bytes --]
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-02-10 9:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-09 8:56 [LTP] [PATCH 1/2] lib: add .min_mem_avail in tst_test struct Li Wang
2022-02-09 8:57 ` [LTP] [PATCH 2/2] kernel: make use of .min_mem_avail Li Wang
2022-02-09 9:50 ` [LTP] [PATCH 1/2] lib: add .min_mem_avail in tst_test struct xuyang2018.jy
2022-02-09 10:53 ` Jan Stancek
2022-02-10 9:28 ` Li Wang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.