[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ltp-list
Subject:    Re: [LTP] [PATCH] hugemmap01.c: Automatically mount hugetlbfs on
From:       tangchen <tangchen () cn ! fujitsu ! com>
Date:       2011-03-24 10:18:28
Message-ID: 4D8B1A74.6030100 () cn ! fujitsu ! com
[Download RAW message or body]

Please ingore this patch! I will resend a new one later! Thanks.

On 03/24/2011 04:34 PM, tangchen wrote:
> Hi,
> 
> hugemmap test could fail because I didn't mount hugetlbfs by myself. And
> I need to unmount it after test.
> 
> In my opinion,
> 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 directory /huge, and automatically mounts hugetlbfs
> on /huge, and echo a large enough to /proc/sys/vm/nr_hugepages before
> test starts. Finally, when the test is over, hugetlbfs is unmounted and
> /huge is removed automatically.
> 
> Signed-off-by: tangchen<tangchen@cn.fujitsu.com>
> ---
> runtest/hugetlb                                    |    2 +-
> testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c |   28
> ++++++++++++++++++-
> 2 files changed, 27 insertions(+), 3 deletions(-)
> 
> diff --git a/runtest/hugetlb b/runtest/hugetlb
> index 1347f32..1490bda 100644
> --- a/runtest/hugetlb
> +++ b/runtest/hugetlb
> @@ -1,4 +1,4 @@
> -hugemmap01 hugemmap01 -H/tmp
> +hugemmap01 hugemmap01 -H/huge
> hugemmap02 hugemmap02 -H/tmp -c10
> hugemmap03 hugemmap03 -H/tmp -I2 -c10
> hugemmap04 hugemmap04 -H/tmp
> diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c
> b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c
> index a9b8a36..569ee0c 100644
> --- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c
> +++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c
> @@ -69,6 +69,7 @@
> #include<sys/stat.h>
> #include<sys/mman.h>
> #include<sys/types.h>
> +#include<sys/mount.h>
> 
> #include "test.h"
> #include "usctest.h"
> @@ -85,6 +86,8 @@ 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 */
> +FILE *nr_hugepages_file = NULL; /* Used for allocate enough hugepages
> for test. */
> +char *mount_point = NULL;    /* The location where we mount hugetlbfs. */
> 
> void setup();            /* Main setup function of test */
> int getfreehugepages();        /* Reads free huge pages */
> @@ -121,6 +124,7 @@ main(int ac, char **av)
> tst_exit();
> }
> 
> +    mount_point = (char *)malloc(sizeof(char) * 50);
> setup();
> 
> for (lc = 0; TEST_LOOPING(lc); lc++) {
> @@ -195,6 +199,25 @@ setup()
> {
> char mypid[40];
> 
> +    mount_point = strcpy(mount_point, Hopt);
> +
> +    if (mkdir(mount_point, 0755)<  0) {
> +        tst_brkm(TBROK, NULL, "Cannot create directory %s!", mount_point);
> +    }
> +
> +    if (mount("none", mount_point, "hugetlbfs", 0, NULL)<  0) {
> +        tst_brkm(TBROK, NULL, "Cannot mount hugetlbfs on %s!",
> mount_point);
> +    }
> +
> +    nr_hugepages_file = fopen("/proc/sys/vm/nr_hugepages", "w+");
> +    if (nr_hugepages_file == NULL) {
> +        tst_brkm(TBROK, NULL, "Cannot open file
> /proc/sys/vm/nr_hugepages!");
> +    }
> +    if (fprintf(nr_hugepages_file, "%d", 1024)<  0) {
> +        tst_brkm(TBROK, NULL, "Cannot write to file
> /proc/sys/vm/nr_hugepages!");
> +    }
> +    fclose(nr_hugepages_file);
> +
> sprintf(mypid,"/%d",getpid());
> TEMPFILE=strcat(mypid,TEMPFILE);
> TEMPFILE=strcat(Hopt,TEMPFILE);
> @@ -275,5 +298,6 @@ cleanup()
> TEST_CLEANUP;
> 
> unlink(TEMPFILE);
> -
> -}
> \ No newline at end of file
> +    umount(mount_point);
> +    remove(mount_point);
> +}
> 


-- 
Best Regards,
Tang chen
--------------------------------------------------
Tang Chen
Development Dept.I
Nanjing Fujitsu Nanda Software Tech. Co., Ltd.(FNST)
No.6 Wenzhu Road, Nanjing, 210012, China
TEL: +86+25-86630566-8513
FUJITSU INTERNAL: 7998-8513
FAX: +86+25-83317685
EMail: tangchen@cn.fujitsu.com
--------------------------------------------------
This communication is for use by the intended recipient(s) only and may contain \
information that is privileged, confidential and exempt from disclosure under \
applicable law. If you are not an intended recipient of this communication, you are \
hereby notified that any dissemination, distribution or copying hereof is strictly \
prohibited.  If you have received this communication in error, please notify me by \
reply e-mail, permanently delete this communication from your system, and destroy any \
hard copies you may have printed



------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic