svn commit: r288691 - user/pho/stress2/misc

Peter Holm pho at FreeBSD.org
Mon Oct 5 06:40:11 UTC 2015


Author: pho
Date: Mon Oct  5 06:40:09 2015
New Revision: 288691
URL: https://svnweb.freebsd.org/changeset/base/288691

Log:
  These tests would run for an unreasonable long time. Fixed that.
  
  Sponsored by:	EMC / Isilon storage division

Modified:
  user/pho/stress2/misc/mmap10.sh
  user/pho/stress2/misc/mmap11.sh
  user/pho/stress2/misc/mmap15.sh
  user/pho/stress2/misc/mmap22.sh

Modified: user/pho/stress2/misc/mmap10.sh
==============================================================================
--- user/pho/stress2/misc/mmap10.sh	Mon Oct  5 05:33:30 2015	(r288690)
+++ user/pho/stress2/misc/mmap10.sh	Mon Oct  5 06:40:09 2015	(r288691)
@@ -43,11 +43,16 @@ mycc -o mmap10 -Wall -Wextra -O2 -g mmap
 rm -f mmap10.c
 
 daemon sh -c "(cd $here/../testcases/swap; ./swap -t 2m -i 20 -k)"
-rnd=`od -An -N1 -t u1 /dev/random | sed 's/ //g'`
-sleep $((rnd % 10))
+sleep `jot -r 1 0 9`
 for i in `jot 2`; do
-	/tmp/mmap10
+	/tmp/mmap10 &
 done
+sleep 300
+while pgrep -q mmap10; do
+	pkill -9 mmap10
+	sleep 2
+done
+wait
 killall -q swap
 
 rm -f /tmp/mmap10 /tmp/mmap10.core
@@ -56,7 +61,6 @@ EOF
 #include <sys/types.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
-#include <sys/time.h>
 #include <sys/wait.h>
 
 #include <err.h>
@@ -64,15 +68,13 @@ EOF
 #include <fcntl.h>
 #include <pthread.h>
 #include <pthread_np.h>
-#include <sched.h>
-#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <time.h>
 #include <unistd.h>
 
 #define LOOPS 2
+#define MMSIZE (192 * 1024 * 1024)
 #define N (128 * 1024 / (int)sizeof(u_int32_t))
 #define PARALLEL 50
 
@@ -122,12 +124,12 @@ void *
 tmmap(void *arg __unused)
 {
 	size_t len;
-	int i, fd;
+	int i, j, fd;
 
 	pthread_set_name_np(pthread_self(), __func__);
-	len = 1LL * 1024 * 1024 * 1024;
+	len = MMSIZE;
 
-	for (i = 0; i < 100; i++) {
+	for (i = 0, j = 0; i < 100; i++) {
 		if ((fd = open("/dev/zero", O_RDWR)) == -1)
 			err(1,"open()");
 
@@ -135,15 +137,19 @@ tmmap(void *arg __unused)
 		    fd, 0)) != MAP_FAILED) {
 			usleep(100);
 			munmap(p, len);
+			j++;
 		}
 
 		if ((p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON,
 		    -1, 0)) != MAP_FAILED) {
 			usleep(100);
 			munmap(p, len);
+			j++;
 		}
 		close(fd);
 	}
+	if (j == 0)
+		fprintf(stderr, "FAIL: all mmap(2) calls failed.\n");
 
 	return (NULL);
 }
@@ -255,7 +261,6 @@ main(void)
 	for (i = 0; i < N; i++)
 		r[i] = arc4random();
 
-	alarm(1200);
 	for (i = 0; i < LOOPS; i++) {
 		for (j = 0; j < PARALLEL; j++) {
 			if (fork() == 0)

Modified: user/pho/stress2/misc/mmap11.sh
==============================================================================
--- user/pho/stress2/misc/mmap11.sh	Mon Oct  5 05:33:30 2015	(r288690)
+++ user/pho/stress2/misc/mmap11.sh	Mon Oct  5 06:40:09 2015	(r288691)
@@ -46,11 +46,16 @@ mycc -o mmap11 -Wall -Wextra -O2 -g mmap
 rm -f mmap11.c
 
 daemon sh -c "(cd $here/../testcases/swap; ./swap -t 2m -i 20 -k)"
-rnd=`od -An -N1 -t u1 /dev/random | sed 's/ //g'`
-sleep $((rnd % 10))
+sleep `jot -r 1 0 9`
 for i in `jot 2`; do
-	/tmp/mmap11
+	/tmp/mmap11 &
 done
+sleep 300
+while pgrep -q mmap11; do
+	pkill -9 mmap11
+	sleep 2
+done
+wait
 killall -q swap
 
 rm -f /tmp/mmap11 /tmp/mmap11.core
@@ -59,7 +64,6 @@ EOF
 #include <sys/types.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
-#include <sys/time.h>
 #include <sys/wait.h>
 
 #include <err.h>
@@ -67,15 +71,13 @@ EOF
 #include <fcntl.h>
 #include <pthread.h>
 #include <pthread_np.h>
-#include <sched.h>
-#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <time.h>
 #include <unistd.h>
 
 #define LOOPS 2
+#define MMSIZE (192 * 1024 * 1024)
 #define N (128 * 1024 / (int)sizeof(u_int32_t))
 #define PARALLEL 50
 
@@ -125,12 +127,12 @@ void *
 tmmap(void *arg __unused)
 {
 	size_t len;
-	int i, fd;
+	int i, j, fd;
 
 	pthread_set_name_np(pthread_self(), __func__);
-	len = 1LL * 1024 * 1024 * 1024;
+	len = MMSIZE;
 
-	for (i = 0; i < 100; i++) {
+	for (i = 0, j = 0; i < 100; i++) {
 		if ((fd = open("/dev/zero", O_RDWR)) == -1)
 			err(1,"open()");
 
@@ -138,15 +140,19 @@ tmmap(void *arg __unused)
 		    fd, 0)) != MAP_FAILED) {
 			usleep(100);
 			munmap(p, len);
+			j++;
 		}
 
 		if ((p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON,
 		    -1, 0)) != MAP_FAILED) {
 			usleep(100);
 			munmap(p, len);
+			j++;
 		}
 		close(fd);
 	}
