public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v3 1/3] ltp/numa: add new test11
@ 2017-05-19  8:25 Li Wang
  2017-05-19  8:25 ` [LTP] [PATCH v3 2/3] ltp/numa: Kill the support_numa if FAILED Li Wang
  2017-05-19  8:25 ` [LTP] [PATCH v3 3/3] ltp/numa: use string to describe operation Li Wang
  0 siblings, 2 replies; 9+ messages in thread
From: Li Wang @ 2017-05-19  8:25 UTC (permalink / raw)
  To: ltp

Signed-off-by: Li Wang <liwang@redhat.com>
---
 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(-)

diff --git a/testcases/kernel/numa/README b/testcases/kernel/numa/README
index 57b12f7..a5c3f1b 100644
--- a/testcases/kernel/numa/README
+++ b/testcases/kernel/numa/README
@@ -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
 ====================================================================================================================
diff --git a/testcases/kernel/numa/numa01.sh b/testcases/kernel/numa/numa01.sh
index f0f6139..69e5357 100755
--- a/testcases/kernel/numa/numa01.sh
+++ b/testcases/kernel/numa/numa01.sh
@@ -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_run
diff --git a/testcases/kernel/numa/support_numa.c b/testcases/kernel/numa/support_numa.c
index eaf63e3..97f3008 100644
--- a/testcases/kernel/numa/support_numa.c
+++ b/testcases/kernel/numa/support_numa.c
@@ -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  Sivakumar.C@in.ibm.com                   */
 /*                                                                            */
@@ -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:
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [LTP] [PATCH v3 2/3] ltp/numa: Kill the support_numa if FAILED
  2017-05-19  8:25 [LTP] [PATCH v3 1/3] ltp/numa: add new test11 Li Wang
@ 2017-05-19  8:25 ` Li Wang
  2017-05-19  8:25 ` [LTP] [PATCH v3 3/3] ltp/numa: use string to describe operation Li Wang
  1 sibling, 0 replies; 9+ messages in thread
From: Li Wang @ 2017-05-19  8:25 UTC (permalink / raw)
  To: ltp

Signed-off-by: Li Wang <liwang@redhat.com>
---
 testcases/kernel/numa/numa01.sh | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/numa/numa01.sh b/testcases/kernel/numa/numa01.sh
