Date: Thu, 29 Aug 2019 09:29:40 +0000 (UTC) From: Peter Holm <pho@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r351602 - user/pho/stress2/misc Message-ID: <201908290929.x7T9Te4I034670@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pho Date: Thu Aug 29 09:29:39 2019 New Revision: 351602 URL: https://svnweb.freebsd.org/changeset/base/351602 Log: Added regression tests. Sponsored by: Dell EMC Isilon Added: user/pho/stress2/misc/midi.sh (contents, props changed) user/pho/stress2/misc/midi2.sh (contents, props changed) Added: user/pho/stress2/misc/midi.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/midi.sh Thu Aug 29 09:29:39 2019 (r351602) @@ -0,0 +1,71 @@ +#!/bin/sh + +# Test scenario by Mark Johnston <markj@freebsd.org> + +# 'panic: vm_fault_hold: fault on nofault entry, addr: 0x33522000' seen. +# Fixed by 351262 + +# $FreeBSD$ + +cat > /tmp/midi.c <<EOF +#include <err.h> +#include <fcntl.h> +#include <pthread.h> +#include <stdatomic.h> +#include <stdlib.h> +#include <unistd.h> + +#define NTHREADS 16 + +static _Atomic(int) threads; +static int fd; + +static void * +t(void *data __unused) +{ + char buf[4096]; + ssize_t n; + off_t off; + + (void)atomic_fetch_add(&threads, 1); + while (atomic_load(&threads) != NTHREADS) + ; + + for (;;) { + arc4random_buf(&off, sizeof(off)); + if ((n = pread(fd, buf, sizeof(buf), off)) >= 0) + write(STDOUT_FILENO, buf, n); + } + + return (NULL); +} + +int +main(void) +{ + pthread_t tid[NTHREADS]; + int error, i; + + fd = open("/dev/midistat", O_RDONLY); + if (fd < 0) + err(1, "open"); + + for (i = 0; i < NTHREADS; i++) + if ((error = pthread_create(&tid[i], NULL, t, NULL)) != 0) + errc(1, error, "pthread_create"); + for (i = 0; i < NTHREADS; i++) + if ((error = pthread_join(tid[i], NULL)) != 0) + errc(1, error, "pthread_join"); + + return (0); +} +EOF +cc -o /tmp/midi -Wall -Wextra -O2 /tmp/midi.c -lpthread + +start=`date +%s` +while [ $((`date +%s` - start)) -lt 120 ]; do + timeout 10 /tmp/midi | strings | head -20 +done + +rm -f /tmp/midi /tmp/midi.c /tmp/midi.core +exit 0 Added: user/pho/stress2/misc/midi2.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/midi2.sh Thu Aug 29 09:29:39 2019 (r351602) @@ -0,0 +1,116 @@ +#!/bin/sh + +# +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2019 Dell EMC Isilon +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +# Test threaded access to /dev/midistat. + +# "panic: vm_fault_hold: fault on nofault entry, addr: 0x8b352000" seen. +# https://people.freebsd.org/~pho/stress/log/mark089.txt +# Fixed by 351262 + +. ../default.cfg +[ `id -u` -ne 0 ] && echo "Must be root!" && exit 1 + +dir=/tmp +odir=`pwd` +cd $dir +sed '1,/^EOF/d' < $odir/$0 > $dir/midi2.c +mycc -o midi2 -Wall -Wextra -O0 -g midi2.c -lpthread || exit 1 + +$dir/midi2 +s=$? +cat /dev/midistat > /dev/null || s=1 + +rm -rf midi2 midi2.c midi2.core +exit $s + +EOF +#include <sys/param.h> + +#include <machine/atomic.h> + +#include <err.h> +#include <errno.h> +#include <fcntl.h> +#include <pthread.h> +#include <stdio.h> +#include <stdlib.h> +#include <time.h> +#include <unistd.h> + +static volatile u_int share; +static int fd; +static char buf[0xbc59], buf2[0x40eddf]; + +#define THREADS 4 +#define RUNTIME (1 * 60) +#define SYNC 0 + +static void * +t1(void *data __unused) +{ + + atomic_add_int(&share, 1); + while (share != THREADS) + ; + + pread(fd, buf, 0xbc59, 0x27dbb298LL); + pread(fd, buf, 0xbc59, 0x104e35c6d22eLL); + pread(fd, buf2, 0x40eddf, 0x405d1df88cbf41LL); + + return (NULL); +} + +int +main(void) +{ + pthread_t tid[THREADS]; + time_t start; + int i, rc; + + if ((fd = open("/dev/midistat", O_RDONLY)) == -1) + err(1, "open(/dev/midistat)"); + start = time(NULL); + while ((time(NULL) - start) < RUNTIME) { + share = 0; + for (i = 0; i < THREADS; i++) { + if ((rc = pthread_create(&tid[i], NULL, t1, NULL)) != + 0) + errc(1, rc, "pthread_create"); + } + + for (i = 0; i < THREADS; i++) { + if ((rc = pthread_join(tid[i], NULL)) != 0) + errc(1, rc, "pthread_join"); + } + } + + return (0); +}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201908290929.x7T9Te4I034670>