From: Wanlong G. <gao...@cn...> - 2012-01-30 03:32:04
|
Hi : This is the V2 of this cleanups, thanks for Casper's comments. Thanks -Wanlong Gao Wanlong Gao (5): hugemmap01: coding style cleanups hugemmap02: coding style cleanups hugemmap03: coding style cleanups hugemmap04: coding style cleanups hugemmap05: coding style cleanups testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c | 158 ++++++++---------- testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c | 182 +++++++++----------- testcases/kernel/mem/hugetlb/hugemmap/hugemmap03.c | 125 ++++++------- testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c | 178 +++++++++---------- testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c | 22 ++- 5 files changed, 308 insertions(+), 357 deletions(-) -- 1.7.9.rc2 |
From: Wanlong G. <gao...@cn...> - 2012-01-30 03:32:02
|
cleanup the coding style Signed-off-by: Wanlong Gao <gao...@cn...> --- testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c | 158 +++++++++----------- 1 files changed, 71 insertions(+), 87 deletions(-) diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c index 874f736..209265e 100644 --- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c +++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c @@ -33,29 +33,17 @@ * Pause for SIGUSR1 if option specified. * Create temporary directory. * - * Test: - * Loop if the proper options are given. - * Execute system call - * Check return code, if system call failed (return=-1) - * Log the errno and Issue a FAIL message. - * Cleanup: - * Print timing stats if options given - * Delete the temporary directory created. - * - * Usage: <for command-line> - * hugemmap01 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. + * Test: + * Loop if the proper options are given. + * Execute system call + * Check return code, if system call failed (return=-1) + * Log the errno and Issue a FAIL message. + * Cleanup: + * Print timing stats if options given + * Delete the temporary directory created. * * HISTORY - * 04/2004 Written by Robbie Williamson - * - * RESTRICTIONS: - * None. + * 04/2004 Written by Robbie Williamson */ #include <stdio.h> @@ -76,62 +64,53 @@ #define BUFFER_SIZE 256 -char* TEMPFILE="mmapfile"; +static char *TEMPFILE = "mmapfile"; -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 *TCID = "hugemmap01"; +int TST_TOTAL = 1; +static long *addr; /* addr of memory mapped region */ +static int fildes; /* file descriptor for tempfile */ +static char *Hopt; /* location of hugetlbfs */ +static int beforetest; /* Amount of free huge pages before testing */ +static int aftertest; /* Amount of free huge pages after testing */ +static int hugepagesmapped; /* Amount of huge pages mapped after testing */ -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"); -} +static void setup(void); +static void cleanup(void); +static void help(void); -int -main(int ac, char **av) +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; + int lc; + char *msg; + int Hflag = 0; + int page_sz = 0; - option_t options[] = { - { "H:", &Hflag, &Hopt }, /* Required for location of hugetlbfs */ - { NULL, NULL, NULL } /* NULL required to end array */ - }; + option_t options[] = { + { "H:", &Hflag, &Hopt }, + { NULL, NULL, NULL } + }; - /* Parse standard options given to run the test. */ msg = parse_opts(ac, av, options, &help); - if (msg != (char *) NULL) { - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s, use -help", msg); - tst_exit(); - } + if (msg != NULL) + tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s," + "use -help", msg); - if (Hflag == 0) { - tst_brkm(TBROK, NULL, "-H option is REQUIRED for this test, use -h for options help"); - tst_exit(); - } + if (!Hflag) + tst_brkm(TBROK, NULL, "-H option is REQUIRED for this test, " + "use -h for options help"); setup(); for (lc = 0; TEST_LOOPING(lc); lc++) { - /* Creat a temporary file used for mapping */ - if ((fildes = open(TEMPFILE, O_RDWR | O_CREAT, 0666)) < 0) { - tst_brkm(TFAIL, cleanup, - "open() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - } + /* Creat a temporary file used for mapping */ + fildes = open(TEMPFILE, O_RDWR | O_CREAT, 0666); + if (fildes < 0) + tst_brkm(TFAIL|TERRNO, cleanup, "open %s failed", + TEMPFILE); - Tst_count=0; + Tst_count = 0; /* Note the number of free huge pages BEFORE testing */ beforetest = get_no_of_free_hugepages(); @@ -139,11 +118,8 @@ main(int ac, char **av) /* Note the size of huge page size BEFORE testing */ page_sz = hugepages_size(); - /* - * Call mmap - */ errno = 0; - addr = mmap(NULL, page_sz*1024, PROT_READ | PROT_WRITE, + addr = mmap(NULL, page_sz*1024, PROT_READ | PROT_WRITE, MAP_SHARED, fildes, 0); TEST_ERRNO = errno; @@ -155,19 +131,24 @@ main(int ac, char **av) } else { tst_resm(TPASS, "call succeeded"); /* force to allocate page and change HugePages_Free */ - *(int*)addr = 0; + *(int *)addr = 0; } - /* Make sure the number of free huge pages AFTER testing decreased */ + /* + * Make sure the number of free huge pages + * AFTER testing decreased + */ aftertest = get_no_of_free_hugepages(); hugepagesmapped = beforetest - aftertest; if (hugepagesmapped < 1) { - tst_resm(TWARN,"Number of HUGEPAGES_FREE stayed the same. Okay if"); - tst_resm(TWARN,"multiple copies running due to test collision."); + tst_resm(TWARN, "Number of HUGEPAGES_FREE stayed the" + " same. Okay if"); + tst_resm(TWARN, "multiple copies running due to test" + " collision."); } /* Clean up things in case we are looping */ /* Unmap the mapped memory */ - if (munmap(addr, page_sz*1024) != 0) { + if (munmap(addr, page_sz*1024) != 0) { tst_brkm(TFAIL, NULL, "munmap() fails to unmap the " "memory, errno=%d", errno); } @@ -181,21 +162,20 @@ main(int ac, char **av) /* * setup() - performs all ONE TIME setup for this test. * - * Get system page size, allocate and initialize the string dummy. - * Initialize addr such that it is more than one page below the break - * address of the process, and initialize one page region from addr - * with char 'A'. - * Creat a temporary directory and a file under it. - * Write some known data into file and get the size of the file. + * Get system page size, allocate and initialize the string dummy. + * Initialize addr such that it is more than one page below the break + * address of the process, and initialize one page region from addr + * with char 'A'. + * Creat a temporary directory and a file under it. + * Write some known data into file and get the size of the file. */ -void -setup() +static void setup(void) { char mypid[40]; - sprintf(mypid,"/%d",getpid()); - TEMPFILE=strcat(mypid,TEMPFILE); - TEMPFILE=strcat(Hopt,TEMPFILE); + sprintf(mypid, "/%d", getpid()); + TEMPFILE = strcat(mypid, TEMPFILE); + TEMPFILE = strcat(Hopt, TEMPFILE); tst_sig(FORK, DEF_HANDLER, cleanup); @@ -205,11 +185,10 @@ setup() /* * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Remove the temporary directory created. + * completion or premature exit. + * Remove the temporary directory created. */ -void -cleanup() +static void cleanup(void) { /* * print timing stats if that option was specified. @@ -219,3 +198,8 @@ cleanup() unlink(TEMPFILE); } + +static void help(void) +{ + printf(" -H /.. Location of hugetlbfs, i.e. -H /var/hugetlbfs\n"); +} -- 1.7.9.rc2 |
From: Caspar Z. <ca...@ca...> - 2012-02-02 08:51:07
|
On 01/30/2012 11:30 AM, Wanlong Gao wrote: > cleanup the coding style > > Signed-off-by: Wanlong Gao <gao...@cn...> > --- > testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c | 158 +++++++++----------- > 1 files changed, 71 insertions(+), 87 deletions(-) > > diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c > index 874f736..209265e 100644 > --- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c > +++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c > @@ -33,29 +33,17 @@ > * Pause for SIGUSR1 if option specified. > * Create temporary directory. > * > - * Test: > - * Loop if the proper options are given. > - * Execute system call > - * Check return code, if system call failed (return=-1) > - * Log the errno and Issue a FAIL message. > - * Cleanup: > - * Print timing stats if options given > - * Delete the temporary directory created. > - * > - * Usage: <for command-line> > - * hugemmap01 [-c n] [-f] [-i n] [-I x] [-P x] [-t] > - * where, -c n : Run n copies concurrently. > - * -f : Turn off functionality Testing. > - * -i n : Execute test n times. > - * -I x : Execute test for x seconds. > - * -P x : Pause for x seconds between iterations. > - * -t : Turn on syscall timing. > + * Test: > + * Loop if the proper options are given. > + * Execute system call > + * Check return code, if system call failed (return=-1) > + * Log the errno and Issue a FAIL message. > + * Cleanup: > + * Print timing stats if options given > + * Delete the temporary directory created. > * > * HISTORY > - * 04/2004 Written by Robbie Williamson > - * > - * RESTRICTIONS: > - * None. > + * 04/2004 Written by Robbie Williamson > */ > > #include <stdio.h> > @@ -76,62 +64,53 @@ > > #define BUFFER_SIZE 256 This one is unused, even if it is used, you can replace it with BUFSIZ > > -char* TEMPFILE="mmapfile"; > +static char *TEMPFILE = "mmapfile"; > > -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 *TCID = "hugemmap01"; > +int TST_TOTAL = 1; > +static long *addr; /* addr of memory mapped region */ > +static int fildes; /* file descriptor for tempfile */ > +static char *Hopt; /* location of hugetlbfs */ > +static int beforetest; /* Amount of free huge pages before testing */ > +static int aftertest; /* Amount of free huge pages after testing */ > +static int hugepagesmapped; /* Amount of huge pages mapped after testing */ I think these comments are not necessary either > > -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"); > -} > +static void setup(void); > +static void cleanup(void); > +static void help(void); > > -int > -main(int ac, char **av) > +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; > + int lc; > + char *msg; > + int Hflag = 0; > + int page_sz = 0; > > - option_t options[] = { > - { "H:", &Hflag, &Hopt }, /* Required for location of hugetlbfs */ > - { NULL, NULL, NULL } /* NULL required to end array */ > - }; > + option_t options[] = { > + { "H:", &Hflag, &Hopt }, > + { NULL, NULL, NULL } > + }; > > - /* Parse standard options given to run the test. */ > msg = parse_opts(ac, av, options, &help); > - if (msg != (char *) NULL) { > - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s, use -help", msg); > - tst_exit(); > - } > + if (msg != NULL) > + tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s," > + "use -help", msg); > > - if (Hflag == 0) { > - tst_brkm(TBROK, NULL, "-H option is REQUIRED for this test, use -h for options help"); > - tst_exit(); > - } > + if (!Hflag) > + tst_brkm(TBROK, NULL, "-H option is REQUIRED for this test, " > + "use -h for options help"); > > setup(); > > for (lc = 0; TEST_LOOPING(lc); lc++) { > > - /* Creat a temporary file used for mapping */ > - if ((fildes = open(TEMPFILE, O_RDWR | O_CREAT, 0666)) < 0) { > - tst_brkm(TFAIL, cleanup, > - "open() on %s Failed, errno=%d : %s", > - TEMPFILE, errno, strerror(errno)); > - } > + /* Creat a temporary file used for mapping */ > + fildes = open(TEMPFILE, O_RDWR | O_CREAT, 0666); > + if (fildes < 0) > + tst_brkm(TFAIL|TERRNO, cleanup, "open %s failed", > + TEMPFILE); > > - Tst_count=0; > + Tst_count = 0; > > /* Note the number of free huge pages BEFORE testing */ > beforetest = get_no_of_free_hugepages(); > @@ -139,11 +118,8 @@ main(int ac, char **av) > /* Note the size of huge page size BEFORE testing */ > page_sz = hugepages_size(); > > - /* > - * Call mmap > - */ > errno = 0; > - addr = mmap(NULL, page_sz*1024, PROT_READ | PROT_WRITE, > + addr = mmap(NULL, page_sz*1024, PROT_READ | PROT_WRITE, > MAP_SHARED, fildes, 0); > TEST_ERRNO = errno; errno = 0 and TEST_ERRNO = errno should be useless here. Also I saw the original code: 150 /* Check for the return value of mmap() */ 151 if (addr == MAP_FAILED) { 152 tst_resm(TFAIL, "mmap() Failed on %s, errno=%d : %s", 153 TEMPFILE, errno, strerror(errno)); 154 continue; the tst_resm line should be updated by using TFAIL|TERRNO as well. > > @@ -155,19 +131,24 @@ main(int ac, char **av) > } else { > tst_resm(TPASS, "call succeeded"); > /* force to allocate page and change HugePages_Free */ > - *(int*)addr = 0; > + *(int *)addr = 0; > } > > - /* Make sure the number of free huge pages AFTER testing decreased */ > + /* > + * Make sure the number of free huge pages > + * AFTER testing decreased > + */ > aftertest = get_no_of_free_hugepages(); > hugepagesmapped = beforetest - aftertest; > if (hugepagesmapped < 1) { > - tst_resm(TWARN,"Number of HUGEPAGES_FREE stayed the same. Okay if"); > - tst_resm(TWARN,"multiple copies running due to test collision."); > + tst_resm(TWARN, "Number of HUGEPAGES_FREE stayed the" > + " same. Okay if"); > + tst_resm(TWARN, "multiple copies running due to test" > + " collision."); This looks a little complicated. one tst_resm and mulitple quoted lines are enough. > } > /* Clean up things in case we are looping */ > /* Unmap the mapped memory */ > - if (munmap(addr, page_sz*1024) != 0) { > + if (munmap(addr, page_sz*1024) != 0) { > tst_brkm(TFAIL, NULL, "munmap() fails to unmap the " > "memory, errno=%d", errno); > } brackets are unnecessary here. Also you'd better use `tst_brkm(TFAIL|TERRNO, NULL, "munmap")` here. > @@ -181,21 +162,20 @@ main(int ac, char **av) > /* > * setup() - performs all ONE TIME setup for this test. > * > - * Get system page size, allocate and initialize the string dummy. > - * Initialize addr such that it is more than one page below the break > - * address of the process, and initialize one page region from addr > - * with char 'A'. > - * Creat a temporary directory and a file under it. > - * Write some known data into file and get the size of the file. > + * Get system page size, allocate and initialize the string dummy. > + * Initialize addr such that it is more than one page below the break > + * address of the process, and initialize one page region from addr > + * with char 'A'. > + * Creat a temporary directory and a file under it. > + * Write some known data into file and get the size of the file. > */ > -void > -setup() > +static void setup(void) > { > char mypid[40]; > > - sprintf(mypid,"/%d",getpid()); > - TEMPFILE=strcat(mypid,TEMPFILE); > - TEMPFILE=strcat(Hopt,TEMPFILE); > + sprintf(mypid, "/%d", getpid()); > + TEMPFILE = strcat(mypid, TEMPFILE); > + TEMPFILE = strcat(Hopt, TEMPFILE); > > tst_sig(FORK, DEF_HANDLER, cleanup); > > @@ -205,11 +185,10 @@ setup() > > /* > * cleanup() - performs all ONE TIME cleanup for this test at > - * completion or premature exit. > - * Remove the temporary directory created. > + * completion or premature exit. > + * Remove the temporary directory created. > */ > -void > -cleanup() > +static void cleanup(void) > { > /* > * print timing stats if that option was specified. > @@ -219,3 +198,8 @@ cleanup() > unlink(TEMPFILE); > > } > + > +static void help(void) > +{ > + printf(" -H /.. Location of hugetlbfs, i.e. -H /var/hugetlbfs\n"); > +} |
From: Wanlong G. <gao...@cn...> - 2012-01-30 03:32:03
|
cleanup the coding style Signed-off-by: Wanlong Gao <gao...@cn...> --- testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c | 182 +++++++++----------- 1 files changed, 85 insertions(+), 97 deletions(-) diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c index 45cddf7..6505787 100644 --- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c +++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c @@ -20,32 +20,23 @@ /* * Test Name: hugemmap02 * - * Test Description: There is both a low hugepage region (at 2-3G for use by 32-bit - * processes) and a high hugepage region (at 1-1.5T). The high region is always - * exclusively for hugepages, but the low region has to be activated before it can - * be used for hugepages. When the kernel attempts to do a hugepage mapping in a - * 32-bit process it will automatically attempt to open the low region. However, - * that will fail if there are any normal (non-hugepage) mappings in the region - * already. - * When run as a 64-bit process the kernel will still do a non-hugepage mapping + * Test Description: There is both a low hugepage region (at 2-3G for use by + * 32-bit processes) and a high hugepage region (at 1-1.5T). The high region + * is always exclusively for hugepages, but the low region has to be activated + * before it can be used for hugepages. When the kernel attempts to do a + * hugepage mapping in a 32-bit process it will automatically attempt to open + * the low region. However, that will fail if there are any normal + * (non-hugepage) mappings in the region already. + * + * When run as a 64-bit process the kernel will still do a non-hugepage mapping * in the low region, but the following hugepage mapping will succeed. This is - * because it comes from the high region, which is available to the 64-bit process. - * This test case is checking this behavior. + * because it comes from the high region, which is available to the 64-bit + * process. * - * Usage: <for command-line> - * hugemmap02 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. + * This test case is checking this behavior. * * HISTORY - * 04/2004 Written by Robbie Williamson - * - * RESTRICTIONS: - * None. + * 04/2004 Written by Robbie Williamson */ #include <stdio.h> @@ -67,47 +58,42 @@ #define LOW_ADDR (void *)(0x80000000) #define LOW_ADDR2 (void *)(0x90000000) -char TEMPFILE[MAXPATHLEN]; - -char *TCID = "hugemmap02"; /* Test program identifier. */ -int TST_TOTAL = 1; /* Total number of test cases. */ -unsigned long *addr; /* addr of memory mapped region */ -unsigned long *addr2; /* addr of memory mapped region */ -unsigned long *addrlist[5]; /* list of addresses of memory mapped region */ -int i; -int fildes; /* file descriptor for tempfile */ -int nfildes; /* file descriptor for /dev/zero */ -char *Hopt; /* location of hugetlbfs */ +static char TEMPFILE[MAXPATHLEN]; -void setup(); /* Main setup function of test */ -void cleanup(); /* cleanup function for the test */ +char *TCID = "hugemmap02"; +int TST_TOTAL = 1; +static unsigned long *addr; +static unsigned long *addr2; +static unsigned long *addrlist[5]; +static int i; +static int fildes; /* file descriptor for tempfile */ +static int nfildes; /* file descriptor for /dev/zero */ +static char *Hopt; /* location of hugetlbfs */ -void help() -{ - printf(" -H /.. Location of hugetlbfs, i.e. -H /var/hugetlbfs \n"); -} +static void setup(void); +static void cleanup(void); +static void help(void); -int -main(int ac, char **av) +int main(int ac, char **av) { int lc; char *msg; - int Hflag = 0; + int Hflag = 0; int page_sz, map_sz; - option_t options[] = { - { "H:", &Hflag, &Hopt }, /* Required for location of hugetlbfs */ - { NULL, NULL, NULL } /* NULL required to end array */ - }; + option_t options[] = { + { "H:", &Hflag, &Hopt }, + { NULL, NULL, NULL } + }; - /* Parse standard options given to run the test. */ - if ((msg = parse_opts(ac, av, options, &help)) != NULL) - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s, use -help", msg); + msg = parse_opts(ac, av, options, &help); + if (msg != NULL) + tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s," + " use -help", msg); - if (Hflag == 0) { - tst_brkm(TBROK, NULL, - "-H option is REQUIRED for this test, use -h for options help"); - } + if (!Hflag) + tst_brkm(TBROK, NULL, "-H option is REQUIRED for this test," + " use -h for options help"); page_sz = getpagesize(); map_sz = 2 * 1024 * hugepages_size(); @@ -115,16 +101,17 @@ main(int ac, char **av) setup(); for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* Creat a temporary file used for huge mapping */ - if ((fildes = open(TEMPFILE, O_RDWR|O_CREAT, 0666)) < 0) { + /* Creat a temporary file used for huge mapping */ + fildes = open(TEMPFILE, O_RDWR|O_CREAT, 0666); + if (fildes < 0) { tst_brkm(TBROK|TERRNO, cleanup, - "opening %s failed", TEMPFILE); + "opening %s failed", TEMPFILE); } - /* Creat a file used for normal mapping */ - if ((nfildes = open("/dev/zero", O_RDONLY, 0666)) < 0) { + /* Creat a file used for normal mapping */ + nfildes = open("/dev/zero", O_RDONLY, 0666); + if (nfildes < 0) { tst_brkm(TBROK|TERRNO, cleanup, - "opening /dev/zero failed"); + "opening /dev/zero failed"); } Tst_count = 0; @@ -132,60 +119,57 @@ main(int ac, char **av) /* * Call mmap on /dev/zero 5 times */ - for (i = 0; i < 5; i++) { - addr = mmap(0, 256*1024*1024, PROT_READ, - MAP_SHARED, nfildes, 0); - addrlist[i] = addr; - } + for (i = 0; i < 5; i++) { + addr = mmap(0, 256*1024*1024, PROT_READ, + MAP_SHARED, nfildes, 0); + addrlist[i] = addr; + } /* mmap using normal pages and a low memory address */ errno = 0; addr = mmap(LOW_ADDR, page_sz, PROT_READ, MAP_SHARED | MAP_FIXED, nfildes, 0); if (addr == MAP_FAILED) - tst_brkm(TBROK, cleanup,"mmap failed on nfildes"); + tst_brkm(TBROK, cleanup, "mmap failed on nfildes"); /* Attempt to mmap a huge page into a low memory address */ errno = 0; addr2 = mmap(LOW_ADDR2, map_sz, PROT_READ | PROT_WRITE, - MAP_SHARED, fildes, 0); + MAP_SHARED, fildes, 0); #if __WORDSIZE == 64 /* 64-bit process */ if (addr2 == MAP_FAILED) { - tst_resm(TFAIL|TERRNO, - "huge mmap failed unexpectedly with %s (64-bit)", - TEMPFILE); + tst_resm(TFAIL|TERRNO, "huge mmap failed unexpectedly" + " with %s (64-bit)", TEMPFILE); continue; } else { tst_resm(TPASS, "huge mmap succeeded (64-bit)"); } #else /* 32-bit process */ if (addr2 == MAP_FAILED) - tst_resm(TFAIL|TERRNO, - "huge mmap failed unexpectedly with %s (32-bit)", - TEMPFILE); + tst_resm(TFAIL|TERRNO, "huge mmap failed unexpectedly" + " with %s (32-bit)", TEMPFILE); else if (addr2 > 0) { - tst_resm(TCONF, "huge mmap failed to test the scenario"); - continue; - } else if (addr == 0) - tst_resm(TPASS, "huge mmap succeeded (32-bit)"); + tst_resm(TCONF, + "huge mmap failed to test the scenario"); + continue; + } else if (addr == 0) + tst_resm(TPASS, "huge mmap succeeded (32-bit)"); #endif /* Clean up things in case we are looping */ for (i = 0; i < 5; i++) { - if (munmap(addrlist[i], 256*1024*1024) == -1) - tst_resm(TBROK|TERRNO, - "munmap of addrlist[%d] failed", i); - } + if (munmap(addrlist[i], 256*1024*1024) == -1) + tst_resm(TBROK|TERRNO, + "munmap of addrlist[%d] failed", i); + } #if __WORDSIZE == 64 - if (munmap(addr2, map_sz) == -1) { + if (munmap(addr2, map_sz) == -1) tst_brkm(TFAIL|TERRNO, NULL, "huge munmap failed"); - } #endif - if (munmap(addr, page_sz) == -1) { + if (munmap(addr, page_sz) == -1) tst_brkm(TFAIL|TERRNO, NULL, "munmap failed"); - } close(fildes); } @@ -198,15 +182,15 @@ main(int ac, char **av) /* * setup() - performs all ONE TIME setup for this test. * - * Get system page size, allocate and initialize the string dummy. - * Initialize addr such that it is more than one page below the break - * address of the process, and initialize one page region from addr - * with char 'A'. - * Creat a temporary directory and a file under it. - * Write some known data into file and get the size of the file. + * Get system page size, allocate and initialize the string dummy. + * Initialize addr such that it is more than one page below the break + * address of the process, and initialize one page region from addr + * with char 'A'. + * + * Creat a temporary directory and a file under it. + * Write some known data into file and get the size of the file. */ -void -setup() +static void setup(void) { tst_tmpdir(); @@ -219,11 +203,10 @@ setup() /* * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Remove the temporary directory created. + * completion or premature exit. + * Remove the temporary directory created. */ -void -cleanup() +static void cleanup(void) { /* * print timing stats if that option was specified. @@ -234,3 +217,8 @@ cleanup() tst_rmdir(); } + +static void help(void) +{ + printf(" -H /.. Location of hugetlbfs, i.e. -H /var/hugetlbfs\n"); +} -- 1.7.9.rc2 |
From: Wanlong G. <gao...@cn...> - 2012-01-30 03:32:04
|
cleanup the coding style Signed-off-by: Wanlong Gao <gao...@cn...> --- testcases/kernel/mem/hugetlb/hugemmap/hugemmap03.c | 125 +++++++++----------- 1 files changed, 58 insertions(+), 67 deletions(-) diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap03.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap03.c index cac94b0..0876952 100644 --- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap03.c +++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap03.c @@ -23,17 +23,8 @@ * Test Description: Test that a normal page cannot be mapped into a high * memory region. * - * Usage: <for command-line> - * hugemmap03 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * * HISTORY - * 04/2004 Written by Robbie Williamson + * 04/2004 Written by Robbie Williamson * * RESTRICTIONS: * Must be compiled in 64-bit mode. @@ -57,76 +48,72 @@ #define HIGH_ADDR (void *)(0x1000000000000) -char* TEMPFILE="mmapfile"; - -char *TCID="hugemmap03"; /* Test program identifier. */ -int TST_TOTAL=1; /* Total number of test cases. */ -unsigned long *addr; /* addr of memory mapped region */ -int fildes; /* file descriptor for tempfile */ -char *Hopt; /* location of hugetlbfs */ +static char *TEMPFILE = "mmapfile"; -void setup(); /* Main setup function of test */ -void cleanup(); /* cleanup function for the test */ +char *TCID = "hugemmap03"; +int TST_TOTAL = 1; +static unsigned long *addr; /* addr of memory mapped region */ +static int fildes; /* file descriptor for tempfile */ +static char *Hopt; /* location of hugetlbfs */ -void help() -{ - printf(" -H /.. Location of hugetlbfs, i.e. -H /var/hugetlbfs \n"); -} +static void setup(void); +static void cleanup(void); +static void help(void); -int -main(int ac, char **av) +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 lc; + char *msg; + int Hflag = 0; int page_sz; -#if __WORDSIZE==32 /* 32-bit compiled */ +#if __WORDSIZE == 32 /* 32-bit compiled */ tst_brkm(TCONF, NULL, "This test is only for 64bit"); #endif - option_t options[] = { - { "H:", &Hflag, &Hopt }, /* Required for location of hugetlbfs */ - { NULL, NULL, NULL } /* NULL required to end array */ - }; + option_t options[] = { + { "H:", &Hflag, &Hopt }, + { NULL, NULL, NULL } + }; - /* Parse standard options given to run the test. */ msg = parse_opts(ac, av, options, &help); - if (msg != (char *) NULL) { - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s, use -help", msg); - tst_exit(); - } + if (msg != NULL) + tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s, use -help", + msg); - if (Hflag == 0) { - tst_brkm(TBROK, NULL, "-H option is REQUIRED for this test, use -h for options help"); - tst_exit(); - } + if (!Hflag) + tst_brkm(TBROK, NULL, "-H option is REQUIRED for this test, " + "use -h for options help"); page_sz = getpagesize(); setup(); for (lc = 0; TEST_LOOPING(lc); lc++) { - - /* Creat a temporary file used for huge mapping */ - if ((fildes = open(TEMPFILE, O_RDWR | O_CREAT, 0666)) < 0) { - tst_brkm(TFAIL, cleanup, - "open() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); + /* Creat a temporary file used for huge mapping */ + fildes = open(TEMPFILE, O_RDWR | O_CREAT, 0666); + if (fildes < 0) { + tst_brkm(TBROK|TERRNO, cleanup, + "opening %s failed", TEMPFILE); } - Tst_count=0; + Tst_count = 0; - /* Attempt to mmap using normal pages and a high memory address */ + /* + * Attempt to mmap using normal pages and + * a high memory address + */ errno = 0; addr = mmap(HIGH_ADDR, page_sz, PROT_READ, MAP_SHARED | MAP_FIXED, fildes, 0); if (addr != MAP_FAILED) { - tst_resm(TFAIL, "Normal mmap() into high region unexpectedly succeeded on %s, errno=%d : %s", + tst_resm(TFAIL, "Normal mmap() into high region" + " unexpectedly succeeded on %s, errno=%d : %s", TEMPFILE, errno, strerror(errno)); continue; } else { - tst_resm(TPASS, "Normal mmap() into high region failed correctly"); + tst_resm(TPASS, "Normal mmap() into high region" + " failed correctly"); break; } @@ -141,21 +128,21 @@ main(int ac, char **av) /* * setup() - performs all ONE TIME setup for this test. * - * Get system page size, allocate and initialize the string dummy. - * Initialize addr such that it is more than one page below the break - * address of the process, and initialize one page region from addr - * with char 'A'. - * Creat a temporary directory and a file under it. - * Write some known data into file and get the size of the file. + * Get system page size, allocate and initialize the string dummy. + * Initialize addr such that it is more than one page below the break + * address of the process, and initialize one page region from addr + * with char 'A'. + * + * Creat a temporary directory and a file under it. + * Write some known data into file and get the size of the file. */ -void -setup() +void setup(void) { char mypid[40]; - sprintf(mypid,"/%d",getpid()); - TEMPFILE=strcat(mypid,TEMPFILE); - TEMPFILE=strcat(Hopt,TEMPFILE); + sprintf(mypid, "/%d", getpid()); + TEMPFILE = strcat(mypid, TEMPFILE); + TEMPFILE = strcat(Hopt, TEMPFILE); tst_sig(FORK, DEF_HANDLER, cleanup); @@ -165,11 +152,10 @@ setup() /* * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Remove the temporary directory created. + * completion or premature exit. + * Remove the temporary directory created. */ -void -cleanup() +void cleanup(void) { /* * print timing stats if that option was specified. @@ -179,3 +165,8 @@ cleanup() unlink(TEMPFILE); } + +void help(void) +{ + printf(" -H /.. Location of hugetlbfs, i.e. -H /var/hugetlbfs\n"); +} -- 1.7.9.rc2 |
From: Wanlong G. <gao...@cn...> - 2012-01-30 03:32:05
|
cleanup the coding style Signed-off-by: Wanlong Gao <gao...@cn...> --- testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c | 178 +++++++++----------- 1 files changed, 82 insertions(+), 96 deletions(-) diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c index 4cc6ed4..855200e 100644 --- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c +++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c @@ -21,7 +21,8 @@ * Test Name: hugemmap04 * * Test Description: - * Verify that, a hugetlb mmap() succeeds when used to map the largest size possible. + * Verify that, a hugetlb mmap() succeeds when used to map the largest + * size possible. * * Expected Result: * mmap() should succeed returning the address of the hugetlb mapped region. @@ -33,29 +34,17 @@ * Pause for SIGUSR1 if option specified. * Create temporary directory. * - * Test: - * Loop if the proper options are given. - * Execute system call - * Check return code, if system call failed (return=-1) - * Log the errno and Issue a FAIL message. - * Cleanup: - * Print timing stats if options given - * Delete the temporary directory created. - * - * Usage: <for command-line> - * hugemmap04 [-c n] [-f] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. + * Test: + * Loop if the proper options are given. + * Execute system call + * Check return code, if system call failed (return=-1) + * Log the errno and Issue a FAIL message. + * Cleanup: + * Print timing stats if options given + * Delete the temporary directory created. * * HISTORY - * 04/2004 Written by Robbie Williamson - * - * RESTRICTIONS: - * None. + * 04/2004 Written by Robbie Williamson */ #include <stdio.h> @@ -76,51 +65,43 @@ #define BUFFER_SIZE 256 -char* TEMPFILE="mmapfile"; - -char *TCID="hugemmap04"; /* Test program identifier. */ -int TST_TOTAL=1; /* Total number of test cases. */ -long *addr; /* addr of memory mapped region */ -long long mapsize; /* size of mapped region */ -int fildes; /* file descriptor for tempfile */ -int freepages=0; /* Amount of free huge pages to use for testing */ -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 *Hopt; /* location of hugetlbfs */ +static char *TEMPFILE = "mmapfile"; -void setup(); /* Main setup function of test */ -void cleanup(); /* cleanup function for the test */ +char *TCID = "hugemmap04"; +int TST_TOTAL = 1; +static long *addr; +static long long mapsize; +static int fildes; +static int freepages; /* Amount of free huge pages for testing */ +static int beforetest; /* Amount of free huge pages before testing */ +static int aftertest; /* Amount of free huge pages after testing */ +static int hugepagesmapped; /* Amount of huge pages mapped after testing */ +static char *Hopt; /* location of hugetlbfs */ -void help() -{ - printf(" -H /.. Location of hugetlbfs, i.e. -H /var/hugetlbfs \n"); -} +static void setup(void); +static void cleanup(void); +static void help(void); -int -main(int ac, char **av) +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 huge_pagesize=0; + int lc; + char *msg; + int Hflag = 0; + int huge_pagesize = 0; - option_t options[] = { - { "H:", &Hflag, &Hopt }, /* Required for location of hugetlbfs */ - { NULL, NULL, NULL } /* NULL required to end array */ - }; + option_t options[] = { + { "H:", &Hflag, &Hopt }, + { NULL, NULL, NULL } + }; - /* Parse standard options given to run the test. */ msg = parse_opts(ac, av, options, &help); - if (msg != (char *) NULL) { - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s, use -help", msg); - tst_exit(); - } + if (msg != NULL) + tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s," + " use -help", msg); - if (Hflag == 0) { - tst_brkm(TBROK, NULL, "-H option is REQUIRED for this test, use -h for options help"); - tst_exit(); - } + if (!Hflag) + tst_brkm(TBROK, NULL, "-H option is REQUIRED for this test," + " use -h for options help"); /* Check number of hugepages */ if (get_no_of_hugepages() <= 0 || hugepages_size() <= 0) @@ -129,15 +110,13 @@ main(int ac, char **av) setup(); for (lc = 0; TEST_LOOPING(lc); lc++) { + /* Creat a temporary file used for huge mapping */ + fildes = open(TEMPFILE, O_RDWR | O_CREAT, 0666); + if (fildes < 0) + tst_brkm(TFAIL|TERRNO, cleanup, "open %s failed", + TEMPFILE); - /* Creat a temporary file used for mapping */ - if ((fildes = open(TEMPFILE, O_RDWR | O_CREAT, 0666)) < 0) { - tst_brkm(TFAIL, cleanup, - "open() on %s Failed, errno=%d : %s", - TEMPFILE, errno, strerror(errno)); - } - - Tst_count=0; + Tst_count = 0; /* Note the number of free huge pages BEFORE testing */ freepages = get_no_of_free_hugepages(); @@ -145,19 +124,18 @@ main(int ac, char **av) /* Note the size of huge page size BEFORE testing */ huge_pagesize = hugepages_size(); - tst_resm(TINFO,"Size of huge pages is %d KB",huge_pagesize); + tst_resm(TINFO, "Size of huge pages is %d KB", huge_pagesize); -#if __WORDSIZE==32 - tst_resm(TINFO,"Total amount of free huge pages is %d",freepages); - tst_resm(TINFO,"Max number allowed for 1 mmap file in 32-bits is 128"); +#if __WORDSIZE == 32 + tst_resm(TINFO, "Total amount of free huge pages is %d", + freepages); + tst_resm(TINFO, "Max number allowed for 1 mmap file in" + " 32-bits is 128"); if (freepages > 128) - freepages=128; + freepages = 128; #endif - /* - * Call mmap - */ errno = 0; - mapsize=(long long)freepages*huge_pagesize*1024; + mapsize = (long long)freepages * huge_pagesize * 1024; addr = mmap(NULL, mapsize, PROT_READ | PROT_WRITE, MAP_SHARED, fildes, 0); TEST_ERRNO = errno; @@ -168,17 +146,22 @@ main(int ac, char **av) TEMPFILE, errno, strerror(errno)); continue; } else { - tst_resm(TPASS, "Succeeded mapping file using %d pages",freepages); + tst_resm(TPASS, "Succeeded mapping file using %d pages", + freepages); /* force to allocate page and change HugePages_Free */ - *(int*)addr = 0; + *(int *)addr = 0; } - /* Make sure the number of free huge pages AFTER testing decreased */ + /* + * Make sure the number of free huge pages + * AFTER testing decreased + */ aftertest = get_no_of_free_hugepages(); hugepagesmapped = beforetest - aftertest; if (hugepagesmapped < 1) { - tst_resm(TWARN,"Number of HUGEPAGES_FREE stayed the same. Okay if"); - tst_resm(TWARN,"multiple copies running due to test collision."); + tst_resm(TWARN, "Number of HUGEPAGES_FREE stayed the" + " same. Okay if multiple copies running due" + " to test collision."); } /* Clean up things in case we are looping */ /* Unmap the mapped memory */ @@ -196,21 +179,20 @@ main(int ac, char **av) /* * setup() - performs all ONE TIME setup for this test. * - * Get system page size, allocate and initialize the string dummy. - * Initialize addr such that it is more than one page below the break - * address of the process, and initialize one page region from addr - * with char 'A'. - * Creat a temporary directory and a file under it. - * Write some known data into file and get the size of the file. + * Get system page size, allocate and initialize the string dummy. + * Initialize addr such that it is more than one page below the break + * address of the process, and initialize one page region from addr + * with char 'A'. + * Creat a temporary directory and a file under it. + * Write some known data into file and get the size of the file. */ -void -setup() +void setup(void) { char mypid[40]; - sprintf(mypid,"/%d",getpid()); - TEMPFILE=strcat(mypid,TEMPFILE); - TEMPFILE=strcat(Hopt,TEMPFILE); + sprintf(mypid, "/%d", getpid()); + TEMPFILE = strcat(mypid, TEMPFILE); + TEMPFILE = strcat(Hopt, TEMPFILE); tst_sig(FORK, DEF_HANDLER, cleanup); @@ -220,11 +202,10 @@ setup() /* * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Remove the temporary directory created. + * completion or premature exit. + * Remove the temporary directory created. */ -void -cleanup() +void cleanup(void) { /* * print timing stats if that option was specified. @@ -234,3 +215,8 @@ cleanup() unlink(TEMPFILE); } + +static void help(void) +{ + printf(" -H /.. Location of hugetlbfs, i.e. -H /var/hugetlbfs\n"); +} -- 1.7.9.rc2 |
From: Wanlong G. <gao...@cn...> - 2012-01-30 03:32:09
|
cleanup the coding style Signed-off-by: Wanlong Gao <gao...@cn...> --- testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c | 22 ++++++++++--------- 1 files changed, 12 insertions(+), 10 deletions(-) diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c index 50bb8ca..d0b8b50 100644 --- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c +++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c @@ -89,7 +89,7 @@ static char *opt_allocstr; static int hugepagesize; /* in Bytes */ static int opt_sysfs, opt_alloc; static int shmid = -1; -static int restore_shmmax = 0; +static int restore_shmmax; static size_t size = 128, length = 384; static option_t options[] = { { "s", &opt_sysfs, NULL}, @@ -102,7 +102,7 @@ static void cleanup(void); static void overcommit(void); static void write_bytes(void *addr); static void read_bytes(void *addr); -static int lookup (char *line, char *pattern); +static int lookup(char *line, char *pattern); static void usage(void); static int checkproc(FILE *fp, char *string, int value); static int checksys(char *path, char *pattern, int value); @@ -139,7 +139,7 @@ int main(int argc, char *argv[]) for (lc = 0; TEST_LOOPING(lc); lc++) { Tst_count = 0; overcommit(); - } + } cleanup(); tst_exit(); } @@ -194,7 +194,7 @@ static void overcommit(void) tst_brkm(TBROK|TERRNO, cleanup, "fopen"); if (checkproc(fp, "HugePages_Total", length / 2) != 0) return; - if (checkproc(fp, "HugePages_Free", length / 2 ) != 0) + if (checkproc(fp, "HugePages_Free", length / 2) != 0) return; if (checkproc(fp, "HugePages_Surp", length / 2 - size) != 0) return; @@ -209,7 +209,7 @@ static void overcommit(void) tst_brkm(TBROK|TERRNO, cleanup, "shmat"); write_bytes(shmaddr); read_bytes(shmaddr); - } else { + } else { write_bytes(addr); read_bytes(addr); } @@ -326,7 +326,8 @@ static void setup(void) fd = open(PATH_SHMMAX, O_RDWR); if (fd == -1) tst_brkm(TBROK|TERRNO, cleanup, "open"); - snprintf(buf, BUFSIZ, "%ld", (long)(length / 2 * hugepagesize)); + snprintf(buf, BUFSIZ, "%ld", + (long)(length / 2 * hugepagesize)); if (write(fd, buf, strlen(buf)) != strlen(buf)) tst_brkm(TBROK|TERRNO, cleanup, "failed to change shmmax."); @@ -409,8 +410,8 @@ static void read_bytes(void *addr) } } -/* Lookup a pattern and get the value from file*/ -static int lookup (char *line, char *pattern) +/* Lookup a pattern and get the value from file */ +static int lookup(char *line, char *pattern) { char buf2[BUFSIZ]; @@ -473,7 +474,8 @@ static void init_hugepagesize(void) FILE *fp; memset(buf, -1, BUFSIZ); - if ((fp = fopen(PATH_MEMINFO, "r")) == NULL) + fp = fopen(PATH_MEMINFO, "r"); + if (fp == NULL) tst_brkm(TBROK, NULL, "can't open %s", PATH_MEMINFO); while (fgets(line, BUFSIZ, fp) != NULL) { if (lookup(line, "Hugepagesize")) { @@ -485,7 +487,7 @@ static void init_hugepagesize(void) tst_brkm(TBROK, NULL, "get Hugepagesize failed."); } -/* +/* * It's not easy to #define tunable file paths via sysfs, * use function init_hugepagesize and global variable instead. */ -- 1.7.9.rc2 |
From: Caspar Z. <ca...@ca...> - 2012-02-02 15:37:27
|
On 01/30/2012 11:30 AM, Wanlong Gao wrote: > cleanup the coding style > > Signed-off-by: Wanlong Gao <gao...@cn...> Hi, I committed this patch, please make an update on 1-4. Thanks, Caspar > --- > testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c | 22 ++++++++++--------- > 1 files changed, 12 insertions(+), 10 deletions(-) > > diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c > index 50bb8ca..d0b8b50 100644 > --- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c > +++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c > @@ -89,7 +89,7 @@ static char *opt_allocstr; > static int hugepagesize; /* in Bytes */ > static int opt_sysfs, opt_alloc; > static int shmid = -1; > -static int restore_shmmax = 0; > +static int restore_shmmax; > static size_t size = 128, length = 384; > static option_t options[] = { > { "s", &opt_sysfs, NULL}, > @@ -102,7 +102,7 @@ static void cleanup(void); > static void overcommit(void); > static void write_bytes(void *addr); > static void read_bytes(void *addr); > -static int lookup (char *line, char *pattern); > +static int lookup(char *line, char *pattern); > static void usage(void); > static int checkproc(FILE *fp, char *string, int value); > static int checksys(char *path, char *pattern, int value); > @@ -139,7 +139,7 @@ int main(int argc, char *argv[]) > for (lc = 0; TEST_LOOPING(lc); lc++) { > Tst_count = 0; > overcommit(); > - } > + } > cleanup(); > tst_exit(); > } > @@ -194,7 +194,7 @@ static void overcommit(void) > tst_brkm(TBROK|TERRNO, cleanup, "fopen"); > if (checkproc(fp, "HugePages_Total", length / 2) != 0) > return; > - if (checkproc(fp, "HugePages_Free", length / 2 ) != 0) > + if (checkproc(fp, "HugePages_Free", length / 2) != 0) > return; > if (checkproc(fp, "HugePages_Surp", length / 2 - size) != 0) > return; > @@ -209,7 +209,7 @@ static void overcommit(void) > tst_brkm(TBROK|TERRNO, cleanup, "shmat"); > write_bytes(shmaddr); > read_bytes(shmaddr); > - } else { > + } else { > write_bytes(addr); > read_bytes(addr); > } > @@ -326,7 +326,8 @@ static void setup(void) > fd = open(PATH_SHMMAX, O_RDWR); > if (fd == -1) > tst_brkm(TBROK|TERRNO, cleanup, "open"); > - snprintf(buf, BUFSIZ, "%ld", (long)(length / 2 * hugepagesize)); > + snprintf(buf, BUFSIZ, "%ld", > + (long)(length / 2 * hugepagesize)); > if (write(fd, buf, strlen(buf)) != strlen(buf)) > tst_brkm(TBROK|TERRNO, cleanup, > "failed to change shmmax."); > @@ -409,8 +410,8 @@ static void read_bytes(void *addr) > } > } > > -/* Lookup a pattern and get the value from file*/ > -static int lookup (char *line, char *pattern) > +/* Lookup a pattern and get the value from file */ > +static int lookup(char *line, char *pattern) > { > char buf2[BUFSIZ]; > > @@ -473,7 +474,8 @@ static void init_hugepagesize(void) > FILE *fp; > > memset(buf, -1, BUFSIZ); > - if ((fp = fopen(PATH_MEMINFO, "r")) == NULL) > + fp = fopen(PATH_MEMINFO, "r"); > + if (fp == NULL) > tst_brkm(TBROK, NULL, "can't open %s", PATH_MEMINFO); > while (fgets(line, BUFSIZ, fp) != NULL) { > if (lookup(line, "Hugepagesize")) { > @@ -485,7 +487,7 @@ static void init_hugepagesize(void) > tst_brkm(TBROK, NULL, "get Hugepagesize failed."); > } > > -/* > +/* > * It's not easy to #define tunable file paths via sysfs, > * use function init_hugepagesize and global variable instead. > */ |
From: Wanlong G. <gao...@cn...> - 2012-02-01 00:36:00
|
On 01/30/2012 11:30 AM, Wanlong Gao wrote: > Hi : > This is the V2 of this cleanups, thanks for Casper's comments. Ping, commit this set first? > > Thanks > -Wanlong Gao > > > Wanlong Gao (5): > hugemmap01: coding style cleanups > hugemmap02: coding style cleanups > hugemmap03: coding style cleanups > hugemmap04: coding style cleanups > hugemmap05: coding style cleanups > > testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c | 158 ++++++++---------- > testcases/kernel/mem/hugetlb/hugemmap/hugemmap02.c | 182 +++++++++----------- > testcases/kernel/mem/hugetlb/hugemmap/hugemmap03.c | 125 ++++++------- > testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c | 178 +++++++++---------- > testcases/kernel/mem/hugetlb/hugemmap/hugemmap05.c | 22 ++- > 5 files changed, 308 insertions(+), 357 deletions(-) > |
From: Cyril H. <ch...@su...> - 2012-02-02 14:31:33
|
Hi! > > Hi : > > This is the V2 of this cleanups, thanks for Casper's comments. > > > Ping, commit this set first? > Please follow Caspar's comments on that. -- Cyril Hrubis ch...@su... |