index 69e5357..93d74cc 100755
--- a/testcases/kernel/numa/numa01.sh
+++ b/testcases/kernel/numa/numa01.sh
@@ -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
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [LTP] [PATCH v3 3/3] ltp/numa: use string to describe operation
  2017-05-19  8:25 [LTP] [PATCH v3 1/3] ltp/numa: add new test11 Li Wang
  2017-05-19  8:25 ` [LTP] [PATCH v3 2/3] ltp/numa: Kill the support_numa if FAILED Li Wang
@ 2017-05-19  8:25 ` Li Wang
  2017-05-19  8:32   ` Li Wang
  1 sibling, 1 reply; 9+ messages in thread
From: Li Wang @ 2017-05-19  8:25 UTC (permalink / raw)
  To: ltp

Signed-off-by: Li Wang <liwang@redhat.com>
---
 testcases/kernel/numa/numa01.sh      | 24 +++++++++---------------
 testcases/kernel/numa/support_numa.c | 23 +++++++++--------------
 2 files changed, 18 insertions(+), 29 deletions(-)

diff --git a/testcases/kernel/numa/numa01.sh b/testcases/kernel/numa/numa01.sh
index 93d74cc..4eda3f1 100755
--- a/testcases/kernel/numa/numa01.sh
+++ b/testcases/kernel/numa/numa01.sh
@@ -86,12 +86,6 @@ setup()
 	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
-	HUGE_PAGE=3
-	PAUSE=4
-
 	total_nodes=0
 
 	nodes_list=$(numactl --show | grep nodebind | cut -d ':' -f 2)
@@ -112,7 +106,7 @@ test1()
 	Mem_curr=0
 
 	for node in $nodes_list; do
-		numactl --cpunodebind=$node --membind=$node support_numa $ALLOC_1MB &
+		numactl --cpunodebind=$node --membind=$node support_numa alloc_1MB &
 		pid=$!
 
 		wait_for_support_numa $pid
@@ -146,7 +140,7 @@ test2()
 			Preferred_node=$(echo $nodes_list | cut -d ' ' -f $((COUNTER+1)))
 		fi
 
-		numactl --cpunodebind=$node --preferred=$Preferred_node support_numa $ALLOC_1MB &
+		numactl --cpunodebind=$node --preferred=$Preferred_node support_numa alloc_1MB &
 		pid=$!
 
 		wait_for_support_numa $pid
@@ -182,7 +176,7 @@ test3()
 			Preferred_node=$(echo $nodes_list | cut -d ' ' -f $((COUNTER+1)))
 		fi
 
-		numactl --cpunodebind=$node --preferred=$Preferred_node support_numa $SHARE_1MB &
+		numactl --cpunodebind=$node --preferred=$Preferred_node support_numa alloc_1MB_shared &
 		pid=$!
 
 		wait_for_support_numa $pid
@@ -209,7 +203,7 @@ test4()
 	# Memory will be allocated using round robin on nodes.
 	Exp_incr=$(echo "$MB / $total_nodes" |bc)
 
-	numactl --interleave=all support_numa $ALLOC_1MB &
+	numactl --interleave=all support_numa alloc_1MB &
 	pid=$!
 
 	wait_for_support_numa $pid
@@ -236,7 +230,7 @@ test5()
 	# Memory will be allocated using round robin on nodes.
 	Exp_incr=$(echo "$MB / $total_nodes" |bc)
 
-	numactl --interleave=all support_numa $SHARE_1MB &
+	numactl --interleave=all support_numa alloc_1MB_shared &
 	pid=$!
 
 	wait_for_support_numa $pid
@@ -267,7 +261,7 @@ test6()
 	no_of_cpus=$(tst_ncpus)
 	# not sure whether cpu's can't be in odd number
 	run_on_cpu=$(($((no_of_cpus+1))/2))
-	numactl --physcpubind=$run_on_cpu support_numa $PAUSE & #just waits for sigint
+	numactl --physcpubind=$run_on_cpu support_numa pause & #just waits for sigint
 	pid=$!
 	var=`awk '{ print $2 }' /proc/$pid/stat`
 	while [ $var = '(numactl)' ]; do
@@ -295,7 +289,7 @@ test7()
 	Mem_curr=0
 
 	for node in $nodes_list; do
-		numactl --cpunodebind=$node --localalloc support_numa $ALLOC_1MB &
+		numactl --cpunodebind=$node --localalloc support_numa alloc_1MB &
 		pid=$!
 
 		wait_for_support_numa $pid
@@ -388,7 +382,7 @@ test10()
 			Preferred_node=$(echo $nodes_list | cut -d ' ' -f $((COUNTER+1)))
 		fi
 
-		numactl --preferred=$node support_numa $ALLOC_1MB &
+		numactl --preferred=$node support_numa alloc_1MB &
 		pid=$!
 
 		wait_for_support_numa $pid
@@ -432,7 +426,7 @@ test11()
 			return
 		fi
 
-		numactl --cpunodebind=$node --membind=$node support_numa $HUGE_PAGE &
+		numactl --cpunodebind=$node --membind=$node support_numa alloc_1huge_page &
 		pid=$!
 		wait_for_support_numa $pid
 
diff --git a/testcases/kernel/numa/support_numa.c b/testcases/kernel/numa/support_numa.c
index 97f3008..fef8277 100644
--- a/testcases/kernel/numa/support_numa.c
+++ b/testcases/kernel/numa/support_numa.c
@@ -50,10 +50,10 @@
 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 allocate 1HUGE PAGE SIZE of memory\n");
-	printf("        argv[1] == 4 then pause the program to catch sigint\n");
+	printf("	argv[1] == "alloc_1MB" then allocate 1MB of memory\n");
+	printf("	argv[1] == "alloc_1MB_shared" then allocate 1MB of share memory\n");
+	printf("        argv[1] == "alloc_1huge_page" then allocate 1HUGE PAGE SIZE of memory\n");
+	printf("        argv[1] == "pause" 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");
 
@@ -97,8 +97,7 @@ int main(int argc, char *argv[])
 		exit(1);
 	}
 
-	switch (atoi(argv[1])) {
-	case 1:
+	if (!strcmp(argv[1], "alloc_1MB")) {
 		buf = malloc(MB);
 		if (!buf) {
 			fprintf(stderr, "Memory is not available\n");
@@ -112,8 +111,7 @@ int main(int argc, char *argv[])
 		raise(SIGSTOP);
 
 		free(buf);
-		break;
-	case 2:
+	} else if (!strcmp(argv[1], "alloc_1MB_shared")) {
 		fd = open(TEST_SFILE, O_RDWR | O_CREAT, 0666);
 		/* Writing 1MB of random data into this file [32 * 32768 = 1024 * 1024] */
 		for (i = 0; i < 32768; i++){
@@ -139,8 +137,7 @@ int main(int argc, char *argv[])
 		munmap(buf, sb.st_size);
 		close(fd);
 		remove(TEST_SFILE);
-		break;
-	case 3:
+	} else if (!strcmp(argv[1], "alloc_1huge_page")) {
 		hpsz = read_hugepagesize();
 		if (hpsz == 0)
 			exit(1);
@@ -159,11 +156,9 @@ int main(int argc, char *argv[])
 		raise(SIGSTOP);
 
 		munmap(buf, hpsz);
-		break;
-	case 4:
+	} else if (!strcmp(argv[1], "pause")) {
 		raise(SIGSTOP);
-		break;
-	default:
+	} else {
 		help();
 	}
 
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [LTP] [PATCH v3 3/3] ltp/numa: use string to describe operation
@ 2017-05-19  8:27 Li Wang
  2017-05-19 12:23 ` Cyril Hrubis
  0 siblings, 1 reply; 9+ messages in thread
