From owner-svn-src-user@freebsd.org Thu Aug 29 09:29:40 2019 Return-Path: Delivered-To: svn-src-user@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B0C35D085E for ; Thu, 29 Aug 2019 09:29:40 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46Jy4N4D0bz4RMb; Thu, 29 Aug 2019 09:29:40 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 73EA71DDAF; Thu, 29 Aug 2019 09:29:40 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7T9TeDa034671; Thu, 29 Aug 2019 09:29:40 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7T9Te4I034670; Thu, 29 Aug 2019 09:29:40 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201908290929.x7T9Te4I034670@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Thu, 29 Aug 2019 09:29:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r351602 - user/pho/stress2/misc X-SVN-Group: user X-SVN-Commit-Author: pho X-SVN-Commit-Paths: user/pho/stress2/misc X-SVN-Commit-Revision: 351602 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Aug 2019 09:29:40 -0000 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 + +# 'panic: vm_fault_hold: fault on nofault entry, addr: 0x33522000' seen. +# Fixed by 351262 + +# $FreeBSD$ + +cat > /tmp/midi.c < +#include +#include +#include +#include +#include + +#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 + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +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); +}