Index: user/pho/stress2/misc/context.sh =================================================================== --- user/pho/stress2/misc/context.sh (revision 330998) +++ user/pho/stress2/misc/context.sh (revision 330999) @@ -1,132 +1,132 @@ #!/bin/sh # # Copyright (c) 2016 EMC Corp. # All rights reserved. # # 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$ # . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > context.c mycc -o context -Wall -Wextra -O2 -g context.c || exit 1 rm -f context.c [ -d $RUNDIR ] || mkdir -p $RUNDIR cd $RUNDIR daemon sh -c "(cd $here/../testcases/swap; ./swap -t 10m -i 20)" > \ /dev/null 2>&1 for i in `jot 4`; do /tmp/context & pids="$pids $!" done s=0 for i in $pids; do wait $i [ $? -ne 0 ] && s=$((s + 1)) done while pgrep -q swap; do pkill -9 swap done rm -f /tmp/context exit $s EOF /* * Inspired by lmbench-3.0-a9/src/lat_ctx.c * Pass a token thru pipes to CHILDREN+1 processes in a circular list */ #include #include #include #include #include #include #include #include #define CHILDREN 64 #define RUNTIME 300 int fds[CHILDREN +1 ][2]; pid_t pid[CHILDREN]; void handler(int s __unused) { _exit(0); } int main(void) { time_t start; int i, j; int token; for (i = 0; i < CHILDREN + 1; i++) { if (pipe(fds[i]) == -1) err(1, "pipe"); } signal(SIGHUP, handler); start = time(NULL); for (i = 0; i < CHILDREN; i++) { pid[i] = fork(); if (pid[i] == -1) { perror("fork"); exit(2); } if (pid[i] == 0) { /* child */ for (;;) { if (read(fds[i][0], &token, sizeof(token)) != sizeof(token)) err(1, "read pipe 2"); if (write(fds[i+1][1], &token, sizeof(token)) != sizeof(token)) err(1, "write pipe 1"); } } - } /* parent */ + } /* parent */ for (j = 0; time(NULL) - start < RUNTIME; j++) { token = j; if (write(fds[0][1], &token, sizeof(token)) != sizeof(token)) err(1, "write pipe 2"); if (read(fds[CHILDREN][0], &token, sizeof(token)) != sizeof(token)) err(1, "read pipe 1"); } for (i = 0; i < CHILDREN; i++) kill(pid[i], SIGHUP); return (0); } Index: user/pho/stress2/misc/graid1_3.sh =================================================================== --- user/pho/stress2/misc/graid1_3.sh (revision 330998) +++ user/pho/stress2/misc/graid1_3.sh (revision 330999) @@ -1,94 +1,94 @@ #!/bin/sh # # Copyright (c) 2017 Dell EMC Isilon # All rights reserved. # # 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$ # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Test scenario by Mark Johnston # Page fault seen: # https://people.freebsd.org/~pho/stress/log/graid1_3.txt . ../default.cfg gmirror load > /dev/null 2>&1 && unload=1 [ -c /dev/mirror/markj-mirror ] && { gmirror stop markj-mirror; gmirror destroy markj-mirror; } old=`sysctl -n kern.geom.mirror.debug` sysctl kern.geom.mirror.debug=-1 | grep -q -- -1 || sysctl kern.geom.mirror.debug=$old > /dev/null u1=$mdstart u2=$((mdstart + 1)) size=$((5 * 1024 * 1024)) for u in $u1 $u2; do dd if=/dev/zero of=/tmp/graid1_2_di$u bs=$size count=1 2>&1 | \ egrep -v "records|transferred" [ -c /dev/md$u ] && mdconfig -d -u $u mdconfig -a -t vnode -f /tmp/graid1_2_di$u -u $u done set -e ( gpart create -s GPT md$u1 gpart create -s GPT md$u2 gpart add -t freebsd-ufs -s 1M md$u1 gpart add -t freebsd-ufs -s 1M md$u2 ) > /dev/null gmirror label markj-mirror md${u1}p1 set +e while true; do gmirror label markj-mirror md${u1}p1 - gmirror destroy markj-mirror + gmirror destroy markj-mirror done 2>/dev/null & pid1=$! while true; do gmirror insert markj-mirror md${u2}p1 gmirror remove markj-mirror md${u2}p1 done 2>/dev/null & pid2=$! for i in `jot 60`; do gmirror list markj-mirror sleep 1 done > /dev/null 2>&1 sleep 60 kill $pid1 $pid2 wait sleep 1 gmirror remove markj-mirror md${u2}p1 > /dev/null 2>&1 gmirror destroy markj-mirror > /dev/null 2>&1 mdconfig -d -u $u1 || exit 1 mdconfig -d -u $u2 || exit 1 rm -f /tmp/graid1_2_di* exit 0 Index: user/pho/stress2/misc/kevent9.sh =================================================================== --- user/pho/stress2/misc/kevent9.sh (revision 330998) +++ user/pho/stress2/misc/kevent9.sh (revision 330999) @@ -1,206 +1,206 @@ #!/bin/sh # $FreeBSD$ # Test scenario by Eric Badger # userret: returning with the following locks held: # exclusive sleep mutex process lock (process lock) r = 0 (0xcb714758) # locked @ kern/kern_event.c:2125 # panic: witness_warn # https://people.freebsd.org/~pho/stress/log/kevent9.txt # Fixed in r302235. . ../default.cfg [ `sysctl -n hw.ncpu` -ne 4 ] && echo "For best results use hw.ncpu == 4" cd /tmp cat > /tmp/kevent9-1.c < #include #include #include #include #include #include #include #include #include #include #include #include #define NUM_PROCS 4000 void *procmaker(void *arg __unused) { pthread_set_name_np(pthread_self(), "procmaker"); for (int i = 0; i < NUM_PROCS; ++i) { struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = 50000; nanosleep(&ts, NULL); switch(fork()) { case -1: err(1, "fork"); break; case 0: execl("./kevent9-2", "kevent9-2", NULL); _exit(127); break; default: break; } } printf("done forking\n"); - return NULL; + return NULL; } void *reaper(void *arg __unused) { pthread_set_name_np(pthread_self(), "reaper"); int counter = 0; while (counter < NUM_PROCS) { int status; if (wait(&status) > 0) { ++counter; } } printf("Reaped %d\n", counter); return NULL; } int main() { pthread_set_name_np(pthread_self(), "main"); int kqfd = kqueue(); if (kqfd == -1) { err(1, "kqueue()"); } struct kevent change; memset(&change, 0, sizeof(change)); change.ident = getpid(); change.filter = EVFILT_PROC; change.flags = EV_ADD | EV_ENABLE; change.fflags = NOTE_EXIT | NOTE_EXEC | NOTE_FORK | NOTE_TRACK; if (kevent(kqfd, &change, 1, NULL, 0, NULL) == -1) { err(1, "kevent change"); } pthread_t t; pthread_create(&t, NULL, procmaker, NULL); pthread_create(&t, NULL, reaper, NULL); int numexecs = 0; int numexits = 0; int numforks = 0; int nummults = 0; int numchlds = 0; int numterrs = 0; while (1) { struct kevent event; struct timespec to; to.tv_sec = 1; to.tv_nsec = 0; int ret = kevent(kqfd, NULL, 0, &event, 1, &to); if (ret == -1) { err(1, "kevent event"); } else if (ret == 0) { printf("numexecs: %d numexits: %d numforks: %d numchlds: %d numterrs: %d nummults: %d\n", numexecs, numexits, numforks, numchlds, numterrs, nummults); // Sometimes we miss a NOTE_EXIT. If it hasn't arrived by the timeout, bail out since // it will probably never arrive. break; /* if (numexits == NUM_PROCS) { break; } else { continue; } */ } int numflags = 0; if (event.fflags & NOTE_EXEC) { ++numflags; ++numexecs; } if (event.fflags & NOTE_EXIT) { ++numflags; ++numexits; } if (event.fflags & NOTE_FORK) { ++numflags; ++numforks; } if (event.fflags & NOTE_CHILD) { ++numflags; ++numchlds; } if (event.fflags & NOTE_TRACKERR) { ++numflags; ++numterrs; } if (numflags > 1) { ++nummults; } /* struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = 50000; nanosleep(&ts, NULL); */ } return 0; } EOF cat > /tmp/kevent9-2.c < int main() { struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = 1000; nanosleep(&ts, NULL); return 0; } EOF mycc -o kevent9-1 -Wall -Wextra -O2 -g kevent9-1.c -lpthread || exit 1 mycc -o kevent9-2 -Wall -Wextra -O2 -g kevent9-2.c || exit 1 rm kevent9-1.c kevent9-2.c start=`date '+%s'` while [ $((`date '+%s'` - start)) -lt 300 ]; do ./kevent9-1 > /dev/null done rm kevent9-1 kevent9-2 Index: user/pho/stress2/misc/marcus4.sh =================================================================== --- user/pho/stress2/misc/marcus4.sh (revision 330998) +++ user/pho/stress2/misc/marcus4.sh (revision 330999) @@ -1,82 +1,82 @@ #!/bin/sh # # Copyright (c) 2015 EMC Corp. # All rights reserved. # # 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$ # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Copy of marcus3.sh, but without the VM (page stealer) pressure. # Deadlock and "panic: smp_targeted_tlb_shootdown: interrupts disabled" # https://people.freebsd.org/~pho/stress/log/marcus4.txt # "panic: spin lock held too long" seen. # Fixed in r313472. . ../default.cfg pgrep -q watchdogd && { service watchdogd stop > /dev/null && restart=1; } dev=$(df -h `dirname $RUNDIR` | tail -1 | awk '{print $1}') mount | grep $dev | grep -q journaled && exit 0 size=$((`sysctl -n hw.physmem` / 1024 / 1024)) [ $size -gt $((4 * 1024)) ] && { echo "RAM should be capped to 4GB for this test."; } [ "`sysctl -n debug.deadlkres.sleepfreq 2>/dev/null`" = "3" ] && { echo "deadlkres must be disabled for this test."; exit 0; } n=`find ../testcases -perm -1 -type f | wc -l` m=`su $testuser -c "limits | grep maxprocesses | awk '{print \\$NF}'"` m=$((m / 2)) export INCARNATIONS=$((m / n)) export runRUNTIME=15m export LOAD=80 export symlinkLOAD=80 export rwLOAD=80 export TESTPROGS=" testcases/lockf2/lockf2 testcases/symlink/symlink testcases/openat/openat testcases/rw/rw testcases/fts/fts testcases/link/link testcases/lockf/lockf testcases/creat/creat testcases/mkdir/mkdir testcases/rename/rename testcases/mkfifo/mkfifo " su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' & sleep $((16 * 60)) ../tools/killall.sh wait ./cleanup.sh -[ $restart ] && service watchdogd start > /dev/null +[ $restart ] && service watchdogd start > /dev/null exit 0 Index: user/pho/stress2/misc/shm.sh =================================================================== --- user/pho/stress2/misc/shm.sh (revision 330998) +++ user/pho/stress2/misc/shm.sh (revision 330999) @@ -1,203 +1,203 @@ #!/bin/sh # # Copyright (c) 2016 Dell EMC Isilon # All rights reserved. # # 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$ # # Regression test for r310849. Hang in "vmpfw" was seen. # Test scenario suggestion by kib. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg RUNTIME=60 old=`sysctl -n kern.ipc.shm_use_phys` trap "sysctl kern.ipc.shm_use_phys=$old" EXIT INT sysctl kern.ipc.shm_use_phys=1 dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/shm.c mycc -o shm -Wall -Wextra -O0 -g shm.c -pthread || exit 1 rm -f shm.c /tmp/shm & s=0 sleep $RUNTIME if pgrep -q shm; then if pgrep shm | xargs ps -lHp | grep -q vmpfw; then s=1 echo FAIL pgrep shm | xargs ps -lHp pkill -9 shm fi fi wait rm -rf /tmp/shm exit $s EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void *shmp; static size_t len; static int cont, shmid; #define PAGES 64 #define RUNTIME (1 * 60) #define STOP 1 #define SYNC 0 static void cleanup(void) { if (shmp != MAP_FAILED) shmdt(shmp); if (shmid != 0) shmctl(shmid, IPC_RMID, NULL); } static void * t1(void *arg __unused) { time_t start; char *cp; pthread_set_name_np(pthread_self(), __func__); start = time(NULL); while (cont == 1 && (time(NULL) - start) < RUNTIME) { if ((cp = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED) err(1, "mmap"); usleep(arc4random() % 400); if (munmap(cp, len) == -1) warn("unmap(%p, %zu)", shmp, len); } return (NULL); } static void * t2(void *arg __unused) { key_t shmkey; - size_t i; + size_t i; time_t start; char *cp; pthread_set_name_np(pthread_self(), __func__); shmkey = ftok("/tmp", getpid()); start = time(NULL); atexit(cleanup); while ((time(NULL) - start) < RUNTIME) { if ((shmid = shmget(shmkey, len, IPC_CREAT | IPC_EXCL | 0640)) == -1) { if (errno != ENOSPC && errno != EEXIST) err(1, "shmget (%s:%d)", __FILE__, __LINE__); break; } if ((shmp = shmat(shmid, NULL, 0)) == (void *) -1) break; cp = (char *)(shmp); for (i = 0; i < len; i = i + PAGE_SIZE) cp[i] = 1; if (shmdt(shmp) == -1) { if (errno != EINVAL) warn("shmdt(%p)", shmp); } if (shmctl(shmid, IPC_RMID, NULL) == -1) warn("shmctl IPC_RMID"); usleep(50); shmp = MAP_FAILED; shmid = 0; } cont = 0; return (NULL); } static int test(void) { pthread_t tid[2]; int i, rc; shmp = MAP_FAILED; cont = 1; if ((rc = pthread_create(&tid[0], NULL, t1, NULL)) != 0) errc(1, rc, "pthread_create()"); if ((rc = pthread_create(&tid[1], NULL, t2, NULL)) != 0) errc(1, rc, "pthread_create()"); for (i = 0; i < 2; i++) if ((rc = pthread_join(tid[i], NULL)) != 0) errc(1, rc, "pthread_join(%d)", i); return (0); } int main(void) { pid_t pid; time_t start; len = PAGES * PAGE_SIZE; start = time(NULL); while ((time(NULL) - start) < RUNTIME) { if ((pid = fork()) == 0) { test(); exit(0); /* calls cleanup() */ } if (waitpid(pid, NULL,0) != pid) err(1, "waitpid(%d)", pid); } return(0); }