From: Li Wang @ 2017-05-19  8:27 UTC (permalink / raw)
  To: ltp

Signed-off-by: Li Wang <liwang@redhat.com>
---
 testcases/kernel/numa/numa01.sh      | 24 +++++++++---------------
 testcases/kernel/numa/support_numa.c | 23 +++++++++--------------
 2 files changed, 18 insertions(+), 29 deletions(-)

diff --git a/testcases/kernel/numa/numa01.sh b/testcases/kernel/numa/numa01.sh
index 93d74cc..4eda3f1 100755
--- a/testcases/kernel/numa/numa01.sh
+++ b/testcases/kernel/numa/numa01.sh
@@ -86,12 +86,6 @@ setup()
 	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
-	HUGE_PAGE=3
-	PAUSE=4
-
 	total_nodes=0
 
 	nodes_list=$(numactl --show | grep nodebind | cut -d ':' -f 2)
@@ -112,7 +106,7 @@ test1()
 	Mem_curr=0
 
 	for node in $nodes_list; do
-		numactl --cpunodebind=$node --membind=$node support_numa $ALLOC_1MB &
+		numactl --cpunodebind=$node --membind=$node support_numa alloc_1MB &
 		pid=$!
 
 		wait_for_support_numa $pid
@@ -146,7 +140,7 @@ test2()
 			Preferred_node=$(echo $nodes_list | cut -d ' ' -f $((COUNTER+1)))
 		fi
 
-		numactl --cpunodebind=$node --preferred=$Preferred_node support_numa $ALLOC_1MB &
+		numactl --cpunodebind=$node --preferred=$Preferred_node support_numa alloc_1MB &
 		pid=$!
 
 		wait_for_support_numa $pid
@@ -182,7 +176,7 @@ test3()
 			Preferred_node=$(echo $nodes_list | cut -d ' ' -f $((COUNTER+1)))
 		fi
 
-		numactl --cpunodebind=$node --preferred=$Preferred_node support_numa $SHARE_1MB &
+		numactl --cpunodebind=$node --preferred=$Preferred_node support_numa alloc_1MB_shared &
 		pid=$!
 
 		wait_for_support_numa $pid
@@ -209,7 +203,7 @@ test4()
 	# Memory will be allocated using round robin on nodes.
 	Exp_incr=$(echo "$MB / $total_nodes" |bc)
 
-	numactl --interleave=all support_numa $ALLOC_1MB &
+	numactl --interleave=all support_numa alloc_1MB &
 	pid=$!
 
 	wait_for_support_numa $pid
@@ -236,7 +230,7 @@ test5()
 	# Memory will be allocated using round robin on nodes.
 	Exp_incr=$(echo "$MB / $total_nodes" |bc)
 
-	numactl --interleave=all support_numa $SHARE_1MB &
+	numactl --interleave=all support_numa alloc_1MB_shared &
 	pid=$!
 
 	wait_for_support_numa $pid
@@ -267,7 +261,7 @@ test6()
 	no_of_cpus=$(tst_ncpus)
 	# not sure whether cpu's can't be in odd number
 	run_on_cpu=$(($((no_of_cpus+1))/2))
