public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v2] ltp/numa: add new test11
@ 2017-02-06  8:50 Li Wang
  2017-03-01  8:28 ` Li Wang
  2017-03-02 15:14 ` Cyril Hrubis
  0 siblings, 2 replies; 4+ messages in thread
From: Li Wang @ 2017-02-06  8:50 UTC (permalink / raw)
  To: ltp

Signed-off-by: Li Wang <liwang@redhat.com>
---

Notes:
    V1 --> V2
    
    * tst_brk --> tst_res, we just hope the testcase11 skip but exit
    * allocate '$Ori_hpgs + 1' hugepages then check if allocation success
    * simplify arithmetic operation
    * make sure 'hpsz != 0' before mmap() funciton in main()
    * fprintf() --> perror()
    * coding style correction

 testcases/kernel/numa/README         |  2 ++
 testcases/kernel/numa/numa01.sh      | 48 ++++++++++++++++++++++++++++++--
 testcases/kernel/numa/support_numa.c | 53 ++++++++++++++++++++++++++++++++++--
 3 files changed, 98 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..5793bf9 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=$(cat /proc/meminfo  |grep "Hugepagesize:" |awk '{print $2}')
 
 	# 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,45 @@ test10()
 	tst_res TPASS "NUMA MIGRATEPAGES policy"
 }
 
