public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* Re: [LTP] [PATCH 1/5] A library used to mount hugetlbfs automatically.
       [not found] ` <1322044169-30851-2-git-send-email-gaowanlong@cn.fujitsu.com>
@ 2011-12-28  5:21   ` Caspar Zhang
  2011-12-28  6:02     ` [LTP] [PATCH v2 " Wanlong Gao
  0 siblings, 1 reply; 8+ messages in thread
From: Caspar Zhang @ 2011-12-28  5:21 UTC (permalink / raw)
  To: Wanlong Gao; +Cc: ltp-list

On 11/23/2011 06:29 PM, Wanlong Gao wrote:
> This library includes a set of functions used to mount hugetlbfs automatically when doing the hugemmap tests.
> 
> Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
> Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
> ---
>  testcases/kernel/mem/hugetlb/hugemmap/Makefile |    6 ++-
>  testcases/kernel/mem/hugetlb/hugemmap/libmnt.c |   58 ++++++++++++++++++++++++
>  testcases/kernel/mem/hugetlb/hugemmap/libmnt.h |   25 ++++++++++
>  3 files changed, 88 insertions(+), 1 deletions(-)
>  create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/libmnt.c
>  create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/libmnt.h
> 
> diff --git a/testcases/kernel/mem/hugetlb/hugemmap/Makefile b/testcases/kernel/mem/hugetlb/hugemmap/Makefile
> index a1ba46e..e6ba4fe 100644
> --- a/testcases/kernel/mem/hugetlb/hugemmap/Makefile
> +++ b/testcases/kernel/mem/hugetlb/hugemmap/Makefile
> @@ -23,5 +23,9 @@
>  top_srcdir              ?= ../../../../..
>  
>  include $(top_srcdir)/include/mk/testcases.mk
> -include $(abs_srcdir)/../Makefile.inc
> +
> +MAKE_TARGETS	:= $(filter-out libmnt,$(patsubst $(abs_srcdir)/%.c,%,$(wildcard $(abs_srcdir)/*.c)))
> +
> +$(MAKE_TARGETS): %: %.o libmnt.o
> +
>  include $(top_srcdir)/include/mk/generic_leaf_target.mk
> diff --git a/testcases/kernel/mem/hugetlb/hugemmap/libmnt.c b/testcases/kernel/mem/hugetlb/hugemmap/libmnt.c
> new file mode 100644
> index 0000000..bf6f857
> --- /dev/null
> +++ b/testcases/kernel/mem/hugetlb/hugemmap/libmnt.c
> @@ -0,0 +1,58 @@
> +/*
> + *
> + *   Copyright (c) Fujitsu Corp., 2011
> + *
> + *   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.
> + *
> + *   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.
> + *
> + *   You should have received a copy of the GNU General Public License
> + *   along with this program;  if not, write to the Free Software
> + *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> + */
> +
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <sys/mount.h>
> +#include <errno.h>
> +
> +#include "test.h"
> +#include "libmnt.h"
> +
> +void
> +hugepage_alloc(int num)

It's not necessary to put it into 2 lines.

> +{
> +	FILE *file = fopen("/proc/sys/vm/nr_hugepages", "w+");
> +	if (file == NULL) {
> +		tst_brkm(TBROK|TERRNO, NULL,
> +			"fopen failed on /proc/sys/vm/nr_hugepages");
> +	}
> +
> +	if (fprintf(file, "%d", num) < 0) {
> +		tst_brkm(TBROK|TERRNO, NULL,
> +			"fprintf failed on /proc/sys/vm/nr_hugepages");
> +	}
> +
> +	fclose(file);
> +}
> +
> +void
> +mount_hugetlbfs(char *mount_point)
> +{
> +	if (mount("none", mount_point, "hugetlbfs", 0, NULL) < 0) {
> +		tst_brkm(TBROK|TERRNO, NULL,
> +			"mount failed on %s", mount_point);
> +	}
> +}
> +
> +void
> +umount_hugetlbfs(char *mount_point)
> +{
> +	umount(mount_point);

You should check the return code and errno for it.

> +}
> diff --git a/testcases/kernel/mem/hugetlb/hugemmap/libmnt.h b/testcases/kernel/mem/hugetlb/hugemmap/libmnt.h
> new file mode 100644
> index 0000000..dc1ceed
> --- /dev/null
> +++ b/testcases/kernel/mem/hugetlb/hugemmap/libmnt.h
> @@ -0,0 +1,25 @@
> +/*
> + *   Copyright (c) Fujitsu  Corp., 2011
> + *
> + *   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.
> + *
> + *   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.
> + *
> + *   You should have received a copy of the GNU General Public License
> + *   along with this program;  if not, write to the Free Software
> + *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> + */
> +
> +/*
> + *   libmnt.h - functions to mount hugetlbfs automatically.
> + */
> +
> +void hugepage_alloc(int num);
> +void mount_hugetlbfs(char *mount_point);
> +void umount_hugetlbfs(char *mount_point);


------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 2/5] hugemmap01.c : automatically mount hugetlbfs.
       [not found] ` <1322044169-30851-3-git-send-email-gaowanlong@cn.fujitsu.com>