-	numactl --physcpubind=$run_on_cpu support_numa $PAUSE & #just waits for sigint
+	numactl --physcpubind=$run_on_cpu support_numa pause & #just waits for sigint
 	pid=$!
 	var=`awk '{ print $2 }' /proc/$pid/stat`
 	while [ $var = '(numactl)' ]; do
@@ -295,7 +289,7 @@ test7()
 	Mem_curr=0
 
 	for node in $nodes_list; do
-		numactl --cpunodebind=$node --localalloc support_numa $ALLOC_1MB &
+		numactl --cpunodebind=$node --localalloc support_numa alloc_1MB &
 		pid=$!
 
 		wait_for_support_numa $pid
@@ -388,7 +382,7 @@ test10()
 			Preferred_node=$(echo $nodes_list | cut -d ' ' -f $((COUNTER+1)))
 		fi
 
-		numactl --preferred=$node support_numa $ALLOC_1MB &
+		numactl --preferred=$node support_numa alloc_1MB &
 		pid=$!
 
 		wait_for_support_numa $pid
@@ -432,7 +426,7 @@ test11()
 			return
 		fi
 
-		numactl --cpunodebind=$node --membind=$node support_numa $HUGE_PAGE &
+		numactl --cpunodebind=$node --membind=$node support_numa alloc_1huge_page &
 		pid=$!
 		wait_for_support_numa $pid
 
diff --git a/testcases/kernel/numa/support_numa.c b/testcases/kernel/numa/support_numa.c
index 97f3008..b6aa8bd 100644
--- a/testcases/kernel/numa/support_numa.c
+++ b/testcases/kernel/numa/support_numa.c
@@ -50,10 +50,10 @@
 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 allocate 1HUGE PAGE SIZE of memory\n");
-	printf("        argv[1] == 4 then pause the program to catch sigint\n");
+	printf("	argv[1] == \"alloc_1MB\" then allocate 1MB of memory\n");
+	printf("	argv[1] == \"alloc_1MB_shared\" then allocate 1MB of share memory\n");
+	printf("        argv[1] == \"alloc_1huge_page\" then allocate 1HUGE PAGE SIZE of memory\n");
+	printf("        argv[1] == \"pause\" 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");
 
@@ -97,8 +97,7 @@ int main(int argc, char *argv[])
 		exit(1);
 	}
 