+# Verification of hugepage memory allocated on a node
+test11()
+{
+	Mem_huge=0
+
+	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/devices/system/node/node${node}/hugepages/hugepages-${HPAGE_SIZE}kB/nr_hugepages)
+		New_hpgs=$((Ori_hpgs + 1))
+		echo $New_hpgs >/sys/devices/system/node/node${node}/hugepages/hugepages-${HPAGE_SIZE}kB/nr_hugepages
+
+		Chk_hpgs=$(cat /sys/devices/system/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 |grep '^Huge' |awk '{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"
+			return
+		fi
+
+		kill -CONT $pid >/dev/null 2>&1
+		echo $Ori_hpgs >/sys/devices/system/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:
-- 
1.8.3.1


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

* [LTP] [PATCH v2] ltp/numa: add new test11
  2017-02-06  8:50 [LTP] [PATCH v2] ltp/numa: add new test11 Li Wang
@ 2017-03-01  8:28 ` Li Wang
  2017-03-02 15:14 ` Cyril Hrubis
  1 sibling, 0 replies; 4+ messages in thread
From: Li Wang @ 2017-03-01  8:28 UTC (permalink / raw)
  To: ltp

ping

On Mon, Feb 6, 2017 at 4:50 PM, Li Wang <liwang@redhat.com> wrote:
> Signed-off-by: Li Wang <liwang@redhat.com>
> ---
>
> Notes:
>     V1 --> V2
>
>     * tst_brk --> tst_res, we just hope the testcase11 skip but exit
>     * allocate '$Ori_hpgs + 1' hugepages then check if allocation success
>     * simplify arithmetic operation
>     * make sure 'hpsz != 0' before mmap() funciton in main()
>     * fprintf() --> perror()
>     * coding style correction
>
>  testcases/kernel/numa/README         |  2 ++
>  testcases/kernel/numa/numa01.sh      | 48 ++++++++++++++++++++++++++++++--
>  testcases/kernel/numa/support_numa.c | 53 ++++++++++++++++++++++++++++++++++--
>  3 files changed, 98 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..5793bf9 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=$(cat /proc/meminfo  |grep "Hugepagesize:" |awk '{print $2}')
>
>         # 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,45 @@ test10()
>         tst_res TPASS "NUMA MIGRATEPAGES policy"
>  }
>
> +# Verification of hugepage memory allocated on a node
> +test11()
> +{
> +       Mem_huge=0
> +
> +       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/devices/system/node/node${node}/hugepages/hugepages-${HPAGE_SIZE}kB/nr_hugepages)
> +               New_hpgs=$((Ori_hpgs + 1))
> +               echo $New_hpgs >/sys/devices/system/node/node${node}/hugepages/hugepages-${HPAGE_SIZE}kB/nr_hugepages
> +
> +               Chk_hpgs=$(cat /sys/devices/system/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 |grep '^Huge' |awk '{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"
> +                       return
> +               fi
> +
> +               kill -CONT $pid >/dev/null 2>&1
> +               echo $Ori_hpgs >/sys/devices/system/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:
> --
> 1.8.3.1
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp



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

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

* [LTP] [PATCH v2] ltp/numa: add new test11
  2017-02-06  8:50 [LTP] [PATCH v2] ltp/numa: add new test11 Li Wang
  2017-03-01  8:28 ` Li Wang
@ 2017-03-02 15:14 ` Cyril Hrubis
  2017-03-03  3:22   ` Li Wang
  1 sibling, 1 reply; 4+ messages in thread
From: Cyril Hrubis @ 2017-03-02 15:14 UTC (permalink / raw)
  To: ltp

>  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=$(cat /proc/meminfo  |grep "Hugepagesize:" |awk '{print $2}')

awk '/Hugepagesize:/ {print $2}' /proc/meminfo

And we should fix the rest of the awk statements in the script as well
(in a separate patch).

>  	# 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,45 @@ test10()
>  	tst_res TPASS "NUMA MIGRATEPAGES policy"
>  }
>  
> +# Verification of hugepage memory allocated on a node
> +test11()
> +{
> +	Mem_huge=0
> +
> +	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/devices/system/node/node${node}/hugepages/hugepages-${HPAGE_SIZE}kB/nr_hugepages)
> +		New_hpgs=$((Ori_hpgs + 1))
> +		echo $New_hpgs >/sys/devices/system/node/node${node}/hugepages/hugepages-${HPAGE_SIZE}kB/nr_hugepages
> +
> +		Chk_hpgs=$(cat /sys/devices/system/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 |grep '^Huge' |awk '{print $'$((node+2))'}'))

Here as well, no need to use grep.

> +		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"

We should restore the /sys/ file and kill the support_numa process here
as well.

> +			return
> +		fi
> +
> +		kill -CONT $pid >/dev/null 2>&1
> +		echo $Ori_hpgs >/sys/devices/system/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:
> -- 
> 1.8.3.1
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH v2] ltp/numa: add new test11
  2017-03-02 15:14 ` Cyril Hrubis
@ 2017-03-03  3:22   ` Li Wang
  0 siblings, 0 replies; 4+ messages in thread
From: Li Wang @ 2017-03-03  3:22 UTC (permalink / raw)
  To: ltp

On Thu, Mar 2, 2017 at 11:14 PM, Cyril Hrubis <chrubis@suse.cz> wrote:
>>  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=$(cat /proc/meminfo  |grep "Hugepagesize:" |awk '{print $2}')
>
> awk '/Hugepagesize:/ {print $2}' /proc/meminfo
>
> And we should fix the rest of the awk statements in the script as well
> (in a separate patch).

Sure.

>
>>       # 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,45 @@ test10()
>>       tst_res TPASS "NUMA MIGRATEPAGES policy"
>>  }
>>
>> +# Verification of hugepage memory allocated on a node
>> +test11()
>> +{
>> +     Mem_huge=0
>> +
>> +     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/devices/system/node/node${node}/hugepages/hugepages-${HPAGE_SIZE}kB/nr_hugepages)
>> +             New_hpgs=$((Ori_hpgs + 1))
>> +             echo $New_hpgs >/sys/devices/system/node/node${node}/hugepages/hugepages-${HPAGE_SIZE}kB/nr_hugepages
>> +
>> +             Chk_hpgs=$(cat /sys/devices/system/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 |grep '^Huge' |awk '{print $'$((node+2))'}'))
>
> Here as well, no need to use grep.

Sure.

>
>> +             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"
>
> We should restore the /sys/ file and kill the support_numa process here
> as well.

Good point. The remains of testcase have not do that too, let me add
all of that in a new patch.

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

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

end of thread, other threads:[~2017-03-03  3:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-06  8:50 [LTP] [PATCH v2] ltp/numa: add new test11 Li Wang
2017-03-01  8:28 ` Li Wang
2017-03-02 15:14 ` Cyril Hrubis
2017-03-03  3:22   ` Li Wang

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