@ 2011-12-28  5:22   ` Caspar Zhang
  2011-12-28  6:23     ` Wanlong Gao
  0 siblings, 1 reply; 8+ messages in thread
From: Caspar Zhang @ 2011-12-28  5:22 UTC (permalink / raw)
  To: Wanlong Gao; +Cc: ltp-list

Hi,

On 11/23/2011 06:29 PM, Wanlong Gao wrote:
> Firstly, mounting hugetlbfs on /tmp is not a good idea, because lots of
> programs could use /tmp for other purpose. This could cause other tests
> fail.
> Secondly, mounting hugetlbfs could be done automatically.
> This patch creates a temp directory with name including the current PID,
> automatically mounts hugetlbfs on the directory before test starts, and
> umounts it when the test is over.
> 
> Signed-off-by: tangchen <tangchen@cn.fujitsu.com>
> Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
> ---
>  testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c |   50 +++++++-------------
>  1 files changed, 18 insertions(+), 32 deletions(-)
> 
> diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c
> index 874f736..906f7e4 100644
> --- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c
> +++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c
> @@ -73,51 +73,35 @@
>  #include "test.h"
>  #include "usctest.h"
>  #include "system_specific_hugepages_info.h"
> +#include "libmnt.h"
>  
>  #define BUFFER_SIZE  256
>  
> -char* TEMPFILE="mmapfile";
> +char TEMPFILE[MAXPATHLEN];
>  
>  char *TCID="hugemmap01";	/* Test program identifier.    */
>  int TST_TOTAL=1;		/* Total number of test cases. */
>  long *addr;			/* addr of memory mapped region */
>  int fildes;			/* file descriptor for tempfile */
> -char *Hopt;                     /* location of hugetlbfs */
>  int beforetest=0;		/* Amount of free huge pages before testing */
>  int aftertest=0;		/* Amount of free huge pages after testing */
>  int hugepagesmapped=0;		/* Amount of huge pages mapped after testing */
> +char *mount_point=NULL;
>  
> -void setup();			/* Main setup function of test */
> -void cleanup();			/* cleanup function for the test */
> -
> -void help()
> -{
> -	printf("  -H /..  Location of hugetlbfs, i.e. -H /var/hugetlbfs \n");
> -}
> +void setup(void);			/* Main setup function of test */
> +void cleanup(void);			/* cleanup function for the test */
>  
>  int
>  main(int ac, char **av)
>  {
>  	int lc;			/* loop counter */
>  	char *msg;		/* message returned from parse_opts */
> -        int Hflag=0;              /* binary flag: opt or not */
>  	int page_sz=0;
>  
> -       	option_t options[] = {
> -        	{ "H:",   &Hflag, &Hopt },    /* Required for location of hugetlbfs */
> -            	{ NULL, NULL, NULL }          /* NULL required to end array */
> -       	};

Hi, I think it's better to keep this option, since not all users would
like the default mount place.

> -
>  	/* Parse standard options given to run the test. */
> -	msg = parse_opts(ac, av, options, &help);
> -	if (msg != (char *) NULL) {
> +	msg = parse_opts(ac, av, NULL, NULL);
> +	if (msg != NULL) {
>  		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s, use -help", msg);
> -		tst_exit();
> -	}
> -
> -	if (Hflag == 0) {
> -		tst_brkm(TBROK, NULL, "-H option is REQUIRED for this test, use -h for options help");
> -		tst_exit();
>  	}
>  
>  	setup();
> @@ -189,18 +173,19 @@ main(int ac, char **av)
>   * 	     Write some known data into file and get the size of the file.
>   */
>  void
> -setup()
> +setup(void)
>  {
> -	char mypid[40];
> -
> -	sprintf(mypid,"/%d",getpid());
> -	TEMPFILE=strcat(mypid,TEMPFILE);
> -	TEMPFILE=strcat(Hopt,TEMPFILE);
> -
> +	tst_require_root(NULL);
>  	tst_sig(FORK, DEF_HANDLER, cleanup);
>  
>  	TEST_PAUSE;
>  
> +	tst_tmpdir();
> +	mount_point = get_tst_tmpdir();
> +	mount_hugetlbfs(mount_point);
> +	hugepage_alloc(1024);

hard-coded hugepage size is not recommended. You should either set it
dynamically or allow user pass a parameter via argv.

> +	snprintf(TEMPFILE, sizeof(TEMPFILE), "%s/mmapfile%d",
> +		mount_point, getpid());
>  }
>  
>  /*
> @@ -209,7 +194,7 @@ setup()
>   * 	       Remove the temporary directory created.
>   */
>  void
> -cleanup()
> +cleanup(void)
>  {
>  	/*
>  	 * print timing stats if that option was specified.
> @@ -217,5 +202,6 @@ cleanup()
>  	TEST_CLEANUP;
>  
>  	unlink(TEMPFILE);
> -
> +	umount_hugetlbfs(mount_point);
> +	tst_rmdir();
>  }


------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH v2 1/5] A library used to mount hugetlbfs automatically
  2011-12-28  5:21   ` [LTP] [PATCH 1/5] A library used to mount hugetlbfs automatically Caspar Zhang
@ 2011-12-28  6:02     ` Wanlong Gao
  2011-12-28  6:55       ` Caspar Zhang
  0 siblings, 1 reply; 8+ messages in thread
From: Wanlong Gao @ 2011-12-28  6:02 UTC (permalink / raw)
  To: caspar; +Cc: ltp-list

This library includes a set of functions used to mount hugetlbfs automatically when doing the hugemmap tests.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
---
 testcases/kernel/mem/hugetlb/hugemmap/Makefile |    6 ++-
 testcases/kernel/mem/hugetlb/hugemmap/libmnt.c |   58 ++++++++++++++++++++++++
 2 files changed, 63 insertions(+), 1 deletions(-)
 create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/libmnt.c

diff --git a/testcases/kernel/mem/hugetlb/hugemmap/Makefile b/testcases/kernel/mem/hugetlb/hugemmap/Makefile
index a1ba46e..e6ba4fe 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/Makefile
+++ b/testcases/kernel/mem/hugetlb/hugemmap/Makefile
@@ -23,5 +23,9 @@
 top_srcdir              ?= ../../../../..
 
 include $(top_srcdir)/include/mk/testcases.mk
-include $(abs_srcdir)/../Makefile.inc
+
+MAKE_TARGETS	:= $(filter-out libmnt,$(patsubst $(abs_srcdir)/%.c,%,$(wildcard $(abs_srcdir)/*.c)))
+
+$(MAKE_TARGETS): %: %.o libmnt.o
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/mem/hugetlb/hugemmap/libmnt.c b/testcases/kernel/mem/hugetlb/hugemmap/libmnt.c
new file mode 100644
index 0000000..36e2700
--- /dev/null
+++ b/testcases/kernel/mem/hugetlb/hugemmap/libmnt.c
@@ -0,0 +1,58 @@
+/*
+ *
+ *   Copyright (c) Fujitsu Corp., 2011
+ *
+ *   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.
+ *
+ *   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.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program;  if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/mount.h>
+#include <errno.h>
+
+#include "test.h"
+#include "libmnt.h"
+
+void hugepage_alloc(int num)
+{
+	FILE *file = fopen("/proc/sys/vm/nr_hugepages", "w+");
+	if (file == NULL) {
+		tst_brkm(TBROK|TERRNO, NULL,
+			 "fopen failed on /proc/sys/vm/nr_hugepages");
+	}
+
+	if (fprintf(file, "%d", num) < 0) {
+		tst_brkm(TBROK|TERRNO, NULL,
+			 "fprintf failed on /proc/sys/vm/nr_hugepages");
+	}
+
+	fclose(file);
+}
+
+void mount_hugetlbfs(char *mount_point)
+{
+	if (mount("none", mount_point, "hugetlbfs", 0, NULL) < 0) {
+		tst_brkm(TBROK|TERRNO, NULL,
+			 "mount failed on %s", mount_point);
+	}
+}
+
+void umount_hugetlbfs(char *mount_point)
+{
+	if (umount(mount_point)) {
+		tst_brkm(TBROK|TERRNO, NULL,
+			 "umount faild on %s", mount_point);
+	}
+}
-- 
1.7.8


------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 2/5] hugemmap01.c : automatically mount hugetlbfs.
  2011-12-28  5:22   ` [LTP] [PATCH 2/5] hugemmap01.c : automatically mount hugetlbfs Caspar Zhang
@ 2011-12-28  6:23     ` Wanlong Gao
  2011-12-28  6:43       ` Caspar Zhang
  0 siblings, 1 reply; 8+ messages in thread
From: Wanlong Gao @ 2011-12-28  6:23 UTC (permalink / raw)
  To: Caspar Zhang; +Cc: ltp-list

Hi Casper:

> 
> Hi, I think it's better to keep this option, since not all users would
> like the default mount place.


-H option is not needed, users can set TDIRECTORY env to change the dir if
he don't like the default one, also, remove the -H option can be consistent with
others.


>> +	tst_tmpdir();
>> +	mount_point = get_tst_tmpdir();
>> +	mount_hugetlbfs(mount_point);
>> +	hugepage_alloc(1024);


sure, will change to a macro.


Thanks a lot
-Wanlong Gao

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* [LTP] [PATCH 7/5] hugemmap: change hard-coded page alloc size to a macro
       [not found] <1322044169-30851-1-git-send-email-gaowanlong@cn.fujitsu.com>
       [not found] ` <1322044169-30851-2-git-send-email-gaowanlong@cn.fujitsu.com>
       [not found] ` <1322044169-30851-3-git-send-email-gaowanlong@cn.fujitsu.com>
@ 2011-12-28  6:40 ` Wanlong Gao
       [not found] ` <4EF308EF.9010604@cn.fujitsu.com>
  3 siblings, 0 replies; 8+ messages in thread
From: Wanlong Gao @ 2011-12-28  6:40 UTC (permalink / raw)
  To: caspar; +Cc: ltp-list

change the hard-coded alloc size to a macro, because hard-coded is
not a good idea.

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
---
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c |    3 ++-
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c |    3 ++-
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap03.c |    3 ++-
 testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c |    3 ++-
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c
index 906f7e4..ca68fb5 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c
+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c
@@ -76,6 +76,7 @@
 #include "libmnt.h"
 
 #define BUFFER_SIZE  256
+#define PAGE_ALLOC_SIZE	1024
 
 char TEMPFILE[MAXPATHLEN];
 
@@ -183,7 +184,7 @@ setup(void)
 	tst_tmpdir();
 	mount_point = get_tst_tmpdir();
 	mount_hugetlbfs(mount_point);
-	hugepage_alloc(1024);
+	hugepage_alloc(PAGE_ALLOC_SIZE);
 	snprintf(TEMPFILE, sizeof(TEMPFILE), "%s/mmapfile%d",
 		mount_point, getpid());
 }
diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c
index 3bbbc46..349e564 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c
+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c
@@ -67,6 +67,7 @@
 
 #define LOW_ADDR       (void *)(0x80000000)
 #define LOW_ADDR2      (void *)(0x90000000)
+#define PAGE_ALLOC_SIZE	1024
 
 char TEMPFILE[MAXPATHLEN];
 
@@ -197,7 +198,7 @@ setup(void)
 	mount_point = get_tst_tmpdir();
 
 	mount_hugetlbfs(mount_point);
-	hugepage_alloc(1024);
+	hugepage_alloc(PAGE_ALLOC_SIZE);
 
 	snprintf(TEMPFILE, sizeof(TEMPFILE), "%s/mmapfile%d", mount_point, getpid());
 }
diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap03.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap03.c
index b17b19d..866ca57 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap03.c
+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap03.c
@@ -57,6 +57,7 @@
 #include "libmnt.h"
 
 #define HIGH_ADDR      (void *)(0x1000000000000)
+#define PAGE_ALLOC_SIZE	1024
 
 char TEMPFILE[MAXPATHLEN];
 
@@ -143,7 +144,7 @@ setup(void)
 	mount_point = get_tst_tmpdir();
 
 	mount_hugetlbfs(mount_point);
-	hugepage_alloc(1024);
+	hugepage_alloc(PAGE_ALLOC_SIZE);
 
 	snprintf(TEMPFILE, sizeof(TEMPFILE), "%s/mmapfile%d", mount_point, getpid());
 }
diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c
index 9774e87..2eea936 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c
+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c
@@ -76,6 +76,7 @@
 #include "libmnt.h"
 
 #define BUFFER_SIZE  256
+#define PAGE_ALLOC_SIZE	1024
 
 char TEMPFILE[MAXPATHLEN];
 
@@ -192,7 +193,7 @@ setup()
 	mount_point = get_tst_tmpdir();
 
 	mount_hugetlbfs(mount_point);
-	hugepage_alloc(1024);
+	hugepage_alloc(PAGE_ALLOC_SIZE);
 
 	snprintf(TEMPFILE, sizeof(TEMPFILE), "%s/mmapfile%d", mount_point, getpid());
 }
-- 
1.7.8


------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 2/5] hugemmap01.c : automatically mount hugetlbfs.
  2011-12-28  6:23     ` Wanlong Gao
@ 2011-12-28  6:43       ` Caspar Zhang
  0 siblings, 0 replies; 8+ messages in thread
From: Caspar Zhang @ 2011-12-28  6:43 UTC (permalink / raw)
  To: gaowanlong; +Cc: ltp-list

On 12/28/2011 02:23 PM, Wanlong Gao wrote:
>>> >> +	tst_tmpdir();
>>> >> +	mount_point = get_tst_tmpdir();
>>> >> +	mount_hugetlbfs(mount_point);
>>> >> +	hugepage_alloc(1024);
> 
> sure, will change to a macro.

I don't think a macro can improve much. You patch reduces the testcase
scalability. A better way is passing hugepage size you want to set via
option:

./hugemmap01 -s 1024

The default value 1024 is not good enough, for x86 systems, it will
require at least 2GB free memory, for other systems, like powerpc, it
will require 16GB free memory. It would be better if you calculate how
much memory the system can be used for hugepages.

One more thing (on libmnt.c side), is there any action if hugepage_alloc
set 0, and is there any action if you want to set 1024 hpages, but only
allocated less amount than that?

Thanks,
Caspar

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH v2 1/5] A library used to mount hugetlbfs automatically
  2011-12-28  6:02     ` [LTP] [PATCH v2 " Wanlong Gao
@ 2011-12-28  6:55       ` Caspar Zhang
  0 siblings, 0 replies; 8+ messages in thread
From: Caspar Zhang @ 2011-12-28  6:55 UTC (permalink / raw)
  To: Wanlong Gao; +Cc: ltp-list

On 12/28/2011 02:02 PM, Wanlong Gao wrote:
> This library includes a set of functions used to mount hugetlbfs automatically when doing the hugemmap tests.
> 
> Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
> ---
>  testcases/kernel/mem/hugetlb/hugemmap/Makefile |    6 ++-
>  testcases/kernel/mem/hugetlb/hugemmap/libmnt.c |   58 ++++++++++++++++++++++++
>  2 files changed, 63 insertions(+), 1 deletions(-)
>  create mode 100644 testcases/kernel/mem/hugetlb/hugemmap/libmnt.c
> 
> diff --git a/testcases/kernel/mem/hugetlb/hugemmap/Makefile b/testcases/kernel/mem/hugetlb/hugemmap/Makefile
> index a1ba46e..e6ba4fe 100644
> --- a/testcases/kernel/mem/hugetlb/hugemmap/Makefile
> +++ b/testcases/kernel/mem/hugetlb/hugemmap/Makefile
> @@ -23,5 +23,9 @@
>  top_srcdir              ?= ../../../../..
>  
>  include $(top_srcdir)/include/mk/testcases.mk
> -include $(abs_srcdir)/../Makefile.inc
> +
> +MAKE_TARGETS	:= $(filter-out libmnt,$(patsubst $(abs_srcdir)/%.c,%,$(wildcard $(abs_srcdir)/*.c)))
> +
> +$(MAKE_TARGETS): %: %.o libmnt.o
> +
>  include $(top_srcdir)/include/mk/generic_leaf_target.mk
> diff --git a/testcases/kernel/mem/hugetlb/hugemmap/libmnt.c b/testcases/kernel/mem/hugetlb/hugemmap/libmnt.c
> new file mode 100644
> index 0000000..36e2700
> --- /dev/null
> +++ b/testcases/kernel/mem/hugetlb/hugemmap/libmnt.c
> @@ -0,0 +1,58 @@
> +/*
> + *
> + *   Copyright (c) Fujitsu Corp., 2011
> + *
> + *   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.
> + *
> + *   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.
> + *
> + *   You should have received a copy of the GNU General Public License
> + *   along with this program;  if not, write to the Free Software
> + *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> + */
> +
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <sys/mount.h>
> +#include <errno.h>
> +
> +#include "test.h"
> +#include "libmnt.h"
> +
> +void hugepage_alloc(int num)
> +{
> +	FILE *file = fopen("/proc/sys/vm/nr_hugepages", "w+");
> +	if (file == NULL) {
> +		tst_brkm(TBROK|TERRNO, NULL,
> +			 "fopen failed on /proc/sys/vm/nr_hugepages");
> +	}
> +
> +	if (fprintf(file, "%d", num) < 0) {
> +		tst_brkm(TBROK|TERRNO, NULL,
> +			 "fprintf failed on /proc/sys/vm/nr_hugepages");
> +	}
> +
> +	fclose(file);
> +}

Besides the questions I mentions in previous mail, you may also want to
use new functions I committed to mem/lib just now:

    void set_sys_tune(char *sys_file, long tune, int check);
    long get_sys_tune(char *sys_file);

Thanks,
Caspar

> +
> +void mount_hugetlbfs(char *mount_point)
> +{
> +	if (mount("none", mount_point, "hugetlbfs", 0, NULL) < 0) {
> +		tst_brkm(TBROK|TERRNO, NULL,
> +			 "mount failed on %s", mount_point);
> +	}
> +}
> +
> +void umount_hugetlbfs(char *mount_point)
> +{
> +	if (umount(mount_point)) {
> +		tst_brkm(TBROK|TERRNO, NULL,
> +			 "umount faild on %s", mount_point);
> +	}
> +}


------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH 0/5] Automatically mount hugetlbfs for hugemmap tests.
       [not found]   ` <4EF9169B.2000106@cn.fujitsu.com>
@ 2012-01-20 14:40     ` Cyril Hrubis
  0 siblings, 0 replies; 8+ messages in thread
From: Cyril Hrubis @ 2012-01-20 14:40 UTC (permalink / raw)
  To: Wanlong Gao; +Cc: ltp-list

Hi!
> > Hi Cyril:
> > 
> > Can you please commit this patch set?
> > 

Hmm, I'm a little confused (sorry my mailbox is full of patches), that
is just another patchset for the hugemmap testcases. Which one is the
latest one?

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2012-01-20 14:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1322044169-30851-1-git-send-email-gaowanlong@cn.fujitsu.com>
     [not found] ` <1322044169-30851-2-git-send-email-gaowanlong@cn.fujitsu.com>
2011-12-28  5:21   ` [LTP] [PATCH 1/5] A library used to mount hugetlbfs automatically Caspar Zhang
2011-12-28  6:02     ` [LTP] [PATCH v2 " Wanlong Gao
2011-12-28  6:55       ` Caspar Zhang
     [not found] ` <1322044169-30851-3-git-send-email-gaowanlong@cn.fujitsu.com>
2011-12-28  5:22   ` [LTP] [PATCH 2/5] hugemmap01.c : automatically mount hugetlbfs Caspar Zhang
2011-12-28  6:23     ` Wanlong Gao
2011-12-28  6:43       ` Caspar Zhang
2011-12-28  6:40 ` [LTP] [PATCH 7/5] hugemmap: change hard-coded page alloc size to a macro Wanlong Gao
     [not found] ` <4EF308EF.9010604@cn.fujitsu.com>
     [not found]   ` <4EF9169B.2000106@cn.fujitsu.com>
2012-01-20 14:40     ` [LTP] [PATCH 0/5] Automatically mount hugetlbfs for hugemmap tests Cyril Hrubis

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