Index: user/pho/stress2/misc/mmap4.sh =================================================================== --- user/pho/stress2/misc/mmap4.sh (revision 319207) +++ user/pho/stress2/misc/mmap4.sh (revision 319208) @@ -1,117 +1,118 @@ #!/bin/sh # # Copyright (c) 2010 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$ # # Test overcommit of the file system capacity # Causes panic: 1 vncache entries remaining # Fixed in r202529 # Scenario by kib@ [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > mmap4.c mycc -o mmap4 -Wall -O2 mmap4.c rm -f mmap4.c mount | grep -q "$mntpoint" && umount $mntpoint mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 40m -u $mdstart bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint /tmp/mmap4 /$mntpoint/file cd $here rm -f /tmp/mmap4 while mount | grep -q $mntpoint; do sync;sync;sync sleep 1 umount $mntpoint done mdconfig -d -u $mdstart exit 0 EOF #include #include #include #include #include #include #include #include #include #include #include #define STARTADDR 0x0U #define ADRSPACE 0x06400000U /* 100 Mb */ int main(int argc, char **argv) { int fd, ps; void *p; size_t len; - char *c, *path; + volatile char *c; + char *path; p = (void *)STARTADDR; len = ADRSPACE; path = argv[1]; if ((fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0622)) == -1) err(1,"open()"); if (ftruncate(fd, len) == -1) err(1, "ftruncate"); if ((p = mmap(p, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) { if (errno == ENOMEM) return (1); err(1, "mmap(1)"); } c = p; ps = getpagesize(); for (c = p; (void *)c < p + len; c += ps) { *c = 1; } close(fd); return (0); } Index: user/pho/stress2/misc/stealer.sh =================================================================== --- user/pho/stress2/misc/stealer.sh (revision 319207) +++ user/pho/stress2/misc/stealer.sh (revision 319208) @@ -1,133 +1,133 @@ #!/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$ # # Process stuck in objtrm wait state # http://people.freebsd.org/~pho/stress/log/stealer.txt # Fixed in r263328. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > stealer.c mycc -o stealer -Wall -Wextra stealer.c || exit 1 rm -f stealer.c cd $here swapoff -a > /dev/null dd if=/dev/zero of=$diskimage bs=1m count=1k 2>&1 | egrep -v 'records|transferred' mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t vnode -f $diskimage -u $mdstart swapon /dev/md$mdstart hw=`sysctl hw.pagesize | sed 's/.*: //'` pages=`sysctl hw.usermem | sed 's/.*: //'` pages=$((pages / hw)) echo "`date '+%T'` Test with $pages pages." su $testuser -c "sh -c \"/tmp/stealer $pages\"" & sleep 30 while swapinfo | grep -q /dev/md$mdstart; do swapoff /dev/md$mdstart 2>&1 | grep -v "Cannot allocate memory" sleep 2 done ps auxwwl | grep -v grep | grep objtrm && echo FAIL wait swapon -a > /dev/null mdconfig -d -u $mdstart rm -rf /tmp/stealer $diskimage exit 0 EOF #include #include #include #include #include #include #define N 200 void handler(int i __unused) { _exit(0); } void stealer(int pages) { - char *c; + volatile char *c; int i, page, size; page = getpagesize(); size = pages * page; if ((c = malloc(size)) == 0) err(1, "malloc(%d pages)", pages); signal(SIGALRM, handler); alarm(3 * 60); for (;;) { i = 0; while (i < size) { c[i] = 0; i += page; } } } int main(int argc __unused, char **argv) { int i, j, n, pages, status; pages = atoi(argv[1]); n = pages / N; j = 0; for ( i = 0; i < N; i++, j++) { if (fork() == 0) stealer(n); pages = pages - n; } if (pages > 0) { j++; if (fork() == 0) stealer(pages); } while (j-- > 0) if (wait(&status) == -1) err(1, "wait()"); return (0); } Index: user/pho/stress2/misc/swap.sh =================================================================== --- user/pho/stress2/misc/swap.sh (revision 319207) +++ user/pho/stress2/misc/swap.sh (revision 319208) @@ -1,154 +1,154 @@ #!/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$ # # Swap test. Variation of testcases/swap. . ../default.cfg dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/swap.c mycc -o swap -Wall -Wextra -O2 swap.c || exit 1 rm -f swap.c usermem=`sysctl hw.usermem | sed 's/.* //'` swap=`sysctl vm.swap_total | sed 's/.* //'` if [ $swap -gt 0 ]; then size=$((usermem/10*11)) else size=$((usermem/10*9)) fi /tmp/swap $((size / 4096)) rm -f /tmp/swap exit EOF #include #include #include #include #include #include #include #include #include #define RUNTIME (5 * 60) #define INCARNATIONS 32 static unsigned long size, original; void setup(void) { struct rlimit rlp; size = size / INCARNATIONS; original = size; if (size == 0) errx(1, "Argument too small"); if (getrlimit(RLIMIT_DATA, &rlp) < 0) err(1,"getrlimit"); rlp.rlim_cur -= 1024 * 1024; if (size > (unsigned long)rlp.rlim_cur) size = rlp.rlim_cur; #if 0 printf("setup: pid %d. Total %luMb\n", getpid(), size / 1024 / 1024 * INCARNATIONS); #endif if (size == 0) errx(1, "Argument too small"); return; } int test(void) { - char *c; + volatile char *c; int page; unsigned long i, j; time_t start; c = malloc(size); while (c == NULL) { size -= 1024 * 1024; c = malloc(size); } if (size != original) printf("Malloc size changed from %ld Mb to %ld Mb\n", original / 1024 / 1024, size / 1024 / 1024); page = getpagesize(); start = time(NULL); while ((time(NULL) - start) < RUNTIME) { i = j = 0; while (i < size) { c[i] = 0; i += page; if (++j % 1024 == 0) { if ((time(NULL) - start) >= RUNTIME) break; if (arc4random() % 100 < 5) usleep(1000); } } } - free(c); + free((void *)c); _exit(0); } int main(int argc, char **argv) { int i; if (argc != 2) errx(1, "Usage: %s bytes", argv[0]); size = atol(argv[1]) * 4096; setup(); for (i = 0; i < INCARNATIONS; i++) if (fork() == 0) test(); for (i = 0; i < INCARNATIONS; i++) wait(NULL); return (0); } Index: user/pho/stress2/misc/swap2.sh =================================================================== --- user/pho/stress2/misc/swap2.sh (revision 319207) +++ user/pho/stress2/misc/swap2.sh (revision 319208) @@ -1,179 +1,179 @@ #!/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$ # # Swap test. Variation of swap.sh # panic: vm_radix_remove: impossible to locate the key # panic: vm_page_alloc: cache page 0xff... is missing from the free queue # panic: vm_radix_node_put: rnode 0xfffffe00099035a0 has a child # panic: vm_radix_remove: impossible to locate the key [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg 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 2g -u $mdstart bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint chmod 777 $mntpoint export runRUNTIME=30m export RUNDIR=$mntpoint/stressX rm -rf /tmp/stressX.control dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/swap2.c mycc -o swap2 -Wall -Wextra -O2 swap2.c || exit 1 rm -f swap2.c cd $odir usermem=`sysctl -n hw.usermem` swap=`sysctl -n vm.swap_total` if [ $swap -gt 0 ]; then size=$((usermem/10*11)) else size=$((usermem/10*8)) fi /tmp/swap2 $((size / 4096)) & sleep 30 su $testuser -c "(cd ../testcases/rw; ./rw -t 3m -i 40 -l 100 -v -h -h)" & wait while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/swap2 exit EOF #include #include #include #include #include #include #include #include #include #define RUNTIME (5 * 60) #define INCARNATIONS 32 static unsigned long size, original; void setup(void) { struct rlimit rlp; size = size / INCARNATIONS; original = size; if (size == 0) errx(1, "Argument too small"); if (getrlimit(RLIMIT_DATA, &rlp) < 0) err(1,"getrlimit"); rlp.rlim_cur -= 1024 * 1024; if (size > (unsigned long)rlp.rlim_cur) size = rlp.rlim_cur; #if 0 printf("setup: pid %d. Total %luMb\n", getpid(), size / 1024 / 1024 * INCARNATIONS); #endif if (size == 0) errx(1, "Argument too small"); return; } int test(void) { - char *c; + volatile char *c; int page; unsigned long i, j; time_t start; c = malloc(size); while (c == NULL) { size -= 1024 * 1024; c = malloc(size); } if (size != original) printf("Malloc size changed from %ld Mb to %ld Mb\n", original / 1024 / 1024, size / 1024 / 1024); page = getpagesize(); start = time(NULL); while ((time(NULL) - start) < RUNTIME) { i = j = 0; while (i < size) { c[i] = 0; i += page; if (++j % 1024 == 0) { if ((time(NULL) - start) >= RUNTIME) break; if (arc4random() % 100 < 5) usleep(1000); } } } - free(c); + free((void *)c); _exit(0); } int main(int argc, char **argv) { int i; if (argc != 2) errx(1, "Usage: %s bytes", argv[0]); size = atol(argv[1]) * 4096; setup(); for (i = 0; i < INCARNATIONS; i++) if (fork() == 0) test(); for (i = 0; i < INCARNATIONS; i++) wait(NULL); return (0); } Index: user/pho/stress2/testcases/swap/swap.c =================================================================== --- user/pho/stress2/testcases/swap/swap.c (revision 319207) +++ user/pho/stress2/testcases/swap/swap.c (revision 319208) @@ -1,148 +1,148 @@ /*- * 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. * */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include "stress.h" #if defined(__LP64__) #define MINLEFT (1792LL * 1024 * 1024) #else #define MINLEFT (1024LL * 1024 * 1024) #endif static unsigned long size; int setup(int nb) { struct rlimit rlp; int64_t swapinfo; unsigned long mem; int pct; if (nb == 0) { mem = usermem(); swapinfo = swap(); pct = 0; if (op->hog == 0) pct = random_int(80, 100); if (op->hog == 1) pct = random_int(100, 110); if (op->hog == 2) pct = random_int(110, 120); if (op->hog >= 3) pct = random_int(120, 130); if (swapinfo == 0) { pct = random_int(30, 50); if (mem <= MINLEFT) _exit(1); mem -= MINLEFT; size = mem / 100 * pct; } else { size = mem / 100 * pct; if (size > mem + swapinfo / 4) { size = mem + swapinfo / 4; pct = size * 100 / mem; } } size = size / op->incarnations; if (getrlimit(RLIMIT_DATA, &rlp) < 0) err(1,"getrlimit"); rlp.rlim_cur -= 1024 * 1024; if (size > (unsigned long)rlp.rlim_cur) size = rlp.rlim_cur; putval(size); if (op->verbose > 1 && nb == 0) printf("setup: pid %d, %d%%. Total %luMb\n", getpid(), pct, size / 1024 / 1024 * op->incarnations); } else size = getval(); return (0); } void cleanup(void) { } int test(void) { time_t start; unsigned long i, oldsize; int page; - char *c; + volatile char *c; oldsize = size; c = malloc(size); while (c == NULL && done_testing == 0) { size -= 1024 * 1024; c = malloc(size); } if (op->verbose > 1 && size != oldsize) printf("Malloc size changed from %ld Mb to %ld Mb\n", oldsize / 1024 / 1024, size / 1024 / 1024); page = getpagesize(); start = time(NULL); /* Livelock workaround */ while (done_testing == 0 && (time(NULL) - start) < op->run_time) { i = 0; while (i < size && done_testing == 0) { c[i] = 0; i += page; } #if 0 if (op->hog != 1) usleep(1000); #endif } - free(c); + free((void *)c); return (0); }