ksm06 and libnuma cleanups and fixes
cover ksm06 and libnuma cleanups and fixes
Most of the patches cleans up the ksm06 test however a fix for a free memory estimate for the ltplibnuma is included as well.
Cyril Hrubis (7):
ksm06: Move option parsing into the setup() mem/lib: Export group_check() as ksm_group_check() mem/ksm06: Move test code from library to the test mem/ksm06: SPDX + docparse comment
mem/ksm06: Move ksm restoration into the tst_test struct
libs: libltpnuma: Fix free memory estimate mem/ksm06: Make use of the new libltpnuma
libs/libltpnuma/tst_numa.c | 6 +- testcases/kernel/mem/include/mem.h | 2 + testcases/kernel/mem/ksm/Makefile | 3 + testcases/kernel/mem/ksm/ksm06.c | 146 +++++++++++++++++++---------- testcases/kernel/mem/lib/mem.c | 99 ++----------------- 5 files changed, 114 insertions(+), 142 deletions(-)
Signature · 5 lines
2.34.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 1/7 ksm06: Move option parsing into the setup()
--- testcases/kernel/mem/ksm/ksm06.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
testcases/kernel/mem/ksm/ksm06.c +4 -6
@@ -42,17 +42,12 @@static int run =-1 ;static int sleep_millisecs =-1 ;static int merge_across_nodes =-1 ; -static unsigned long nr_pages; +static unsigned long nr_pages =100 ;static char *n_opt;static void test_ksm (void ) { -if (n_opt) - nr_pages =SAFE_STRTOUL (n_opt,0 ,ULONG_MAX ); -else - nr_pages =100 ; -test_ksm_merge_across_nodes (nr_pages); }
@@ -64,6 +59,9 @@ static void setup(void)if (!is_numa (NULL ,NH_MEMS ,2 ))tst_brk (TCONF ,"The case needs a NUMA system." ); +if (n_opt) + nr_pages =SAFE_STRTOUL (n_opt,0 ,ULONG_MAX ); +/* save the current value */ SAFE_FILE_SCANF (PATH_KSM "run" ,"%d" , &run); SAFE_FILE_SCANF(PATH_KSM "merge_across_nodes",
Signature · 5 lines
2.34.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 1/7] ksm06: Move option parsing into the setup()
Hi,
Quoted 1 line · Cyril Hrubis
Signed-off-by Cyril Hrubis <[email protected]>
Quoted 39 lines
--- testcases/kernel/mem/ksm/ksm06.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)testcases/kernel/mem/ksm/ksm06.c +4
-6@@ -42,17 +42,12 @@static int run =-1 ;static int sleep_millisecs =-1 ;static int merge_across_nodes =-1 ; -static unsigned long nr_pages; +static unsigned long nr_pages =100 ;static char *n_opt;static void test_ksm (void ) { -if (n_opt) - nr_pages =SAFE_STRTOUL (n_opt,0 ,ULONG_MAX ); -else - nr_pages =100 ; -test_ksm_merge_across_nodes (nr_pages); }@@ -64,6 +59,9 @@ static void setup(void)if (!is_numa (NULL ,NH_MEMS ,2 ))tst_brk (TCONF ,"The case needs a NUMA system." ); +if (n_opt) + nr_pages =SAFE_STRTOUL (n_opt,0 ,ULONG_MAX ); +/* save the current value */ SAFE_FILE_SCANF (PATH_KSM "run" ,"%d" , &run); SAFE_FILE_SCANF(PATH_KSM "merge_across_nodes",Signature · 1 line
2.34.1
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 2/7 mem/lib: Export group_check() as ksm_group_check()
In reply to Cyril HrubisThis is preparing for the move of the code from library to the ksm06.
--- testcases/kernel/mem/include/mem.h | 2 ++ testcases/kernel/mem/lib/mem.c | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-)
testcases/kernel/mem/include/mem.h +2 -0
@@ -50,6 +50,8 @@ void testoom(int mempolicy, int lite, int retcode, int allow_sigkill);void create_same_memory (int size,int num,int unit);void test_ksm_merge_across_nodes (unsigned long nr_pages); +void ksm_group_check (int run,int pg_shared,int pg_sharing,int pg_volatile, +int pg_unshared,int sleep_msecs,int pages_to_scan);/* THP */
testcases/kernel/mem/lib/mem.c +11 -11
@@ -271,9 +271,9 @@ static void final_group_check(int run, int pages_shared, int pages_sharing,check ("pages_to_scan" , pages_to_scan); } -static void group_check (int run,int pages_shared,int pages_sharing, -int pages_volatile,int pages_unshared, -int sleep_millisecs,int pages_to_scan) +void ksm_group_check (int run,int pages_shared,int pages_sharing, +int pages_volatile,int pages_unshared, +int sleep_millisecs,int pages_to_scan) {if (run !=1 ) {tst_res (TFAIL ,"group_check run is not 1, %d." , run);
@@ -489,19 +489,19 @@ void create_same_memory(int size, int num, int unit)resume_ksm_children (child, num);stop_ksm_children (child, num); -group_check (1 ,2 , size * num * pages -2 ,0 ,0 ,0 , size * pages * num); +ksm_group_check (1 ,2 , size * num * pages -2 ,0 ,0 ,0 , size * pages * num);resume_ksm_children (child, num);stop_ksm_children (child, num); -group_check (1 ,3 , size * num * pages -3 ,0 ,0 ,0 , size * pages * num); +ksm_group_check (1 ,3 , size * num * pages -3 ,0 ,0 ,0 , size * pages * num);resume_ksm_children (child, num);stop_ksm_children (child, num); -group_check (1 ,1 , size * num * pages -1 ,0 ,0 ,0 , size * pages * num); +ksm_group_check (1 ,1 , size * num * pages -1 ,0 ,0 ,0 , size * pages * num);resume_ksm_children (child, num);stop_ksm_children (child, num); -group_check (1 ,1 , size * num * pages -2 ,0 ,1 ,0 , size * pages * num); +ksm_group_check (1 ,1 , size * num * pages -2 ,0 ,1 ,0 , size * pages * num);tst_res (TINFO ,"KSM unmerging..." );SAFE_FILE_PRINTF (PATH_KSM "run" ,"2" );
@@ -586,15 +586,15 @@ void test_ksm_merge_across_nodes(unsigned long nr_pages)tst_res (TINFO ,"Start to test KSM with merge_across_nodes=1" );SAFE_FILE_PRINTF (PATH_KSM "merge_across_nodes" ,"1" );SAFE_FILE_PRINTF (PATH_KSM "run" ,"1" ); -group_check (1 ,1 , nr_pages * num_nodes -1 ,0 ,0 ,0 , - nr_pages * num_nodes); +ksm_group_check (1 ,1 , nr_pages * num_nodes -1 ,0 ,0 ,0 , + nr_pages * num_nodes);SAFE_FILE_PRINTF (PATH_KSM "run" ,"2" );tst_res (TINFO ,"Start to test KSM with merge_across_nodes=0" );SAFE_FILE_PRINTF (PATH_KSM "merge_across_nodes" ,"0" );SAFE_FILE_PRINTF (PATH_KSM "run" ,"1" ); -group_check (1 , num_nodes, nr_pages * num_nodes - num_nodes, -0 ,0 ,0 , nr_pages * num_nodes); +ksm_group_check (1 , num_nodes, nr_pages * num_nodes - num_nodes, +0 ,0 ,0 , nr_pages * num_nodes);SAFE_FILE_PRINTF (PATH_KSM "run" ,"2" );
Signature · 5 lines
2.34.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 2/7] mem/lib: Export group_check() as ksm_group_check()
Hi,
Quoted 3 lines · Cyril Hrubis
This is preparing for the move of the code from library to the ksm06.
Signed-off-by Cyril Hrubis <[email protected]>
Quoted 81 lines
--- testcases/kernel/mem/include/mem.h | 2 ++ testcases/kernel/mem/lib/mem.c | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-)testcases/kernel/mem/include/mem.h +2
-0@@ -50,6 +50,8 @@ void testoom(int mempolicy, int lite, int retcode, int allow_sigkill);void create_same_memory (int size,int num,int unit);void test_ksm_merge_across_nodes (unsigned long nr_pages); +void ksm_group_check (int run,int pg_shared,int pg_sharing,int pg_volatile, +int pg_unshared,int sleep_msecs,int pages_to_scan);/* THP */ testcases/kernel/mem/lib/mem.c +11
-11@@ -271,9 +271,9 @@ static void final_group_check(int run, int pages_shared, int pages_sharing,check ("pages_to_scan" , pages_to_scan); } -static void group_check (int run,int pages_shared,int pages_sharing, -int pages_volatile,int pages_unshared, -int sleep_millisecs,int pages_to_scan) +void ksm_group_check (int run,int pages_shared,int pages_sharing, +int pages_volatile,int pages_unshared, +int sleep_millisecs,int pages_to_scan) {if (run !=1 ) {tst_res (TFAIL ,"group_check run is not 1, %d." , run);@@ -489,19 +489,19 @@ void create_same_memory(int size, int num, int unit)resume_ksm_children (child, num);stop_ksm_children (child, num); -group_check (1 ,2 , size * num * pages -2 ,0 ,0 ,0 , size * pages * num); +ksm_group_check (1 ,2 , size * num * pages -2 ,0 ,0 ,0 , size * pages * num);resume_ksm_children (child, num);stop_ksm_children (child, num); -group_check (1 ,3 , size * num * pages -3 ,0 ,0 ,0 , size * pages * num); +ksm_group_check (1 ,3 , size * num * pages -3 ,0 ,0 ,0 , size * pages * num);resume_ksm_children (child, num);stop_ksm_children (child, num); -group_check (1 ,1 , size * num * pages -1 ,0 ,0 ,0 , size * pages * num); +ksm_group_check (1 ,1 , size * num * pages -1 ,0 ,0 ,0 , size * pages * num);resume_ksm_children (child, num);stop_ksm_children (child, num); -group_check (1 ,1 , size * num * pages -2 ,0 ,1 ,0 , size * pages * num); +ksm_group_check (1 ,1 , size * num * pages -2 ,0 ,1 ,0 , size * pages * num);tst_res (TINFO ,"KSM unmerging..." );SAFE_FILE_PRINTF (PATH_KSM "run" ,"2" );@@ -586,15 +586,15 @@ void test_ksm_merge_across_nodes(unsigned long nr_pages)tst_res (TINFO ,"Start to test KSM with merge_across_nodes=1" );SAFE_FILE_PRINTF (PATH_KSM "merge_across_nodes" ,"1" );SAFE_FILE_PRINTF (PATH_KSM "run" ,"1" ); -group_check (1 ,1 , nr_pages * num_nodes -1 ,0 ,0 ,0 , - nr_pages * num_nodes); +ksm_group_check (1 ,1 , nr_pages * num_nodes -1 ,0 ,0 ,0 , + nr_pages * num_nodes);SAFE_FILE_PRINTF (PATH_KSM "run" ,"2" );tst_res (TINFO ,"Start to test KSM with merge_across_nodes=0" );SAFE_FILE_PRINTF (PATH_KSM "merge_across_nodes" ,"0" );SAFE_FILE_PRINTF (PATH_KSM "run" ,"1" ); -group_check (1 , num_nodes, nr_pages * num_nodes - num_nodes, -0 ,0 ,0 , nr_pages * num_nodes); +ksm_group_check (1 , num_nodes, nr_pages * num_nodes - num_nodes, +0 ,0 ,0 , nr_pages * num_nodes);SAFE_FILE_PRINTF (PATH_KSM "run" ,"2" );Signature · 1 line
2.34.1
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 3/7 mem/ksm06: Move test code from library to the test
In reply to Cyril HrubisThere is no point in keeping the test code in the library since ksm06 is the only test that actually uses it.
--- testcases/kernel/mem/ksm/ksm06.c | 82 +++++++++++++++++++++++++++++- testcases/kernel/mem/lib/mem.c | 85 -------------------------------- 2 files changed, 81 insertions(+), 86 deletions(-)
testcases/kernel/mem/ksm/ksm06.c +81 -1
@@ -48,7 +48,87 @@ static char *n_opt;static void test_ksm (void ) { -test_ksm_merge_across_nodes (nr_pages); +char **memory; +int i, ret; +int num_nodes, *nodes; +unsigned long length; +unsigned long pagesize; + +#ifdef HAVE_NUMA_V2 +unsigned long nmask[MAXNODES /BITS_PER_LONG ] = {0 }; +#endif + + ret =get_allowed_nodes_arr (NH_MEMS , &num_nodes, &nodes); +if (ret !=0 ) +tst_brk (TBROK |TERRNO ,"get_allowed_nodes_arr" ); +if (num_nodes <2 ) { +tst_res (TINFO ,"need NUMA system support" ); +free (nodes); +return ; + } + + pagesize =sysconf (_SC_PAGE_SIZE); + length = nr_pages * pagesize; + + memory =SAFE_MALLOC (num_nodes *sizeof (char *)); +for (i =0 ; i < num_nodes; i++) { + memory[i] =SAFE_MMAP (NULL , length,PROT_READ |PROT_WRITE , +MAP_ANONYMOUS |MAP_PRIVATE ,-1 ,0 ); +#ifdef HAVE_DECL_MADV_MERGEABLE +if (madvise (memory[i], length,MADV_MERGEABLE ) ==-1 ) +tst_brk (TBROK |TERRNO ,"madvise" ); +#endif + +#ifdef HAVE_NUMA_V2 +clean_node (nmask); +set_node (nmask, nodes[i]); +/* +* Use mbind() to make sure each node contains +* length size memory. +*/ + ret =mbind (memory[i], length,MPOL_BIND , nmask,MAXNODES ,0 ); +if (ret ==-1 ) +tst_brk (TBROK |TERRNO ,"mbind" ); +#endif + +memset (memory[i],10 , length); + +if (mlock (memory[i], length)) +tst_res (TWARN |TERRNO ,"mlock() failed" ); + } + +SAFE_FILE_PRINTF (PATH_KSM "sleep_millisecs" ,"0" ); +SAFE_FILE_PRINTF (PATH_KSM "pages_to_scan" ,"%ld" , + nr_pages * num_nodes); +/* +* merge_across_nodes and max_page_sharing setting can be changed +* only when there are no ksm shared pages in system, so set run 2 +* to unmerge pages first, then to 1 after changing merge_across_nodes, +* to remerge according to the new setting. +*/ +SAFE_FILE_PRINTF (PATH_KSM "run" ,"2" ); +if (access (PATH_KSM "max_page_sharing" ,F_OK ) ==0 ) +SAFE_FILE_PRINTF (PATH_KSM "max_page_sharing" , +"%ld" , nr_pages * num_nodes); +tst_res (TINFO ,"Start to test KSM with merge_across_nodes=1" ); +SAFE_FILE_PRINTF (PATH_KSM "merge_across_nodes" ,"1" ); +SAFE_FILE_PRINTF (PATH_KSM "run" ,"1" ); +ksm_group_check (1 ,1 , nr_pages * num_nodes -1 ,0 ,0 ,0 , + nr_pages * num_nodes); + +SAFE_FILE_PRINTF (PATH_KSM "run" ,"2" ); +tst_res (TINFO ,"Start to test KSM with merge_across_nodes=0" ); +SAFE_FILE_PRINTF (PATH_KSM "merge_across_nodes" ,"0" ); +SAFE_FILE_PRINTF (PATH_KSM "run" ,"1" ); +ksm_group_check (1 , num_nodes, nr_pages * num_nodes - num_nodes, +0 ,0 ,0 , nr_pages * num_nodes); + +SAFE_FILE_PRINTF (PATH_KSM "run" ,"2" ); + +for (i =0 ; i < num_nodes; i++) +SAFE_MUNMAP (memory[i], length); + +free (memory); }static void setup (void )
testcases/kernel/mem/lib/mem.c +0 -85
91 lines not on this page · raw message
Signature · 5 lines
2.34.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 3/7] mem/ksm06: Move test code from library to the test
Hi,
Quoted 4 lines · Cyril Hrubis
There is no point in keeping the test code in the library since ksm06 is the only test that actually uses it.
Signed-off-by Cyril Hrubis <[email protected]>
Quoted 196 lines
--- testcases/kernel/mem/ksm/ksm06.c | 82 +++++++++++++++++++++++++++++- testcases/kernel/mem/lib/mem.c | 85 -------------------------------- 2 files changed, 81 insertions(+), 86 deletions(-)testcases/kernel/mem/ksm/ksm06.c +81
-1@@ -48,7 +48,87 @@ static char *n_opt;static void test_ksm (void ) { -test_ksm_merge_across_nodes (nr_pages); +char **memory; +int i, ret; +int num_nodes, *nodes; +unsigned long length; +unsigned long pagesize; + +#ifdef HAVE_NUMA_V2 +unsigned long nmask[MAXNODES /BITS_PER_LONG ] = {0 }; +#endif + + ret =get_allowed_nodes_arr (NH_MEMS , &num_nodes, &nodes); +if (ret !=0 ) +tst_brk (TBROK |TERRNO ,"get_allowed_nodes_arr" ); +if (num_nodes <2 ) { +tst_res (TINFO ,"need NUMA system support" ); +free (nodes); +return ; + } + + pagesize =sysconf (_SC_PAGE_SIZE); + length = nr_pages * pagesize; + + memory =SAFE_MALLOC (num_nodes *sizeof (char *)); +for (i =0 ; i < num_nodes; i++) { + memory[i] =SAFE_MMAP (NULL , length,PROT_READ |PROT_WRITE , +MAP_ANONYMOUS |MAP_PRIVATE ,-1 ,0 ); +#ifdef HAVE_DECL_MADV_MERGEABLE +if (madvise (memory[i], length,MADV_MERGEABLE ) ==-1 ) +tst_brk (TBROK |TERRNO ,"madvise" ); +#endif + +#ifdef HAVE_NUMA_V2 +clean_node (nmask); +set_node (nmask, nodes[i]); +/* +* Use mbind() to make sure each node contains +* length size memory. +*/ + ret =mbind (memory[i], length,MPOL_BIND , nmask,MAXNODES ,0 ); +if (ret ==-1 ) +tst_brk (TBROK |TERRNO ,"mbind" ); +#endif + +memset (memory[i],10 , length); + +if (mlock (memory[i], length)) +tst_res (TWARN |TERRNO ,"mlock() failed" ); + } + +SAFE_FILE_PRINTF (PATH_KSM "sleep_millisecs" ,"0" ); +SAFE_FILE_PRINTF (PATH_KSM "pages_to_scan" ,"%ld" , + nr_pages * num_nodes); +/* +* merge_across_nodes and max_page_sharing setting can be changed +* only when there are no ksm shared pages in system, so set run 2 +* to unmerge pages first, then to 1 after changing merge_across_nodes, +* to remerge according to the new setting. +*/ +SAFE_FILE_PRINTF (PATH_KSM "run" ,"2" ); +if (access (PATH_KSM "max_page_sharing" ,F_OK ) ==0 ) +SAFE_FILE_PRINTF (PATH_KSM "max_page_sharing" , +"%ld" , nr_pages * num_nodes); +tst_res (TINFO ,"Start to test KSM with merge_across_nodes=1" ); +SAFE_FILE_PRINTF (PATH_KSM "merge_across_nodes" ,"1" ); +SAFE_FILE_PRINTF (PATH_KSM "run" ,"1" ); +ksm_group_check (1 ,1 , nr_pages * num_nodes -1 ,0 ,0 ,0 , + nr_pages * num_nodes); + +SAFE_FILE_PRINTF (PATH_KSM "run" ,"2" ); +tst_res (TINFO ,"Start to test KSM with merge_across_nodes=0" ); +SAFE_FILE_PRINTF (PATH_KSM "merge_across_nodes" ,"0" ); +SAFE_FILE_PRINTF (PATH_KSM "run" ,"1" ); +ksm_group_check (1 , num_nodes, nr_pages * num_nodes - num_nodes, +0 ,0 ,0 , nr_pages * num_nodes); + +SAFE_FILE_PRINTF (PATH_KSM "run" ,"2" ); + +for (i =0 ; i < num_nodes; i++) +SAFE_MUNMAP (memory[i], length); + +free (memory); }static void setup (void )testcases/kernel/mem/lib/mem.c +0
-85@@ -519,91 +519,6 @@ void create_same_memory(int size, int num, int unit) WEXITSTATUS(status)); } -void test_ksm_merge_across_nodes (unsigned long nr_pages) -{ -char **memory; -int i, ret; -int num_nodes, *nodes; -unsigned long length; -unsigned long pagesize; - -#ifdef HAVE_NUMA_V2 -unsigned long nmask[MAXNODES /BITS_PER_LONG ] = {0 }; -#endif - - ret =get_allowed_nodes_arr (NH_MEMS , &num_nodes, &nodes); -if (ret !=0 ) -tst_brk (TBROK |TERRNO ,"get_allowed_nodes_arr" ); -if (num_nodes <2 ) { -tst_res (TINFO ,"need NUMA system support" ); -free (nodes); -return ; - } - - pagesize =sysconf (_SC_PAGE_SIZE); - length = nr_pages * pagesize; - - memory =SAFE_MALLOC (num_nodes *sizeof (char *)); -for (i =0 ; i < num_nodes; i++) { - memory[i] =SAFE_MMAP (NULL , length,PROT_READ |PROT_WRITE , -MAP_ANONYMOUS |MAP_PRIVATE ,-1 ,0 ); -#ifdef HAVE_DECL_MADV_MERGEABLE -if (madvise (memory[i], length,MADV_MERGEABLE ) ==-1 ) -tst_brk (TBROK |TERRNO ,"madvise" ); -#endif - -#ifdef HAVE_NUMA_V2 -clean_node (nmask); -set_node (nmask, nodes[i]); -/* -* Use mbind() to make sure each node contains -* length size memory. -*/ - ret =mbind (memory[i], length,MPOL_BIND , nmask,MAXNODES ,0 ); -if (ret ==-1 ) -tst_brk (TBROK |TERRNO ,"mbind" ); -#endif - -memset (memory[i],10 , length); - -if (mlock (memory[i], length)) -tst_res (TWARN |TERRNO ,"mlock() failed" ); - } - -SAFE_FILE_PRINTF (PATH_KSM "sleep_millisecs" ,"0" ); -SAFE_FILE_PRINTF (PATH_KSM "pages_to_scan" ,"%ld" , - nr_pages * num_nodes); -/* -* merge_across_nodes and max_page_sharing setting can be changed -* only when there are no ksm shared pages in system, so set run 2 -* to unmerge pages first, then to 1 after changing merge_across_nodes, -* to remerge according to the new setting. -*/ -SAFE_FILE_PRINTF (PATH_KSM "run" ,"2" ); -if (access (PATH_KSM "max_page_sharing" ,F_OK ) ==0 ) -SAFE_FILE_PRINTF (PATH_KSM "max_page_sharing" , -"%ld" , nr_pages * num_nodes); -tst_res (TINFO ,"Start to test KSM with merge_across_nodes=1" ); -SAFE_FILE_PRINTF (PATH_KSM "merge_across_nodes" ,"1" ); -SAFE_FILE_PRINTF (PATH_KSM "run" ,"1" ); -ksm_group_check (1 ,1 , nr_pages * num_nodes -1 ,0 ,0 ,0 , - nr_pages * num_nodes); - -SAFE_FILE_PRINTF (PATH_KSM "run" ,"2" ); -tst_res (TINFO ,"Start to test KSM with merge_across_nodes=0" ); -SAFE_FILE_PRINTF (PATH_KSM "merge_across_nodes" ,"0" ); -SAFE_FILE_PRINTF (PATH_KSM "run" ,"1" ); -ksm_group_check (1 , num_nodes, nr_pages * num_nodes - num_nodes, -0 ,0 ,0 , nr_pages * num_nodes); - -SAFE_FILE_PRINTF (PATH_KSM "run" ,"2" ); - -for (i =0 ; i < num_nodes; i++) -SAFE_MUNMAP (memory[i], length); - -free (memory); -} -/* THP */ /* cpuset/memcg */ Signature · 1 line
2.34.1
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 4/7 mem/ksm06: SPDX + docparse comment
In reply to Cyril Hrubis--- testcases/kernel/mem/ksm/ksm06.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
testcases/kernel/mem/ksm/ksm06.c +15 -15
@@ -1,24 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (C) 2013-2017 Red Hat, Inc. +*/ +/*\ +* [Description] * -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. +* The case is designed to test sysfs boolean knob +* /sys/kernel/mm/ksm/merge_across_nodes. * -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -* the GNU General Public License for more details. -*/ - -/* -* The case is designed to test new sysfs boolean knob -* /sys/kernel/mm/ksm/merge_across_nodes, which was introduced by -* commit 90bd6fd31c8097ee (ksm: allow trees per NUMA node). -* when merge_across_nodes is set to zero only pages from the same +* When merge_across_nodes is set to zero only pages from the same * node are merged, otherwise pages from all nodes can be merged * together. +* +* Introduced in commit: +* +* commit 90bd6fd31c8097ee4ddcb74b7e08363134863de5 +* Author: Petr Holasek <[email protected]> +* Date: Fri Feb 22 16:35:00 2013 -0800 +* +* ksm: allow trees per NUMA node */ #include "config.h"
Signature · 5 lines
2.34.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 4/7] mem/ksm06: SPDX + docparse comment
Hi,
Quoted 1 line · Cyril Hrubis
Signed-off-by Cyril Hrubis <[email protected]>
Quoted 50 lines
--- testcases/kernel/mem/ksm/ksm06.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)testcases/kernel/mem/ksm/ksm06.c +15
-15@@ -1,24 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (C) 2013-2017 Red Hat, Inc. +*/ +/*\ +* [Description] * -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. +* The case is designed to test sysfs boolean knob +* /sys/kernel/mm/ksm/merge_across_nodes. * -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -* the GNU General Public License for more details. -*/ - -/* -* The case is designed to test new sysfs boolean knob -* /sys/kernel/mm/ksm/merge_across_nodes, which was introduced by -* commit 90bd6fd31c8097ee (ksm: allow trees per NUMA node). -* when merge_across_nodes is set to zero only pages from the same +* When merge_across_nodes is set to zero only pages from the same * node are merged, otherwise pages from all nodes can be merged * together. +* +* Introduced in commit: +* +* commit 90bd6fd31c8097ee4ddcb74b7e08363134863de5 +* Author: Petr Holasek <[email protected]> +* Date: Fri Feb 22 16:35:00 2013 -0800 +* +* ksm: allow trees per NUMA node */ #include "config.h" Signature · 1 line
2.34.1
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 5/7 mem/ksm06: Move ksm restoration into the tst_test struct
In reply to Cyril Hrubis--- testcases/kernel/mem/ksm/ksm06.c | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-)
testcases/kernel/mem/ksm/ksm06.c +3 -25
@@ -39,9 +39,6 @@#ifdef HAVE_NUMA_V2 #include <numaif.h> -static int run =-1 ; -static int sleep_millisecs =-1 ; -static int merge_across_nodes =-1 ;static unsigned long nr_pages =100 ;static char *n_opt;
@@ -141,27 +138,6 @@ static void setup(void)if (n_opt) nr_pages =SAFE_STRTOUL (n_opt,0 ,ULONG_MAX ); - -/* save the current value */ -SAFE_FILE_SCANF (PATH_KSM "run" ,"%d" , &run); -SAFE_FILE_SCANF (PATH_KSM "merge_across_nodes" , -"%d" , &merge_across_nodes); -SAFE_FILE_SCANF (PATH_KSM "sleep_millisecs" , -"%d" , &sleep_millisecs); -} - -static void cleanup (void ) -{ -if (merge_across_nodes !=-1 ) { -FILE_PRINTF (PATH_KSM "merge_across_nodes" , -"%d" , merge_across_nodes); - } - -if (sleep_millisecs !=-1 ) -FILE_PRINTF (PATH_KSM "sleep_millisecs" ,"%d" , sleep_millisecs); - -if (run !=-1 ) -FILE_PRINTF (PATH_KSM "run" ,"%d" , run); }static struct tst_test test = {
@@ -171,9 +147,11 @@ static struct tst_test test = { {} }, .setup = setup, - .cleanup = cleanup, .save_restore = (const char *const []) {"?/sys/kernel/mm/ksm/max_page_sharing" , +"?/sys/kernel/mm/ksm/run" , +"?/sys/kernel/mm/ksm/merge_across_nodes" , +"?/sys/kernel/mm/ksm/sleep_millisecs" ,NULL , }, .test_all = test_ksm,
Signature · 5 lines
2.34.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 5/7] mem/ksm06: Move ksm restoration into the tst_test struct
Quoted 50 lines · Cyril Hrubis
Signed-off-by Cyril Hrubis <[email protected]>--- testcases/kernel/mem/ksm/ksm06.c | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-)testcases/kernel/mem/ksm/ksm06.c +0
-24@@ -39,9 +39,6 @@#ifdef HAVE_NUMA_V2 #include <numaif.h> -static int run =-1 ; -static int sleep_millisecs =-1 ; -static int merge_across_nodes =-1 ;static unsigned long nr_pages =100 ;static char *n_opt;@@ -141,27 +138,6 @@ static void setup(void)if (n_opt) nr_pages =SAFE_STRTOUL (n_opt,0 ,ULONG_MAX ); - -/* save the current value */ -SAFE_FILE_SCANF (PATH_KSM "run" ,"%d" , &run); -SAFE_FILE_SCANF (PATH_KSM "merge_across_nodes" , -"%d" , &merge_across_nodes); -SAFE_FILE_SCANF (PATH_KSM "sleep_millisecs" , -"%d" , &sleep_millisecs); -} - -static void cleanup (void ) -{ -if (merge_across_nodes !=-1 ) { -FILE_PRINTF (PATH_KSM "merge_across_nodes" , -"%d" , merge_across_nodes); - } - -if (sleep_millisecs !=-1 ) -FILE_PRINTF (PATH_KSM "sleep_millisecs" ,"%d" , sleep_millisecs); - -if (run !=-1 ) -FILE_PRINTF (PATH_KSM "run" ,"%d" , run); }static struct
tst_testtest = {
testcases/kernel/mem/ksm/ksm06.c static struct tst_test test = { · line 152
Quoted 7 lines
testcases/kernel/mem/ksm/ksm06.c +0
-1@@ -171,9 +147,11 @@ static struct tst_test test = { {} }, .setup = setup, - .cleanup = cleanup, .save_restore = (const char *const []) {"?/sys/kernel/mm/ksm/max_page_sharing" ,
The mem library verifies the max_page_sharing validity before setting because some old kernels do not have it. Thus it is fine to use the prefix '?'.
+ "?/sys/kernel/mm/ksm/run",
testcases/kernel/mem/ksm/ksm06.c static struct tst_test test = {
Quoted 3 lines
testcases/kernel/mem/ksm/ksm06.c +2
-0+"?/sys/kernel/mm/ksm/merge_across_nodes" , + "?/sys/kernel/mm/ksm/sleep_millisecs",
But for the two knobs(run, sleep_millisecs) that should exist unless the kernel disables KSM. So here we'd better start with prefix '!' and add .needs_kconfg for ‘CONFIG_KSM=y' check.
(This also fit for other ksm tests)
For 'merge_across_nodes', we don't need any prefix because ksm06 is actually relying on it, otherwise TCONF is expected. Thus it's fine to remove the file check from setup() as well.
Signature · 2 lines
Regards, Li Wang
Signature · 2 lines
-- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 5/7] mem/ksm06: Move ksm restoration into the tst_test struct
Hi!
Quoted 10 lines
The mem library verifies the
max_page_sharingvalidity before setting because some old kernels do not have it. Thus it is fine to use the prefix '?'.+ "?/sys/kernel/mm/ksm/run",
testcases/kernel/mem/ksm/ksm06.c static struct tst_test test = { · line 154
Quoted 3 lines
testcases/kernel/mem/ksm/ksm06.c +2
-0+"?/sys/kernel/mm/ksm/merge_across_nodes" , + "?/sys/kernel/mm/ksm/sleep_millisecs",
Quoted 4 lines
But for the two
knobs(run, sleep_millisecs)that should exist unless the kernel disables KSM. So here we'd better start with prefix '!' and add .needs_kconfg for ???CONFIG_KSM=y' check.
(This also fit for other ksm tests)
I guess that if we put ! before the merge_across_nodes that would cause TBROK on systems without CONFIG_NUMA or kernels without that feature.
So what about just removing the question marks there and adding .need_kconfigs for KSM and NUMA?
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 5/7] mem/ksm06: Move ksm restoration into the tst_test struct
Quoted 16 lines · Cyril Hrubis
Hi!
Quoted 10 lines
The mem library verifies the
max_page_sharingvalidity before setting because some old kernels do not have it. Thus it is fine to use the prefix '?'.+ "?/sys/kernel/mm/ksm/run",
testcases/kernel/mem/ksm/ksm06.c static struct tst_test test = { · line 154
Quoted 3 lines
testcases/kernel/mem/ksm/ksm06.c +2
-0+"?/sys/kernel/mm/ksm/merge_across_nodes" , + "?/sys/kernel/mm/ksm/sleep_millisecs",Quoted 4 lines
But for the two
knobs(run, sleep_millisecs)that should exist unless the kernel disables KSM. So here we'd better start with prefix '!' and add .needs_kconfg for ???CONFIG_KSM=y' check.
(This also fit for other ksm tests)
Quoted 6 lines
I guess that if we put ! before the
merge_across_nodesthat would cause TBROK on systems withoutCONFIG_NUMAor kernels without that feature.So what about just removing the question marks there and adding .need_kconfigs for KSM and NUMA?
Er, that's exactly what I meant in the last email, maybe you overlooked the last sentence:).
i.e.
"
prefix ! for 'run' and 'sleep_milisecs'
no prefix for 'merge_across_nodes'
.need_kconfigs for KSM and NUMA
"
Signature · 2 lines
Regards, Li Wang
Signature · 2 lines
-- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 5/7] mem/ksm06: Move ksm restoration into the tst_test struct
Hi!
Quoted 15 lines
Quoted 11 lines
Quoted 4 lines
But for the two
knobs(run, sleep_millisecs)that should exist unless the kernel disables KSM. So here we'd better start with prefix '!' and add .needs_kconfg for ???CONFIG_KSM=y' check.
(This also fit for other ksm tests)I guess that if we put ! before the
merge_across_nodesthat would cause TBROK on systems withoutCONFIG_NUMAor kernels without that feature.So what about just removing the question marks there and adding .need_kconfigs for KSM and NUMA?
Er, that's exactly what I meant in the last email, maybe you overlooked the last sentence:).
Quoted 7 lines
i.e.
"
prefix ! for 'run' and 'sleep_milisecs'
no prefix for 'merge_across_nodes'
.need_kconfigs for KSM and NUMA
"
Ah, right, sorry. What about this:
testcases/kernel/mem/ksm/ksm06.c +8 -28
@@ -39,9 +39,6 @@#ifdef HAVE_NUMA_V2 #include <numaif.h> -static int run =-1 ; -static int sleep_millisecs =-1 ; -static int merge_across_nodes =-1 ;static unsigned long nr_pages =100 ;static char *n_opt;
@@ -133,35 +130,11 @@ static void test_ksm(void)static void setup (void ) { -if (access (PATH_KSM "merge_across_nodes" ,F_OK ) ==-1 ) -tst_brk (TCONF ,"no merge_across_nodes sysfs knob" ); -if (!is_numa (NULL ,NH_MEMS ,2 ))tst_brk (TCONF ,"The case needs a NUMA system." );if (n_opt) nr_pages =SAFE_STRTOUL (n_opt,0 ,ULONG_MAX ); - -/* save the current value */ -SAFE_FILE_SCANF (PATH_KSM "run" ,"%d" , &run); -SAFE_FILE_SCANF (PATH_KSM "merge_across_nodes" , -"%d" , &merge_across_nodes); -SAFE_FILE_SCANF (PATH_KSM "sleep_millisecs" , -"%d" , &sleep_millisecs); -} - -static void cleanup (void ) -{ -if (merge_across_nodes !=-1 ) { -FILE_PRINTF (PATH_KSM "merge_across_nodes" , -"%d" , merge_across_nodes); - } - -if (sleep_millisecs !=-1 ) -FILE_PRINTF (PATH_KSM "sleep_millisecs" ,"%d" , sleep_millisecs); - -if (run !=-1 ) -FILE_PRINTF (PATH_KSM "run" ,"%d" , run); }static struct tst_test test = {
@@ -171,11 +144,18 @@ static struct tst_test test = { {} }, .setup = setup, - .cleanup = cleanup, .save_restore = (const char *const []) {"?/sys/kernel/mm/ksm/max_page_sharing" , +"!/sys/kernel/mm/ksm/run" , +"!/sys/kernel/mm/ksm/sleep_millisecs" , +"/sys/kernel/mm/ksm/merge_across_nodes" ,NULL , }, + .needs_kconfigs = (const char *const []){ +"CONFIG_KSM=y" , +"CONFIG_NUMA=y" , +NULL + }, .test_all = test_ksm, };
If we add merge_across_nodes without any prefix we can as well remove the check for the file existence in the test setup.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 5/7] mem/ksm06: Move ksm restoration into the tst_test struct
Quoted 100 lines · Cyril Hrubis
Hi!
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
But for the two
knobs(run, sleep_millisecs)that should exist unless the kernel disables KSM. So here we'd better start with prefix '!'and
Quoted 13 lines
Quoted 9 lines
Quoted 2 lines
add .needs_kconfg for ???CONFIG_KSM=y' check.
(This also fit for other ksm tests)I guess that if we put ! before the
merge_across_nodesthat would cause TBROK on systems withoutCONFIG_NUMAor kernels without that feature.So what about just removing the question marks there and adding .need_kconfigs for KSM and NUMA?
Er, that's exactly what I meant in the last email, maybe you overlooked the last sentence:).
Quoted 7 lines
i.e.
"
prefix ! for 'run' and 'sleep_milisecs'
no prefix for 'merge_across_nodes'
.need_kconfigs for KSM and NUMA
"Ah, right, sorry. What about this:
testcases/kernel/mem/ksm/ksm06.c +0
-27@@ -39,9 +39,6 @@#ifdef HAVE_NUMA_V2 #include <numaif.h> -static int run =-1 ; -static int sleep_millisecs =-1 ; -static int merge_across_nodes =-1 ;static unsigned long nr_pages =100 ;static char *n_opt;@@ -133,35 +130,11 @@ static void test_ksm(void)static void setup (void ) { -if (access (PATH_KSM "merge_across_nodes" ,F_OK ) ==-1 ) -tst_brk (TCONF ,"no merge_across_nodes sysfs knob" ); -if (!is_numa (NULL ,NH_MEMS ,2 ))tst_brk (TCONF ,"The case needs a NUMA system." );if (n_opt) nr_pages =SAFE_STRTOUL (n_opt,0 ,ULONG_MAX ); - -/* save the current value */ -SAFE_FILE_SCANF (PATH_KSM "run" ,"%d" , &run); -SAFE_FILE_SCANF (PATH_KSM "merge_across_nodes" , -"%d" , &merge_across_nodes); -SAFE_FILE_SCANF (PATH_KSM "sleep_millisecs" , -"%d" , &sleep_millisecs); -} - -static void cleanup (void ) -{ -if (merge_across_nodes !=-1 ) { -FILE_PRINTF (PATH_KSM "merge_across_nodes" , -"%d" , merge_across_nodes); - } - -if (sleep_millisecs !=-1 ) -FILE_PRINTF (PATH_KSM "sleep_millisecs" ,"%d" , sleep_millisecs); - -if (run !=-1 ) -FILE_PRINTF (PATH_KSM "run" ,"%d" , run); }static struct
tst_testtest = {testcases/kernel/mem/ksm/ksm06.c +8
-1@@ -171,11 +144,18 @@ static struct tst_test test = { {} }, .setup = setup, - .cleanup = cleanup, .save_restore = (const char *const []) {"?/sys/kernel/mm/ksm/max_page_sharing" , +"!/sys/kernel/mm/ksm/run" , +"!/sys/kernel/mm/ksm/sleep_millisecs" , +"/sys/kernel/mm/ksm/merge_across_nodes" ,NULL , }, + .needs_kconfigs = (const char *const []){ +"CONFIG_KSM=y" , +"CONFIG_NUMA=y" , +NULL + }, .test_all = test_ksm, };
Quoted 3 lines
If we add
merge_across_nodeswithout any prefix we can as well remove the check for the file existence in the test setup.
ACK.
Signature · 2 lines
Regards, Li Wang
Signature · 2 lines
-- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 5/7] mem/ksm06: Move ksm restoration into the tst_test struct
Hi!
Quoted 1 line
ACK.
Thanks I will push the patchset with the rest of the fixes you have suggested.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 6/7 libs: libltpnuma: Fix free memory estimate
In reply to Cyril HrubisOn long running systems most of the memory would be consumed by a file page cache which is reclaimable. Because of that the numa test will be skipped even if the system has plenty of memory. To fix this this patch adds 90% of the memory used by the page cache to the free memory estimate.
--- libs/libltpnuma/tst_numa.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
libs/libltpnuma/tst_numa.c +5 -1
@@ -129,6 +129,7 @@ static int node_has_enough_memory(int node, size_t min_kb)char buf[1024 ];long mem_total =0 ;long mem_used =0 ; +long file_pages =0 ;/* Make sure there is some space for kernel upkeeping as well */ min_kb +=4096 ;
@@ -152,6 +153,9 @@ static int node_has_enough_memory(int node, size_t min_kb)if (sscanf (buf,"%*s %*i MemUsed: %li" , &val) ==1 ) mem_used = val; + +if (sscanf (buf,"%*s %*i FilePages: %li" , &val) ==1 ) + file_pages = val; }fclose (fp);
@@ -161,7 +165,7 @@ static int node_has_enough_memory(int node, size_t min_kb)return 0 ; } -if (mem_total - mem_used < (long )min_kb) { +if (mem_total - mem_used + (9 * file_pages)/10 < (long )min_kb) {tst_res (TINFO ,"Not enough free RAM on node %i, have %likB needs %zukB" , node, mem_total - mem_used, min_kb);
Signature · 5 lines
2.34.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 6/7] libs: libltpnuma: Fix free memory estimate
Quoted 7 lines
libs/libltpnuma/tst_numa.c +1
-1-if (mem_total - mem_used < (long )min_kb) { +if (mem_total - mem_used + (9 * file_pages)/10 < (long )min_kb) { tst_res(TINFO, "Not enough free RAM on node %i, have %likB needs%zukB",
node, mem_total - mem_used, min_kb);
We'd better count that part in the output message as well.
Signature · 2 lines
Regards, Li Wang
Signature · 2 lines
-- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 7/7 mem/ksm06: Make use of the new libltpnuma
In reply to Cyril HrubisTHe main benefit is that the new library also makes sure that memory nodes have enough memory for the test.
--- testcases/kernel/mem/ksm/Makefile | 3 ++ testcases/kernel/mem/ksm/ksm06.c | 72 ++++++++++++++----------------- 2 files changed, 35 insertions(+), 40 deletions(-)
testcases/kernel/mem/ksm/Makefile +3 -0
@@ -3,6 +3,9 @@ top_srcdir ?= ../../../.. +LTPLIBS = ltpnuma +ksm06: LTPLDLIBS = -lltpnuma + include $(top_srcdir)/include/mk/testcases.mk include $(top_srcdir)/testcases/kernel/mem/include/libmem.mk include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/mem/ksm/ksm06.c +32 -40
131 lines not on this page · raw message
Signature · 5 lines
2.34.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 7/7] mem/ksm06: Make use of the new libltpnuma
Hi Cyril,
Beside the tiny issues pointed out in [5|6]/7. The remaining part looks good to me.
That would be awesome if you could help cleanup other ksm tests at the same time. Or, I help do that separately later on. (e.g. knob validation, add KSM kconfig, and remove 'merge_across_nodes' from ksm_common.h)
Anyway, nice cleanup work!
Signature · 2 lines
Regards, Li Wang
Signature · 2 lines
-- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Cyril,
very nice cleanup. LGTM.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp