ports/107311: [patch] benchmarks/raidtest: make more accurate and avoid crashes

Vasil Dimov vd at FreeBSD.org
Fri Dec 29 11:30:21 UTC 2006


>Number:         107311
>Category:       ports
>Synopsis:       [patch] benchmarks/raidtest: make more accurate and avoid crashes
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Dec 29 11:30:19 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Vasil Dimov
>Release:        FreeBSD 6.2-PRERELEASE amd64
>Organization:
N/A
>Environment:

>Description:

raidtest receives SIGFPE:

Core was generated by `raidtest'.
Program terminated with signal 8, Arithmetic exception.
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /libexec/ld-elf.so.1...done.
Loaded symbols for /libexec/ld-elf.so.1
#0  0x000000000040185c in show_stats (secs=0, nbytes=12815872, nreqs=200)
    at raidtest.c:260
260             printf("Bytes per second: %ju\n", nbytes / secs);
(gdb) bt
#0  0x000000000040185c in show_stats (secs=0, nbytes=12815872, nreqs=200)
    at raidtest.c:260
#1  0x0000000000402000 in raidtest_test (argc=0, argv=0x7fffffffea98)
    at raidtest.c:407
#2  0x000000000040207c in main (argc=6, argv=0x7fffffffea68) at raidtest.c:421

The reason for this is obvious: secs is 0.

>How-To-Repeat:

Run test which finishes in less than one second.

>Fix:

In addition to avoiding the division by zero this patch makes raidtest
more accurate by not truncating seconds fractions.

--- raidtest_accuracy.diff begins here ---
Index: Makefile
===================================================================
RCS file: /usr/local/pcvs/ports/benchmarks/raidtest/Makefile,v
retrieving revision 1.4
diff -u -r1.4 Makefile
--- Makefile	7 May 2006 12:31:44 -0000	1.4
+++ Makefile	29 Dec 2006 10:15:31 -0000
@@ -7,7 +7,7 @@
 #
 
 PORTNAME=	raidtest
-PORTVERSION=	1.0
+PORTVERSION=	1.1
 CATEGORIES=	benchmarks
 MASTER_SITES=	# none
 DISTFILES=	# none
Index: files/Makefile
===================================================================
RCS file: /usr/local/pcvs/ports/benchmarks/raidtest/files/Makefile,v
retrieving revision 1.1
diff -u -r1.1 Makefile
--- files/Makefile	5 Dec 2004 04:13:29 -0000	1.1
+++ files/Makefile	29 Dec 2006 10:15:31 -0000
@@ -1,7 +1,7 @@
 # $FreeBSD: ports/benchmarks/raidtest/files/Makefile,v 1.1 2004/12/05 04:13:29 obrien Exp $
 
 PROG=	raidtest
-NOMAN=	true
+NO_MAN=	true
 WARNS?=	6
 BINDIR?= ${PREFIX}/bin
 
Index: files/raidtest.c
===================================================================
RCS file: /usr/local/pcvs/ports/benchmarks/raidtest/files/raidtest.c,v
retrieving revision 1.3
diff -u -r1.3 raidtest.c
--- files/raidtest.c	29 Dec 2004 01:57:28 -0000	1.3
+++ files/raidtest.c	29 Dec 2006 10:15:31 -0000
@@ -254,11 +254,11 @@
 }
 
 static void
-show_stats(long secs, uintmax_t nbytes, uintmax_t nreqs)
+show_stats(double secs, uintmax_t nbytes, uintmax_t nreqs)
 {
 
-	printf("Bytes per second: %ju\n", nbytes / secs);
-	printf("Requests per second: %ju\n", nreqs / secs);
+	printf("Bytes per second: %ju\n", (uintmax_t)(nbytes / secs));
+	printf("Requests per second: %ju\n", (uintmax_t)(nreqs / secs));
 }
 
 static void
@@ -266,7 +266,7 @@
 {
 	uintmax_t i, nbytes, nreqs, nrreqs, nwreqs, reqs_per_proc, nstart;
 	const char *dev, *file = NULL;
-	struct timeval tstart, tend;
+	struct timeval tstart, tend, tdiff;
 	struct ioreq *iorqs;
 	unsigned nprocs;
 	struct stat sb;
@@ -404,7 +404,9 @@
 		wait(&status);
 	}
 	gettimeofday(&tend, NULL);
-	show_stats(tend.tv_sec - tstart.tv_sec, nbytes, nreqs);
+	timersub(&tend, &tstart, &tdiff);
+	show_stats(tdiff.tv_sec + (double)tdiff.tv_usec / 1000000,
+		   nbytes, nreqs);
 }
 
 int
--- raidtest_accuracy.diff ends here ---

-- 
Vasil Dimov
gro.DSBeerF at dv
%
The Roman Rule
        The one who says it cannot be done should never interrupt the
        one who is doing it.
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list