[LTP] [PATCH v4 2/4] mmapstress01: default nprocs 20 and cleanup

Edward Liaw edliaw@google.com
Thu Oct 6 20:42:26 CEST 2022


Drop usage information from top level comment and remove
unnecessary function definitions.

Signed-off-by: Edward Liaw <edliaw@google.com>
---
 .../kernel/mem/mmapstress/mmapstress01.c      | 46 +++----------------
 1 file changed, 6 insertions(+), 40 deletions(-)

diff --git a/testcases/kernel/mem/mmapstress/mmapstress01.c b/testcases/kernel/mem/mmapstress/mmapstress01.c
index f68193706..67a2b747d 100644
--- a/testcases/kernel/mem/mmapstress/mmapstress01.c
+++ b/testcases/kernel/mem/mmapstress/mmapstress01.c
@@ -18,33 +18,6 @@
  *  or times out (if a timeout value is specified).  When either of
  *  these things happens, it cleans up its kids, then checks the
  *  file to make sure it has the correct data.
- *
- *  usage:
- *	tmnoextend -p nprocs [-t minutes -f filesize -S sparseoffset
- *			      -r -o -m -l -d]
- *  where:
- *	-p nprocs	- specifies the number of mapping children
- *			  to create.  (nprocs + 1 children actually
- *			  get created, since one is the writer child)
- *	-t minutes	- specifies minutes to run.  If not specified,
- *			  default is to run forever until a SIGINT
- *			  is received.
- *	-f filesize	- initial filesize (defaults to FILESIZE)
- *	-S sparseoffset - when non-zero, causes a sparse area to
- *			  be left before the data, meaning that the
- *			  actual initial file size is sparseoffset +
- *			  filesize.  Useful for testing large files.
- *			  (default is 0).
- *	-r		- randomize number of pages map children check.
- *			  (random % MAXLOOPS).  If not specified, each
- *			  child checks MAXLOOPS pages.
- *	-o		- randomize offset of file to map. (default is 0)
- *	-m		- do random msync/fsyncs as well
- *	-l		- if set, the output file is not removed on
- *			  program exit.
- *	-d		- enable debug output
- *
- *  Compile with -DLARGE_FILE to enable file sizes > 2 GB.
  */
 
 #define _GNU_SOURCE 1
@@ -63,7 +36,6 @@
 #include "tst_test.h"
 
 #define MAXLOOPS	500	/* max pages for map children to write */
-#define	FILESIZE	4096	/* initial filesize set up by parent */
 #define TEST_FILE	"mmapstress01.out"
 
 #ifdef roundup
@@ -72,9 +44,6 @@
 #define roundup(x, y)	((((x)+((y)-1))/(y))*(y))
 
 static unsigned int initrand(void);
-static void child_mapper(char *file, unsigned int procno, unsigned int nprocs);
-static void fileokay(char *file, unsigned char *expbuf);
-static void sighandler(int sig);
 
 static char *debug;
 static char *do_sync;
@@ -87,9 +56,9 @@ static char *randloops;
 
 static int fd;
 static int finished;
-static int nprocs;
+static int nprocs = 20;
 static float alarmtime;
-static long long filesize = FILESIZE;
+static long long filesize = 4096;
 static long long sparseoffset;
 static size_t pagesize;
 static unsigned int pattern;
@@ -99,10 +68,11 @@ static struct tst_option options[] = {
 	{"f:", &opt_filesize, "Initial filesize (default 4096)"},
 	{"m", &do_sync, "Do random msync/fsyncs as well"},
 	{"o", &do_offset, "Randomize the offset of file to map"},
-	{"p:", &opt_nprocs, "Number of mapping children to create (required)"},
+	{"p:", &opt_nprocs,
+	 "Number of mapping children to create (default 20)"},
 	{"r", &randloops,
-	 "Randomize number of pages map children check (random % MAXLOOPS), "
-	 "otherwise each child checks MAXLOOPS pages"},
+	 "Randomize number of pages map children check (random % 500), "
+	 "otherwise each child checks 500 pages"},
 	{"S:", &opt_sparseoffset,
 	 "When non-zero, causes the sparse area to be left before the data, "
 	 "so that the actual initial filesize is sparseoffset + filesize "
@@ -115,10 +85,6 @@ static void setup(void)
 {
 	int pagesize = sysconf(_SC_PAGE_SIZE);
 
-	if (!opt_nprocs)
-		tst_brk(TBROK,
-			"missing number of mapping children, specify with -p nprocs");
-
 #if _FILE_OFFSET_BITS == 64
 	if (tst_parse_filesize(opt_filesize, &filesize, 0, LONG_MAX))
 #else
-- 
2.38.0.rc1.362.ged0d419d3c-goog



More information about the ltp mailing list