-	switch (atoi(argv[1])) {
-	case 1:
+	if (!strcmp(argv[1], "alloc_1MB")) {
 		buf = malloc(MB);
 		if (!buf) {
 			fprintf(stderr, "Memory is not available\n");
@@ -112,8 +111,7 @@ int main(int argc, char *argv[])
 		raise(SIGSTOP);
 
 		free(buf);
-		break;
-	case 2:
+	} else if (!strcmp(argv[1], "alloc_1MB_shared")) {
 		fd = open(TEST_SFILE, O_RDWR | O_CREAT, 0666);
 		/* Writing 1MB of random data into this file [32 * 32768 = 1024 * 1024] */
 		for (i = 0; i < 32768; i++){
@@ -139,8 +137,7 @@ int main(int argc, char *argv[])
 		munmap(buf, sb.st_size);
 		close(fd);
 		remove(TEST_SFILE);
-		break;
-	case 3:
+	} else if (!strcmp(argv[1], "alloc_1huge_page")) {
 		hpsz = read_hugepagesize();
 		if (hpsz == 0)
 			exit(1);
@@ -159,11 +156,9 @@ int main(int argc, char *argv[])
 		raise(SIGSTOP);
 
 		munmap(buf, hpsz);
-		break;
-	case 4:
+	} else if (!strcmp(argv[1], "pause")) {
 		raise(SIGSTOP);
-		break;
-	default:
+	} else {
 		help();
 	}
 
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [LTP] [PATCH v3 3/3] ltp/numa: use string to describe operation
  2017-05-19  8:25 ` [LTP] [PATCH v3 3/3] ltp/numa: use string to describe operation Li Wang
@ 2017-05-19  8:32   ` Li Wang
  0 siblings, 0 replies; 9+ messages in thread
From: Li Wang @ 2017-05-19  8:32 UTC (permalink / raw)
  To: ltp

On Fri, May 19, 2017 at 4:25 PM, Li Wang <liwang@redhat.com> wrote:
> Signed-off-by: Li Wang <liwang@redhat.com>
> diff --git a/testcases/kernel/numa/support_numa.c b/testcases/kernel/numa/support_numa.c
> index 97f3008..fef8277 100644
> --- a/testcases/kernel/numa/support_numa.c
> +++ b/testcases/kernel/numa/support_numa.c
> @@ -50,10 +50,10 @@
>  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 allocate 1HUGE PAGE SIZE of memory\n");
> -       printf("        argv[1] == 4 then pause the program to catch sigint\n");
> +       printf("        argv[1] == "alloc_1MB" then allocate 1MB of memory\n");
> +       printf("        argv[1] == "alloc_1MB_shared" then allocate 1MB of share memory\n");
> +       printf("        argv[1] == "alloc_1huge_page" then allocate 1HUGE PAGE SIZE of memory\n");
> +       printf("        argv[1] == "pause" 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");
>
> @@ -97,8 +97,7 @@ int main(int argc, char *argv[])
>                 exit(1);
>         }

Oops, this one has little syntax error.

please apply the latest:

  [PATCH v3 3/3] ltp/numa: use string to describe operation





-- 
Regards,
Li Wang
Email: liwang@redhat.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [LTP] [PATCH v3 3/3] ltp/numa: use string to describe operation
  2017-05-19  8:27 Li Wang
@ 2017-05-19 12:23 ` Cyril Hrubis
  2017-05-22  3:54   ` Li Wang
  0 siblings, 1 reply; 9+ messages in thread
From: Cyril Hrubis @ 2017-05-19 12:23 UTC (permalink / raw)
  To: ltp

Hi!
I've tested and pushed the patchset, thanks.

And also found that memhog test fails on first iteration (when the
memhog binary is not in the page cache) because the test script runs too
fast and looks at the statistics even befor the memmhog binary has a
chance to run. The problem can be simulated for me by dropping caches by

echo 3 > /proc/sys/vm/drop_caches

then running the test.

I guess that the best solution would be to wait for the memhog to print
at least one dot before we start the actuall test. Unfortunatelly I
cannot think of any better solution than redirectiong the output to a
file and then checking the content in the script in a loop.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [LTP] [PATCH v3 3/3] ltp/numa: use string to describe operation
  2017-05-19 12:23 ` Cyril Hrubis
@ 2017-05-22  3:54   ` Li Wang
  2017-05-23 12:15     ` Cyril Hrubis
  0 siblings, 1 reply; 9+ messages in thread
From: Li Wang @ 2017-05-22  3:54 UTC (permalink / raw)
  To: ltp

On Fri, May 19, 2017 at 8:23 PM, Cyril Hrubis <chrubis@suse.cz> wrote:
> Hi!
> I've tested and pushed the patchset, thanks.
>
> And also found that memhog test fails on first iteration (when the
> memhog binary is not in the page cache) because the test script runs too
> fast and looks at the statistics even befor the memmhog binary has a
> chance to run. The problem can be simulated for me by dropping caches by
>
> echo 3 > /proc/sys/vm/drop_caches
>
> then running the test.
>
> I guess that the best solution would be to wait for the memhog to print
> at least one dot before we start the actuall test. Unfortunatelly I
> cannot think of any better solution than redirectiong the output to a
> file and then checking the content in the script in a loop.

Although I didn't hit this problem,  I believe the situation is easy
to reproduce. As you said above, something changes like:

$ git diff
diff --git a/testcases/kernel/numa/numa01.sh b/testcases/kernel/numa/numa01.sh
index 4eda3f1..e3fe854 100755
--- a/testcases/kernel/numa/numa01.sh
+++ b/testcases/kernel/numa/numa01.sh
@@ -315,9 +315,20 @@ test8()
        # Memory will be allocated using round robin on nodes.
        Exp_incr=$(echo "$MB / $total_nodes" |bc)

-       numactl --interleave=all memhog -r1000000 1MB 2>&1 >/dev/null &
+       numactl --interleave=all memhog -r1000000 1MB 2>&1 >ltp_numa_test8.log &
        pid=$!

+       local retries=20
+       while [ $retries -gt 0 ]; do
+
+               if grep -m1 -q '.' ltp_numa_test8.log; then
+                       break
+               fi
+
+               retries=$((retries-1))
+               tst_sleep 50ms
+       done
+
        for node in $nodes_list; do
                Mem_curr=$(echo "$(extract_numastat_p $pid $node) * $MB" |bc)



Comment?


-- 
Regards,
Li Wang
Email: liwang@redhat.com

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [LTP] [PATCH v3 3/3] ltp/numa: use string to describe operation
  2017-05-22  3:54   ` Li Wang
@ 2017-05-23 12:15     ` Cyril Hrubis
  2017-05-24  1:48       ` Li Wang
  0 siblings, 1 reply; 9+ messages in thread
From: Cyril Hrubis @ 2017-05-23 12:15 UTC (permalink / raw)
  To: ltp

Hi!
> $ git diff
> diff --git a/testcases/kernel/numa/numa01.sh b/testcases/kernel/numa/numa01.sh
> index 4eda3f1..e3fe854 100755
> --- a/testcases/kernel/numa/numa01.sh
> +++ b/testcases/kernel/numa/numa01.sh
> @@ -315,9 +315,20 @@ test8()
>         # Memory will be allocated using round robin on nodes.
>         Exp_incr=$(echo "$MB / $total_nodes" |bc)
> 
> -       numactl --interleave=all memhog -r1000000 1MB 2>&1 >/dev/null &
> +       numactl --interleave=all memhog -r1000000 1MB 2>&1 >ltp_numa_test8.log &
>         pid=$!
> 
> +       local retries=20
> +       while [ $retries -gt 0 ]; do
> +
> +               if grep -m1 -q '.' ltp_numa_test8.log; then
> +                       break
> +               fi
> +
> +               retries=$((retries-1))
> +               tst_sleep 50ms
> +       done
> +
>         for node in $nodes_list; do
>                 Mem_curr=$(echo "$(extract_numastat_p $pid $node) * $MB" |bc)

This fixes the problem for me, can you, pretty please, send a signed
patch?

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [LTP] [PATCH v3 3/3] ltp/numa: use string to describe operation
  2017-05-23 12:15     ` Cyril Hrubis
@ 2017-05-24  1:48       ` Li Wang
  0 siblings, 0 replies; 9+ messages in thread
From: Li Wang @ 2017-05-24  1:48 UTC (permalink / raw)
  To: ltp

On Tue, May 23, 2017 at 8:15 PM, Cyril Hrubis <chrubis@suse.cz> wrote:
> Hi!
>> $ git diff
>> diff --git a/testcases/kernel/numa/numa01.sh b/testcases/kernel/numa/numa01.sh
>> index 4eda3f1..e3fe854 100755
>> --- a/testcases/kernel/numa/numa01.sh
>> +++ b/testcases/kernel/numa/numa01.sh
>> @@ -315,9 +315,20 @@ test8()
>>         # Memory will be allocated using round robin on nodes.
>>         Exp_incr=$(echo "$MB / $total_nodes" |bc)
>>
>> -       numactl --interleave=all memhog -r1000000 1MB 2>&1 >/dev/null &
>> +       numactl --interleave=all memhog -r1000000 1MB 2>&1 >ltp_numa_test8.log &
>>         pid=$!
>>
>> +       local retries=20
>> +       while [ $retries -gt 0 ]; do
>> +
>> +               if grep -m1 -q '.' ltp_numa_test8.log; then
>> +                       break
>> +               fi
>> +
>> +               retries=$((retries-1))
>> +               tst_sleep 50ms
>> +       done
>> +
>>         for node in $nodes_list; do
>>                 Mem_curr=$(echo "$(extract_numastat_p $pid $node) * $MB" |bc)
>
> This fixes the problem for me, can you, pretty please, send a signed
> patch?

Sure, my pleasure.


-- 
Regards,
Li Wang
Email: liwang@redhat.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-05-24  1:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-19  8:25 [LTP] [PATCH v3 1/3] ltp/numa: add new test11 Li Wang
2017-05-19  8:25 ` [LTP] [PATCH v3 2/3] ltp/numa: Kill the support_numa if FAILED Li Wang
2017-05-19  8:25 ` [LTP] [PATCH v3 3/3] ltp/numa: use string to describe operation Li Wang
2017-05-19  8:32   ` Li Wang
  -- strict thread matches above, loose matches on Subject: below --
2017-05-19  8:27 Li Wang
2017-05-19 12:23 ` Cyril Hrubis
2017-05-22  3:54   ` Li Wang
2017-05-23 12:15     ` Cyril Hrubis
2017-05-24  1:48       ` Li Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox