mm/thp: add two new case
v5 cover mm/thp: add two new case
The patchset is desinged to test THP functionality.
when one process allocate hugepage aligned anonymous pages, kernel thread 'khugepaged' controlled by sysfs knobs /sys/kernel/mm/transparent_hugepage/* will scan them, and make them as transparent hugepage if they are suited, you can find out how many transparent hugepages are there in one process from /proc/<pid>/smaps, among the file contents, 'AnonHugePages' entry stand for transparent hugepage.
v1 to v2:
accepted Wanlong's suggestion, added some comment for '10s' added 'static' key word for single-file-only variant.
v2 to v3:
added some comments for low memory system.
v3 to v4:
Wanglong point out that the value of khugepaged/defrag is string type, not a numeric before applying the commit e27e6151b154 in v2.6.39-rc4, and I checked the code again, found the current cases thp0* don't be effected by khugepaged/defrag, so I removed the checking of khugepaged/defrag from khugepaged_scan_done().
v4 to v5:
1. made some cleaup
2. updated 10s to 5s for each checking in khugepaged_scan_done()
3. used SAFE_FILE_SCANF|PRINTF() instead of write_file()
Zhouping Liu (3):
mm/thp: new case thp04.c
lib/mem: introduce a new function set_global_mempolicy() mm/thp: add new case thp05
runtest/mm | 6 ++ testcases/kernel/mem/include/mem.h | 12 +++ testcases/kernel/mem/lib/mem.c | 199 ++++++++++++++++++++++++++++++++++++- testcases/kernel/mem/thp/thp04.c | 142 ++++++++++++++++++++++++++ testcases/kernel/mem/thp/thp05.c | 155 +++++++++++++++++++++++++++++ 5 files changed, 513 insertions(+), 1 deletion(-) create mode 100644 testcases/kernel/mem/thp/thp04.c create mode 100644 testcases/kernel/mem/thp/thp05.c
Signature · 13 lines
1.7.11.7 ------------------------------------------------------------------------------ Precog is a next-generation analytics platform capable of advanced analytics on semi-structured data. The platform includes APIs for building apps and a phenomenal toolset for data science. Developers can use our toolset for easy data analysis & visualization. Get a free account! http://www2.precog.com/precogplatform/slashdotnewsletter _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
PATCH v5 1/3 mm/thp: new case thp04.c
The case is desinged to test THP functionality.
when one process allocate hugepage aligned anonymous pages, kernel thread 'khugepaged' controlled by sysfs knobs /sys/kernel/mm/transparent_hugepage/* will scan them, and make them as transparent hugepage if they are suited, you can find out how many transparent hugepages are there in one process from /proc/<pid>/smaps, among the file contents, 'AnonHugePages' entry stand for transparent hugepage.
--- runtest/mm | 3 + testcases/kernel/mem/include/mem.h | 11 +++ testcases/kernel/mem/lib/mem.c | 188 +++++++++++++++++++++++++++++++++++++ testcases/kernel/mem/thp/thp04.c | 142 ++++++++++++++++++++++++++++ 4 files changed, 344 insertions(+) create mode 100644 testcases/kernel/mem/thp/thp04.c
runtest/mm +3 -0
@@ -84,6 +84,9 @@ swapping01 swapping01 -i 5 thp01 thp01 -I 120 thp02 thp02 thp03 thp03 +thp04_1 thp04 +thp04_2 thp04 -n 10 -N 20 +thp04_3 thp04 -n 1 -N 300 vma01 vma01 vma02 vma02
testcases/kernel/mem/include/mem.h +11 -0
@@ -32,6 +32,17 @@ void testoom(int mempolicy, int lite);#define PATH_KSM "/sys/kernel/mm/ksm/" +/* THP */ + +#define PATH_THP "/sys/kernel/mm/transparent_hugepage/" +#define PATH_KHPD PATH_THP "khugepaged/" + +int opt_nr_children, opt_nr_thps; +char *opt_nr_children_str, *opt_nr_thps_str; +void test_transparent_hugepage (int nr_children,int nr_thps,int hg_aligned); +void check_thp_options (int *nr_children,int *nr_thps); +void thp_usage (void ); +/* HUGETLB */ #define PATH_SHMMAX "/proc/sys/kernel/shmmax"
testcases/kernel/mem/lib/mem.c +188 -0
194 lines not on this page · raw message
testcases/kernel/mem/thp/thp04.c new file +142 -0
142 lines not on this page · raw message
Signature · 13 lines
1.7.11.7 ------------------------------------------------------------------------------ Precog is a next-generation analytics platform capable of advanced analytics on semi-structured data. The platform includes APIs for building apps and a phenomenal toolset for data science. Developers can use our toolset for easy data analysis & visualization. Get a free account! http://www2.precog.com/precogplatform/slashdotnewsletter _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
PATCH v5 2/3 lib/mem: introduce a new function set_global_mempolicy()
Fork out a new function set_global_mempolicy() from the previous testoom() func, which will be useful for other func.
--- testcases/kernel/mem/include/mem.h | 3 ++- testcases/kernel/mem/lib/mem.c | 13 +++++++++++-- testcases/kernel/mem/thp/thp04.c | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-)
testcases/kernel/mem/include/mem.h +2 -1
@@ -39,7 +39,8 @@ void testoom(int mempolicy, int lite);int opt_nr_children, opt_nr_thps;char *opt_nr_children_str, *opt_nr_thps_str; -void test_transparent_hugepage (int nr_children,int nr_thps,int hg_aligned); +void test_transparent_hugepage (int nr_children,int nr_thps, +int hg_aligned,int mempolicy);void check_thp_options (int *nr_children,int *nr_thps);void thp_usage (void );
testcases/kernel/mem/lib/mem.c +11 -2
@@ -91,7 +91,7 @@ void oom(int testcase, int lite) } } -void testoom (int mempolicy,int lite) +static void set_global_mempolicy (int mempolicy) {#if HAVE_NUMA_H &&HAVE_LINUX_MEMPOLICY_H &&HAVE_NUMAIF_H \ &&HAVE_MPOL_CONSTANTS
@@ -133,6 +133,11 @@ void testoom(int mempolicy, int lite) tst_brkm(TBROK|TERRNO, cleanup, "set_mempolicy"); }#endif +} + +void testoom (int mempolicy,int lite) +{ +set_global_mempolicy (mempolicy);tst_resm (TINFO ,"start normal OOM testing." );oom (NORMAL , lite);
@@ -613,12 +618,16 @@ static void verify_thp_size(int *children, int nr_children, int nr_thps) } } -void test_transparent_hugepage (int nr_children,int nr_thps,int hg_aligned) +void test_transparent_hugepage (int nr_children,int nr_thps, +int hg_aligned,int mempolicy) {unsigned long hugepagesize, memfree;int i, *pids, ret, status;char path[BUFSIZ ]; +if (mempolicy) +set_global_mempolicy (mempolicy); + memfree =read_meminfo ("MemFree:" );tst_resm (TINFO ,"The current MemFree is %luMB" , memfree /KB );if (memfree <MB )
testcases/kernel/mem/thp/thp04.c +1 -1
@@ -83,7 +83,7 @@ int main(int argc, char *argv[])for (lc =0 ;TEST_LOOPING (lc); lc++) { tst_count =0 ; -test_transparent_hugepage (nr_children, nr_thps,1 ); +test_transparent_hugepage (nr_children, nr_thps,1 ,0 ); }cleanup ();
Signature · 13 lines
1.7.11.7 ------------------------------------------------------------------------------ Precog is a next-generation analytics platform capable of advanced analytics on semi-structured data. The platform includes APIs for building apps and a phenomenal toolset for data science. Developers can use our toolset for easy data analysis & visualization. Get a free account! http://www2.precog.com/precogplatform/slashdotnewsletter _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
PATCH v5 3/3 mm/thp: add new case thp05
added new case thp05, which is used to test transparent hugepage under mempolicy - NUMA.
--- runtest/mm | 3 + testcases/kernel/mem/thp/thp05.c | 155 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100644 testcases/kernel/mem/thp/thp05.c
runtest/mm +3 -0
@@ -87,6 +87,9 @@ thp03 thp03 thp04_1 thp04 thp04_2 thp04 -n 10 -N 20 thp04_3 thp04 -n 1 -N 300 +thp05_1 thp05 +thp05_2 thp05 -n 10 -N 20 +thp05_3 thp05 -n 1 -N 300 vma01 vma01 vma02 vma02
testcases/kernel/mem/thp/thp05.c new file +155 -0
155 lines not on this page · raw message
Signature · 13 lines
1.7.11.7 ------------------------------------------------------------------------------ Precog is a next-generation analytics platform capable of advanced analytics on semi-structured data. The platform includes APIs for building apps and a phenomenal toolset for data science. Developers can use our toolset for easy data analysis & visualization. Get a free account! http://www2.precog.com/precogplatform/slashdotnewsletter _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Re: [LTP] [PATCH v5 3/3] mm/thp: add new case thp05
Hi!
Here is the last nit (the rest of the code looks ok).
Applies for the next test as well.
Quoted 9 lines
testcases/kernel/mem/thp/thp05.c new file +9
-0+void setup (void ) +{ +char path[BUFSIZ ]; + +tst_require_root (NULL ); + +if (access (PATH_THP ,F_OK ) ==-1 ) +tst_brkm (TCONF ,NULL ,"THP is not enabled" ); +
testcases/kernel/mem/thp/thp05.c line 123
Quoted 10 lines
testcases/kernel/mem/thp/thp05.c new file +10
-0+if (!is_numa (NULL )) +tst_brkm (TCONF ,NULL ,"The case need a NUMA system." ); + +SAFE_FILE_SCANF (NULL ,PATH_KHPD "scan_sleep_millisecs" , +"%d" , &pre_thp_scan_sleep_millisecs); +SAFE_FILE_PRINTF (NULL ,PATH_KHPD "scan_sleep_millisecs" ,"%d" ,0 ); + +SAFE_FILE_SCANF (NULL ,PATH_KHPD "alloc_sleep_millisecs" , +"%d" , &pre_thp_alloc_sleep_millisecs); +SAFE_FILE_PRINTF (NULL ,PATH_KHPD "alloc_sleep_millisecs" ,"%d" ,0 );
No need to convert the constant integer via "%d", just pass the "0" string.
Review
Quoted 2 lines
(quoted diff) +2
-0+ SAFE_FILE_SCANF(NULL, PATH_THP "enabled", "%[^\n]", pre_thp_enabled); + SAFE_FILE_PRINTF(NULL, PATH_THP "enabled", "%s", "always");
No need to pass the "always" via "%s", just pass it directly.
Quoted 4 lines
testcases/kernel/mem/thp/thp05.c new file +4
-0+ +tst_sig (FORK ,DEF_HANDLER ,NULL ); +TEST_PAUSE ; +}
Signature · 13 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ Precog is a next-generation analytics platform capable of advanced analytics on semi-structured data. The platform includes APIs for building apps and a phenomenal toolset for data science. Developers can use our toolset for easy data analysis & visualization. Get a free account! http://www2.precog.com/precogplatform/slashdotnewsletter _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list