+	if (j == 0)
+		fprintf(stderr, "FAIL: all mmap(2) calls failed.\n");
 
 	return (NULL);
 }

Modified: user/pho/stress2/misc/mmap15.sh
==============================================================================
--- user/pho/stress2/misc/mmap15.sh	Mon Oct  5 05:33:30 2015	(r288690)
+++ user/pho/stress2/misc/mmap15.sh	Mon Oct  5 06:40:09 2015	(r288691)
@@ -49,8 +49,14 @@ mycc -o mmap15 -Wall -Wextra -O2 -g mmap
 rm -f mmap15.c
 
 for i in `jot 2`; do
-	su $testuser -c /tmp/mmap15
+	su $testuser -c /tmp/mmap15 &
 done
+sleep 300
+while pgrep -q mmap15; do
+	pkill -9 mmap15
+	sleep 2
+done
+wait
 
 rm -f /tmp/mmap15 /tmp/mmap15.core
 exit 0
@@ -74,6 +80,7 @@ EOF
 #include <unistd.h>
 
 #define LOOPS 2
+#define MMSIZE (256 * 1024)
 #define N (128 * 1024 / (int)sizeof(u_int32_t))
 #define PARALLEL 50
 
@@ -123,17 +130,23 @@ void *
 tmmap(void *arg __unused)
 {
 	size_t len;
-	int i, fd;
+	int i, j, fd;
 
 	pthread_set_name_np(pthread_self(), __func__);
-	len = 1LL * 128 * 1024 * 1024;
+	len = MMSIZE;
 
 	if ((fd = open("/dev/zero", O_RDWR)) == -1)
 		err(1,"open()");
-	for (i = 0; i < 100; i++) {
+	for (i = 0, j = 0; i < 100; i++) {
 		p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
+		if (p != MAP_FAILED)
+			j++;
 		p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0);
+		if (p != MAP_FAILED)
+			j++;
 	}
+	if (j == 0)
+		fprintf(stderr, "FAIL: all mmap(2) calls failed.\n");
 	close(fd);
 
 	return (NULL);
@@ -195,7 +208,6 @@ main(void)
 {
 	int i, j;
 
-	alarm(120);
 	for (i = 0; i < N; i++)
 		r[i] = arc4random();
 

Modified: user/pho/stress2/misc/mmap22.sh
==============================================================================
--- user/pho/stress2/misc/mmap22.sh	Mon Oct  5 05:33:30 2015	(r288690)
+++ user/pho/stress2/misc/mmap22.sh	Mon Oct  5 06:40:09 2015	(r288691)
@@ -46,11 +46,14 @@ sed '1,/^EOF/d' < $here/$0 > mmap22.c
 mycc -o mmap22 -Wall -Wextra -O2 -g mmap22.c -lpthread || exit 1
 rm -f mmap22.c
 
-su $testuser -c /tmp/mmap22
+su $testuser -c /tmp/mmap22 &
 
+sleep 300
 while pgrep -q mmap22; do
+	pkill -9 mmap22
         sleep 2
 done
+wait
 
 rm -f /tmp/mmap22 /tmp/mmap22.core
 exit 0
@@ -69,10 +72,9 @@ EOF
 #include <stdlib.h>
 #include <unistd.h>
 
-#define LOOPS 1
 #define MMAPS 25
-#define PARALLEL 10
-#define SIZ (128 * 1024 * 1024)
+#define PARALLEL 4
+#define SIZ (64 * 1024 * 1024)
 
 void *
 tmmap(void *arg __unused)
@@ -118,7 +120,6 @@ main(void)
 {
 	int i;
 
-	alarm(120);
 	for (i = 0; i < PARALLEL; i++) {
 		if (fork() == 0)
 			test();


More information about the svn-src-user mailing list