lib: add .min_mem_avail in tst_test struct
PATCH 1/2 lib: add .min_mem_avail in tst_test struct
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.
--- doc/c-test-api.txt | 6 ++++++ include/tst_test.h | 3 +++ lib/tst_test.c | 3 +++ 3 files changed, 12 insertions(+)
doc/c-test-api.txt +6 -0
@@ -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 ------------------
include/tst_test.h +3 -0
@@ -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
lib/tst_test.c +3 -0
@@ -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);
Signature · 5 lines
2.31.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 2/2 kernel: make use of .min_mem_avail
Set the minimum size of MemAvailable for tests.
--- 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(-)
testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c +2 -5
@@ -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,
testcases/kernel/mem/swapping/swapping01.c +1 -4
@@ -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" },
testcases/kernel/syscalls/getrusage/getrusage03.c +1 -9
@@ -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), };
Signature · 5 lines
2.31.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Li
This patch series looks simple and obviously ok. So Reviewed-by: Yang Xu <[email protected]>
Best Regards
Yang Xu
Quoted 60 lines
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<[email protected]>--- doc/c-test-api.txt | 6 ++++++ include/tst_test.h | 3 +++ lib/tst_test.c | 3 +++ 3 files changed, 12 insertions(+)doc/c-test-api.txt +6
-0@@ -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 ------------------include/tst_test.h +3
-0@@ -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 lib/tst_test.c +3
-0@@ -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);
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 10 lines · Li Wang
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 <[email protected]>
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Pushed.
Signature · 2 lines
Regards, Li Wang
Signature · 2 lines
-- Mailing list info: https://lists.linux.it/listinfo/ltp