Index: user/pho/stress2/misc/altbufferflushes.sh =================================================================== --- user/pho/stress2/misc/altbufferflushes.sh (revision 287324) +++ user/pho/stress2/misc/altbufferflushes.sh (revision 287325) @@ -1,101 +1,101 @@ #!/bin/sh # # Copyright (c) 2008 Peter Holm # 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. This script caused this panic: # panic: lockmgr: locking against myself # cpuid = 2 # KDB: enter: panic # [thread pid 2526 tid 100070 ] # Stopped at kdb_enter+0x2b: nop # db> bt # Tracing pid 2526 tid 100070 td 0xc46f8360 # kdb_enter(c094247f) at kdb_enter+0x2b # panic(c09402b6,c46f8360,0,12,c06af5d9,...) at panic+0x14b # _lockmgr(d864a748,202122,c479f788,c46f8360,c094b01c,12d) at _lockmgr+0x41a # getblk(c479f6b8,5d51940,0,4000,0,...) at getblk+0x13c # breadn(c479f6b8,5d51940,0,4000,0,...) at breadn+0x2f # bread(c479f6b8,5d51940,0,4000,0,e6d13544,c4743eac,0,c095a185,56d) at bread+0x20 # ffs_alloccg(c47408c4,104,1754628,0,4000,c4743eac,1,c095a185,4d8) at ffs_alloccg+0x11d # ffs_hashalloc(c47408c4,104,1754628,0,4000,...) at ffs_hashalloc+0x45 # ffs_alloc(c47408c4,3f2cd,0,1754628,0,4000,c42fd400,e6d13674) at ffs_alloc+0x1a5 # ffs_balloc_ufs2(c4735d70,fcb34000,0,4000,c42fd400,...) at ffs_balloc_ufs2+0x1619 # ffs_copyonwrite(c479f6b8,d84e3d08) at ffs_copyonwrite+0x3d3 # ffs_geom_strategy(c479f7c0,d84e3d08) at ffs_geom_strategy+0xbd # bufwrite(d84e3d08,4000,d84e3d08,e6d137e4,c070b7a9,...) at bufwrite+0x17a # ffs_bufwrite(d84e3d08) at ffs_bufwrite+0x282 # vfs_bio_awrite(d84e3d08) at vfs_bio_awrite+0x235 # bdwrite(d864a6e8,c4743eac,0,c095a185,57c,...) at bdwrite+0x237 # ffs_alloccg(c4b54a50,104,1754628,0,4000,c4743eac,1,c095a185,4d8) at ffs_alloccg+0x1f6 # ffs_hashalloc(c4b54a50,104,1754628,0,4000,...) at ffs_hashalloc+0x45 # ffs_alloc(c4b54a50,1b00c,0,1754628,0,4000,c4b22a80,e6d139ac) at ffs_alloc+0x1a5 # ffs_balloc_ufs2(c4e72158,6c030000,0,4000,c4b22a80,...) at ffs_balloc_ufs2+0x1619 # ffs_write(e6d13b98) at ffs_write+0x2ac # VOP_WRITE_APV(c0a00e80,e6d13b98) at VOP_WRITE_APV+0x132 # vn_write(c46c65a0,e6d13c60,c4b22a80,0,c46f8360) at vn_write+0x1f6 # dofilewrite(c46f8360,4,c46c65a0,e6d13c60,ffffffff,...) at dofilewrite+0x77 # kern_writev(c46f8360,4,e6d13c60,8430000,d0000,...) at kern_writev+0x36 # write(c46f8360,e6d13d00) at write+0x45 # syscall(e6d13d38) at syscall+0x256 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 persist () { false while [ $? -ne 0 ]; do $1 > /dev/null 2>&1 sleep 1 done } diskfree=`df -k /var/tmp | tail -1 | awk '{print $4}'` [ $((diskfree / 1024 / 1024)) -lt 5 ] && echo "Not enough disk space" && exit 1 rm -f /var/.snap/stress2 /var/tmp/big.? -trap "rm -f /var/.snap/stress2 /var/tmp/big.?" 0 +trap "rm -f /var/.snap/stress2 /var/tmp/big.?" EXIT SIGINT persist 'mksnap_ffs /var /var/.snap/stress2' tresh=`sysctl vfs.dirtybufthresh | awk '{print $NF}'` sysctl vfs.dirtybufthresh=10 cd /var/tmp for j in `jot 5`; do old=`sysctl vfs.altbufferflushes | awk '{print $NF}'` for i in `jot 4`; do echo "`date '+%T'` Create big.$i" dd if=/dev/zero of=big.$i bs=1m count=4k 2>&1 | egrep -v "records|transferred" done sleep 1 rm -rf /var/tmp/big.? new=`sysctl vfs.altbufferflushes | awk '{print $NF}'` [ $new -ne $old ] && echo "vfs.altbufferflushes changed from $old to $new." done sysctl vfs.dirtybufthresh=$tresh rm -f /var/.snap/stress2 Index: user/pho/stress2/misc/lockf.sh =================================================================== --- user/pho/stress2/misc/lockf.sh (revision 287324) +++ user/pho/stress2/misc/lockf.sh (revision 287325) @@ -1,59 +1,59 @@ #!/bin/sh # # Copyright (c) 2008 Peter Holm # 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$ # # Page fault seen: # http://people.freebsd.org/~pho/stress/log/lockf.txt [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg [ -z "$nfs_export" ] && exit 0 ping -c 2 `echo $nfs_export | sed 's/:.*//'` > /dev/null 2>&1 || exit 0 pgrep -q lockd || { echo "lockd not running"; exit 0; } -trap "rm -f /tmp/$0.$$.*" 0 +trap "rm -f /tmp/$0.$$.*" EXIT SIGINT mount | grep "$mntpoint" | grep nfs > /dev/null && umount $mntpoint for i in `jot 100`; do mount -t nfs -o tcp -o retrycnt=3 -o intr -o soft -o rw $nfs_export $mntpoint sleep 1 for j in `jot 50`; do lockf -t 10 $mntpoint/$0.$$.$j sleep 3 & done while mount | grep -q ${mntpoint}; do umount -f $mntpoint > /dev/null 2>&1 done wait done Index: user/pho/stress2/misc/lookup_shared.sh =================================================================== --- user/pho/stress2/misc/lookup_shared.sh (revision 287324) +++ user/pho/stress2/misc/lookup_shared.sh (revision 287325) @@ -1,41 +1,40 @@ #!/bin/sh # # Copyright (c) 2008-2011 Peter Holm # 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 saved=`sysctl vfs.lookup_shared | awk '{print $NF}'` +trap "sysctl vfs.lookup_shared=$saved" EXIT SIGINT export runRUNTIME=10m # Run tests for 10 minutes for i in 1 0; do sysctl vfs.lookup_shared=$i (cd ..; ./run.sh disk.cfg) done - -sysctl vfs.lookup_shared=$saved Index: user/pho/stress2/misc/overcommit2.sh =================================================================== --- user/pho/stress2/misc/overcommit2.sh (revision 287324) +++ user/pho/stress2/misc/overcommit2.sh (revision 287325) @@ -1,69 +1,68 @@ #!/bin/sh # # Copyright (c) 2014 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$ # # Test vm.overcommit. Variation of overcommit.sh # Use a swap backed MD disk with the size of 1.2 * hw.usermem. # Deadlock seen: https://people.freebsd.org/~pho/stress/log/alan007.txt [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ `swapinfo | wc -l` -eq 1 ] && exit 0 . ../default.cfg old=`sysctl -n vm.overcommit` [ $old -eq 1 ] && exit size=$((`sysctl -n hw.usermem` / 1024 / 1024)) # in MB size=$((size + size / 100 * 20)) # 120% of hw.usermem sysctl vm.overcommit=1 +trap "sysctl vm.overcommit=$old" EXIT SIGINT mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s ${size}m -u $mdstart bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint echo "Expect: -/mnt: write failed, filesystem is full -dd: /mnt/big.1: No space left on device" + /mnt: write failed, filesystem is full + dd: /mnt/big.1: No space left on device" for i in `jot 10`; do dd if=/dev/zero of=/mnt/big.$i bs=1m 2>&1 | \ egrep -v "records|transferred" & done wait while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart - -sysctl vm.overcommit=$old Index: user/pho/stress2/misc/signal.sh =================================================================== --- user/pho/stress2/misc/signal.sh (revision 287324) +++ user/pho/stress2/misc/signal.sh (revision 287325) @@ -1,236 +1,236 @@ #!/bin/sh # # Copyright (c) 2013 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$ # # Regression test for kern/150138: signal sent to stopped, traced process # not immediately handled on continue. # Fixed in r212047. # Test scenario by Dan McNulty . ../default.cfg here=`pwd` wd=/tmp/signal.dir rm -rf $wd mkdir -p $wd cd $wd cat > waitthread.c < #include #include #include #include #include #include #include #include #include #include #include #include struct threadArg { int id; pthread_mutex_t *mutex; }; void *entry(void *arg) { struct threadArg *thisArg = (struct threadArg *)arg; long lwp_id = thisArg->id; if( syscall(SYS_thr_self, &lwp_id) ) { perror("syscall"); } printf("%ld waiting on lock\n", lwp_id); if( pthread_mutex_lock(thisArg->mutex) != 0 ) { perror("pthread_mutex_lock"); return NULL; } printf("%ld obtained lock\n", lwp_id); if( pthread_mutex_unlock(thisArg->mutex) != 0 ) { perror("pthread_mutex_unlock"); return NULL; } printf("%ld released lock\n", lwp_id); return NULL; } int main(int argc, char **argv) { if( 2 != argc ) { printf("Usage: %s \n", argv[0]); return EXIT_FAILURE; } printf("%d\n", getpid()); int numThreads; sscanf(argv[1], "%d", &numThreads); if( numThreads < 1 ) numThreads = 1; pthread_t *threads = (pthread_t *)malloc(sizeof(pthread_t)*numThreads); pthread_mutex_t *mutex = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t)); if( pthread_mutex_init(mutex, NULL) != 0 ) { perror("pthread_mutex_init"); return EXIT_FAILURE; } if( pthread_mutex_lock(mutex) != 0 ) { perror("pthread_mutex_lock"); return EXIT_FAILURE; } int i; for(i = 0; i < numThreads; ++i) { struct threadArg *arg = (struct threadArg *)malloc(sizeof(struct threadArg)); arg->id = i; arg->mutex = mutex; assert( !pthread_create(&threads[i], NULL, &entry, (void *)arg) ); } // Wait on the named pipe unlink("/tmp/waitthread"); if( mkfifo("/tmp/waitthread", S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) ) { perror("mkfifo"); return EXIT_FAILURE; } FILE *fifo; do { if( (fifo = fopen("/tmp/waitthread", "r")) == NULL ) { if( errno == EINTR ) continue; perror("fopen"); return EXIT_FAILURE; } break; }while(1); unsigned char byte; if( fread(&byte, sizeof(unsigned char), 1, fifo) != 1 ) { perror("fread"); } fclose(fifo); unlink("/tmp/waitthread"); printf("Received notification\n"); if( pthread_mutex_unlock(mutex) != 0 ) { perror("pthread_mutex_unlock"); return EXIT_FAILURE; } printf("Unlocked mutex, joining\n"); for(i = 0; i < numThreads; ++i ) { assert( !pthread_join(threads[i], NULL) ); } return EXIT_SUCCESS; } EOF cat > tkill.c < #include #include #include #include #include int main(int argc, char *argv[]) { if( argc != 4 ) { printf("Usage: %s \n", argv[0]); return EXIT_FAILURE; } pid_t pid; sscanf(argv[1], "%d", &pid); long id; sscanf(argv[2], "%ld", &id); int sig; sscanf(argv[3], "%d", &sig); if( syscall(SYS_thr_kill2, pid, id, sig) ) { perror("syscall"); } return EXIT_SUCCESS; } EOF mycc -o waitthread -Wall -Wextra waitthread.c -lpthread || exit mycc -o tkill -Wall -Wextra tkill.c || exit rm -f waitthread.c tkill.c rm -f gdbfifo gdbout pstat /tmp/waitthread ps | grep -v grep | grep waitthread | awk '{print $1}' | xargs kill mkfifo gdbfifo -trap "rm -f gdbfifo" 0 +trap "rm -f gdbfifo" EXIT SIGINT sleep 300 > gdbfifo & # Keep the fifo open fifopid=$! gdb ./waitthread < gdbfifo > gdbout 2>&1 & gdbpid=$! echo "set args 8" > gdbfifo echo "run" > gdbfifo sleep .5 pid=`ps | grep -v grep | grep "waitthread 8" | sed 's/^ *//;s/ .*//'` if [ -n "$pid" ]; then procstat -t $pid > pstat t1=`grep fifo pstat | awk '{print $2}'` t2=`grep umtxn pstat | awk '{print $2}' | tail -1` ./tkill $pid $t1 5 # SIGTRAP ./tkill $pid $t2 2 # SIGINT echo "c" > gdbfifo echo "quit" > gdbfifo sleep 1 grep -q "signal SIGINT" gdbout || echo FAIL else echo "Did not find pid for test program waitthread" fi kill $fifopid $gdbpid > /dev/null 2>&1 ps | grep -v grep | grep waitthread | awk '{print $1}' | xargs kill cd $here rm -rf $wd /tmp/waitthread