lib: add .min_swap_avail in tst_test struct
PATCH 1/1 lib: add .min_swap_avail in tst_test struct
From: Andrea Cervesato <[email protected]>
This new field is mainly to set the minimum size of SwapFree for LTP testcase. If system available free swap memory is less than .min_swap_avail, test will be exit with TCONF.
--- include/tst_memutils.h | 5 +++++ include/tst_test.h | 3 +++ lib/tst_memutils.c | 9 +++++++++ lib/tst_test.c | 3 +++ 4 files changed, 20 insertions(+)
include/tst_memutils.h +5 -0
@@ -25,6 +25,11 @@ void tst_pollute_memory(size_t maxsize, int fillchar);*/ long long tst_available_mem (void ); +/* +* Read the value of SwapFree from /proc/meminfo. +*/ +long long tst_available_swap (void ); +/* * Enable OOM protection to prevent process($PID) being killed by OOM Killer. * echo -1000 >/proc/$PID/oom_score_adj
include/tst_test.h +3 -0
@@ -210,6 +210,9 @@ struct tst_test {/* Minimum size(MB) of MemAvailable required by the test */ unsigned long min_mem_avail; +/* Minimum size(MB) of SwapFree required by the test */ +unsigned long min_swap_avail; +/* * Two policies for reserving hugepage: *
lib/tst_memutils.c +9 -0
@@ -95,6 +95,15 @@ long long tst_available_mem(void)return mem_available; } +long long tst_available_swap (void ) +{ +unsigned long long swap_available =0 ; + +FILE_LINES_SCANF ("/proc/meminfo" ,"SwapFree: %llu" , &swap_available); + +return swap_available; +} +static int has_caps (void ) {struct tst_cap_user_header hdr = {
lib/tst_test.c +3 -0
@@ -1198,6 +1198,9 @@ static void do_setup(int argc, char *argv[])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->min_swap_avail > (unsigned long )(tst_available_swap () /1024 )) +tst_brk (TCONF ,"Test needs at least %luMB SwapFree" , tst_test->min_swap_avail); +if (tst_test->hugepages.number)tst_reserve_hugepages (&tst_test->hugepages);
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
This looks good, but should be immediatelly followed by a patch that fixes the process_madvise test.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
I can send it after this patch.
Quoted 4 lines · Cyril Hrubis
Hi!
This looks good, but should be immediatelly followed by a patch that fixes theprocess_madvisetest.
Andrea
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Andrea,
Quoted 36 lines · Andrea Cervesato
From: Andrea Cervesato <[email protected]>
This new field is mainly to set the minimum size of SwapFree for LTP testcase. If system available free swap memory is less than .min_swap_avail, test will be exit with TCONF.
Signed-off-by Andrea Cervesato <[email protected]>--- include/tst_memutils.h | 5 +++++ include/tst_test.h | 3 +++ lib/tst_memutils.c | 9 +++++++++ lib/tst_test.c | 3 +++ 4 files changed, 20 insertions(+)include/tst_memutils.h +5
-0@@ -25,6 +25,11 @@ void tst_pollute_memory(size_t maxsize, int fillchar);*/ long long tst_available_mem (void ); +/* +* Read the value of SwapFree from /proc/meminfo. +*/ +long long tst_available_swap (void ); +/* * Enable OOM protection to prevent process($PID) being killed by OOM Killer.
* echo -1000 >/proc/$PID/oom_score_adjinclude/tst_test.h +0
-0
include/tst_test.h struct tst_test { · line 215
Quoted 6 lines
include/tst_test.h +2
-0@@ -210,6 +210,9 @@ struct tst_test {/* Minimum size(MB) of MemAvailable required by the test */ unsigned long min_mem_avail; +/* Minimum size(MB) of SwapFree required by the test */ +unsigned long min_swap_avail;
It would be great to have a brief introduction in the document, like what we did for min_mem_avail.
Anyway, we can add it in a separate patch. Thanks!
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp