ltp/numa: add new test11
PATCH 1/2 ltp/numa: add new test11
--- testcases/kernel/numa/README | 2 ++ testcases/kernel/numa/numa01.sh | 51 ++++++++++++++++++++++++++++++++-- testcases/kernel/numa/support_numa.c | 53 ++++++++++++++++++++++++++++++++++-- 3 files changed, 101 insertions(+), 5 deletions(-)
testcases/kernel/numa/README +2 -0
@@ -54,6 +54,8 @@ Verifies the numa_node_size api with hardware checking. TestCase10: Verifieds the NUMA migratepages policy. +TestCase11: +Verifies the hugepage memory allocated from the node we specify. Pre-requisites ====================================================================================================================
testcases/kernel/numa/numa01.sh +49 -2
75 lines not on this page · raw message
testcases/kernel/numa/support_numa.c +50 -3
79 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 1/2 ltp/numa: add new test11
ping for these two patch~
Quoted 194 lines · Li Wang
Signed-off-by Li Wang <[email protected]>--- testcases/kernel/numa/README | 2 ++ testcases/kernel/numa/numa01.sh | 51 ++++++++++++++++++++++++++++++++-- testcases/kernel/numa/support_numa.c | 53 ++++++++++++++++++++++++++++++++++-- 3 files changed, 101 insertions(+), 5 deletions(-)testcases/kernel/numa/README +2
-0@@ -54,6 +54,8 @@ Verifies the numa_node_size api with hardware checking. TestCase10: Verifieds the NUMA migratepages policy. +TestCase11: +Verifies the hugepage memory allocated from the node we specify. Pre-requisites ====================================================================================================================testcases/kernel/numa/numa01.sh +49
-2@@ -31,11 +31,12 @@ # Test #8: Verifies memhog # # Test #9: Verifies numa_node_size api # # Test #10:Verifies Migratepages # +# Test #11:Verifies hugepage alloacted on specified node # # # ############################################################################## TST_ID="numa01" -TST_CNT=10 +TST_CNT=11 TST_SETUP=setup TST_TESTFUNC=test TST_NEEDS_TMPDIR=1@@ -83,11 +84,13 @@ setup() { export MB=$((1024*1024)) export PAGE_SIZE=$(getconf PAGE_SIZE) + export HPAGE_SIZE=$(awk '/Hugepagesize:/ {print $2}' /proc/meminfo) # arguments to memory exercise program support_numa.c ALLOC_1MB=1 SHARE_1MB=2 - PAUSE=3 + HUGE_PAGE=3 + PAUSE=4 total_nodes=0@@ -399,4 +402,48 @@ test10() tst_res TPASS "NUMA MIGRATEPAGES policy" } +# Verification of hugepage memory allocated on a node +test11() +{ + Mem_huge=0 + Sys_node=/sys/devices/system/node + + if [ ! -d "/sys/kernel/mm/hugepages/" ]; then + tst_res TCONF "hugepage is not supported" + return + fi + + for node in $nodes_list; do + Ori_hpgs=$(cat ${Sys_node}/node${node}/hugepages/hugepages-${HPAGE_SIZE}kB/nr_hugepages) + New_hpgs=$((Ori_hpgs + 1)) + echo $New_hpgs >${Sys_node}/node${node}/hugepages/hugepages-${HPAGE_SIZE}kB/nr_hugepages + + Chk_hpgs=$(cat ${Sys_node}/node${node}/hugepages/hugepages-${HPAGE_SIZE}kB/nr_hugepages) + if [ "$Chk_hpgs" -ne "$New_hpgs" ]; then + tst_res TCONF "hugepage is not enough to test" + return + fi + + numactl --cpunodebind=$node --membind=$node support_numa $HUGE_PAGE & + pid=$! + wait_for_support_numa $pid + + Mem_huge=$(echo $(numastat -p $pid |awk '/Huge/ {print $'$((node+2))'}')) + Mem_huge=$((${Mem_huge%.*} * 1024)) + + if [ "$Mem_huge" -lt "$HPAGE_SIZE" ]; then + tst_res TFAIL \ + "NUMA memory allocated in node$node is less than expected" + kill -CONT $pid >/dev/null 2>&1 + echo $Ori_hpgs >${Sys_node}/node${node}/hugepages/hugepages-${HPAGE_SIZE}kB/nr_hugepages + return + fi + + kill -CONT $pid >/dev/null 2>&1 + echo $Ori_hpgs >${Sys_node}/node${node}/hugepages/hugepages-${HPAGE_SIZE}kB/nr_hugepages + done + + tst_res TPASS "NUMA local node hugepage memory allocated" +} + tst_runtestcases/kernel/numa/support_numa.c +50
-4@@ -22,7 +22,7 @@/* */ /* File: support_numa.c */ /* */ -/* Description: Allocates 1MB of memory and touches it to verify numa */ +/* Description: Allocates memory and touches it to verify numa */ /* */ /* Author: Sivakumar Chinnaiah [email protected] */ /* */ @@ -52,16 +52,43 @@ static void help(void)printf ("Input: Describe input arguments to this program\n" );printf (" argv[1] == 1 then allocate 1MB of memory\n" );printf (" argv[1] == 2 then allocate 1MB of share memory\n" ); -printf (" argv[1] == 3 then pause the program to catch sigint\n" ); +printf (" argv[1] == 3 then allocate 1HUGE PAGE SIZE of memory\n" ); +printf (" argv[1] == 4 then pause the program to catch sigint\n" );printf ("Exit: On failure - Exits with non-zero value\n" );printf (" On success - exits with 0 exit value\n" );exit (1 ); } +static int read_hugepagesize (void ) +{ +FILE *fp; +char line[BUFSIZ ], buf[BUFSIZ ]; +int val; + + fp =fopen ("/proc/meminfo" ,"r" ); +if (fp ==NULL ) { +fprintf (stderr,"Failed to open /proc/meminfo" ); +return 0 ; + } + +while (fgets (line,BUFSIZ , fp) !=NULL ) { +if (sscanf (line,"%64s %d" , buf, &val) ==2 ) +if (strcmp (buf,"Hugepagesize:" ) ==0 ) { +fclose (fp); +return 1024 * val; + } + } + +fclose (fp); +fprintf (stderr,"can't find \"%s\" in %s" ,"Hugepagesize:" ,"/proc/meminfo" ); + +return 0 ; +} +int main (int argc,char *argv[]) { -int i, fd, rc; +int i, fd, rc, hpsz;char *buf =NULL ;struct stat sb;@@ -114,6 +141,26 @@ int main(int argc, char *argv[])remove (TEST_SFILE );break ;case 3 : + hpsz =read_hugepagesize (); +if (hpsz ==0 ) +exit (1 ); + + buf =mmap (NULL , hpsz,PROT_READ |PROT_WRITE , +MAP_PRIVATE |MAP_ANONYMOUS |MAP_HUGETLB , +-1 ,0 ); + +if (buf ==MAP_FAILED ) { +perror ("mmap failed" ); +exit (1 ); + } + +memset (buf,'a' , hpsz); + +raise (SIGSTOP ); + +munmap (buf, hpsz); +break ; +case 4 :raise (SIGSTOP );break ;default : --1.8.3.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 3 lines
Regards, Li Wang Email: [email protected]
PATCH 2/2 ltp/numa: Kill the support_numa if FAILED
In reply to Li Wang--- testcases/kernel/numa/numa01.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
testcases/kernel/numa/numa01.sh +11 -3
@@ -56,7 +56,7 @@ extract_numastat_p() local pid=$1 local node=$(($2 + 2)) - echo $(numastat -p $pid |grep '^Total' |awk '{print $'$node'}') + echo $(numastat -p $pid |awk '/^Total/ {print $'$node'}') } wait_for_support_numa()
@@ -121,6 +121,7 @@ test1() if [ $(echo "$Mem_curr < $MB" | bc) -eq 1 ]; then tst_res TFAIL \ "NUMA memory allocated in node$node is less than expected" + kill -CONT $pid >/dev/null 2>&1 return fi
@@ -154,6 +155,7 @@ test2() if [ $(echo "$Mem_curr < $MB" |bc ) -eq 1 ]; then tst_res TFAIL \ "NUMA memory allocated in node$Preferred_node is less than expected" + kill -CONT $pid >/dev/null 2>&1 return fi
@@ -189,6 +191,7 @@ test3() if [ $(echo "$Mem_curr < $MB" |bc ) -eq 1 ]; then tst_res TFAIL \ "NUMA share memory allocated in node$Preferred_node is less than expected" + kill -CONT $pid >/dev/null 2>&1 return fi
@@ -217,6 +220,7 @@ test4() if [ $(echo "$Mem_curr < $Exp_incr" |bc ) -eq 1 ]; then tst_res TFAIL \ "NUMA interleave memory allocated in node$node is less than expected" + kill -CONT $pid >/dev/null 2>&1 return fi done
@@ -243,6 +247,7 @@ test5() if [ $(echo "$Mem_curr < $Exp_incr" |bc ) -eq 1 ]; then tst_res TFAIL \ "NUMA interleave share memory allocated in node$node is less than expected" + kill -CONT $pid >/dev/null 2>&1 return fi done
@@ -299,6 +304,7 @@ test7() if [ $(echo "$Mem_curr < $MB" |bc ) -eq 1 ]; then tst_res TFAIL \ "NUMA localnode memory allocated in node$node is less than expected" + kill -CONT $pid >/dev/null 2>&1 return fi
@@ -324,11 +330,12 @@ test8() if [ $(echo "$Mem_curr < $Exp_incr" |bc ) -eq 1 ]; then tst_res TFAIL \ "NUMA interleave memhog in node$node is less than expected" + kill -KILL $pid >/dev/null 2>&1 return fi done - kill -9 $pid >/dev/null 2>&1 + kill -KILL $pid >/dev/null 2>&1 tst_res TPASS "NUMA MEMHOG policy" }
@@ -392,6 +399,7 @@ test10() if [ $(echo "$Mem_curr < $MB" |bc ) -eq 1 ]; then tst_res TFAIL \ "NUMA migratepages is not working fine" + kill -CONT $pid >/dev/null 2>&1 return fi
@@ -428,7 +436,7 @@ test11() pid=$! wait_for_support_numa $pid - Mem_huge=$(echo $(numastat -p $pid |awk '/Huge/ {print $'$((node+2))'}')) + Mem_huge=$(echo $(numastat -p $pid |awk '/^Huge/ {print $'$((node+2))'}')) Mem_huge=$((${Mem_huge%.*} * 1024)) if [ "$Mem_huge" -lt "$HPAGE_SIZE" ]; then
Signature · 1 line
1.8.3.1
PATCH 1/2 ltp/numa: add new test11
In reply to Li WangHi!
testcases/kernel/numa/support_numa.c static void help(void) · line 58
Quoted 9 lines
testcases/kernel/numa/support_numa.c +2
-1@@ -52,16 +52,43 @@ static void help(void)printf ("Input: Describe input arguments to this program\n" );printf (" argv[1] == 1 then allocate 1MB of memory\n" );printf (" argv[1] == 2 then allocate 1MB of share memory\n" ); -printf (" argv[1] == 3 then pause the program to catch sigint\n" ); +printf (" argv[1] == 3 then allocate 1HUGE PAGE SIZE of memory\n" ); +printf (" argv[1] == 4 then pause the program to catch sigint\n" );printf ("Exit: On failure - Exits with non-zero value\n" );printf (" On success - exits with 0 exit value\n" );
Can we, pretty please, change this parameter to a string that describes the operation?
Something as:
argv[1] == "alloc_1MB" argv[1] == "alloc_1MB_shared" argv[1] == "alloc_huge_page" argv[1] == "pause"
So that we can use the helper as:
numactl --cpunodebind=$node --membind=$node support_numa alloc_1MB &
The helper would then do the classical if else:
if (!strcmp(argv[1], "alloc_1MB")) {
...
} else if (!strcmp(argv[1], "alloc_1MB_shared")) {
...
} else {
help();
}Otherwise it looks fine.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/2 ltp/numa: add new test11
Quoted 13 lines · Cyril Hrubis
Hi!
testcases/kernel/numa/support_numa.c static void help(void) · line 58
Quoted 9 lines
testcases/kernel/numa/support_numa.c +2
-1@@ -52,16 +52,43 @@ static void help(void)printf ("Input: Describe input arguments to this program\n" );printf (" argv[1] == 1 then allocate 1MB of memory\n" );printf (" argv[1] == 2 then allocate 1MB of share memory\n" ); -printf (" argv[1] == 3 then pause the program to catch sigint\n" ); +printf (" argv[1] == 3 then allocate 1HUGE PAGE SIZE of memory\n" ); +printf (" argv[1] == 4 then pause the program to catch sigint\n" );printf ("Exit: On failure - Exits with non-zero value\n" );printf (" On success - exits with 0 exit value\n" );Can we, pretty please, change this parameter to a string that describes the operation?
Sure, sounds good. But I hope to change this in a new patch, because these exist two are focus on different issues. I don't wanna mess things up.
Signature · 3 lines
Regards, Li Wang Email: [email protected]