svn commit: r358571 - user/pho/stress2/misc
Peter Holm
pho at FreeBSD.org
Tue Mar 3 10:03:00 UTC 2020
Author: pho
Date: Tue Mar 3 10:02:58 2020
New Revision: 358571
URL: https://svnweb.freebsd.org/changeset/base/358571
Log:
Added new tests all marked as "no run" for now.
Added:
user/pho/stress2/misc/force.sh (contents, props changed)
user/pho/stress2/misc/force2.sh (contents, props changed)
user/pho/stress2/misc/force3.sh (contents, props changed)
user/pho/stress2/misc/force4.sh (contents, props changed)
user/pho/stress2/misc/force5.sh (contents, props changed)
user/pho/stress2/misc/getrandom2.sh (contents, props changed)
Modified:
user/pho/stress2/misc/all.sh
Modified: user/pho/stress2/misc/all.sh
==============================================================================
--- user/pho/stress2/misc/all.sh Tue Mar 3 09:51:53 2020 (r358570)
+++ user/pho/stress2/misc/all.sh Tue Mar 3 10:02:58 2020 (r358571)
@@ -42,10 +42,16 @@
# collapse.sh panic: freeing mapped page 0xfffffe0028ed1d50 20200106
# dd.sh CAM stuck in vmwait 20200116
# devfs4.sh WiP 20181031
+# force.sh WiP 20200303
+# force2.sh WiP 20200303
+# force3.sh WiP 20200303
+# force4.sh Known issue 20200303
+# force5.sh WiP 20200303
# fsync.sh panic: Journal overflow 20190208
# fuse.sh Memory corruption seen in log file kostik734.txt 20141114
# fuse2.sh Deadlock seen 20121129
# fuse3.sh Deadlock seen 20141120
+# getrandom2.sh Known DoS issue 20200302
# gjournal.sh panic: Journal overflow 20190626
# gjournal2.sh panic: Journal overflow 20180125
# gjournal3.sh panic: Bio not on queue 20171225
Added: user/pho/stress2/misc/force.sh
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/pho/stress2/misc/force.sh Tue Mar 3 10:02:58 2020 (r358571)
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+#
+# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+#
+# Copyright (c) 2020 Peter Holm
+#
+# 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$
+#
+
+# "mdconfig -o force" test scenario.
+# Run with marcus.cfg on a 1g swap backed MD with UFS SU fs.
+
+# Page fault seen in WiP kernel code:
+# https://people.freebsd.org/~pho/stress/log/kirk113.txt
+
+[ `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 1g -u $mdstart
+flags=$newfs_flags
+[ `jot -r 1 0 1` -eq 1 ] && flags="-j"
+echo "newfs $flags md$mdstart"
+newfs $flags md$mdstart > /dev/null
+mount /dev/md$mdstart $mntpoint
+chmod 777 $mntpoint
+
+export runRUNTIME=3m
+export RUNDIR=$mntpoint/stressX
+
+su $testuser -c 'cd ..; ./run.sh marcus.cfg' > /dev/null 2>&1 &
+
+sleep `jot -r 1 10 40`
+while mdconfig -l | grep md$mdstart; do
+ mdconfig -d -u $mdstart -o force || sleep 1
+done
+sleep 1
+../tools/killall.sh
+wait
+n=0
+while mount | grep $mntpoint | grep -q /dev/md; do
+ umount $mntpoint || sleep 1
+ [ $((n += 1)) -gt 300 ] && { echo FAIL; exit 1; }
+done
+exit $s
Added: user/pho/stress2/misc/force2.sh
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/pho/stress2/misc/force2.sh Tue Mar 3 10:02:58 2020 (r358571)
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+#
+# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+#
+# Copyright (c) 2020 Peter Holm
+#
+# 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$
+#
+
+# "mdconfig -o force" test scenario.
+# Run with marcus.cfg on a 1g swap backed MD with UFS SU fs.
+
+[ `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
+dd if=/dev/zero of=$diskimage bs=1m count=1k status=none || exit 1
+mdconfig -a -t vnode -f $diskimage -u $mdstart
+flags=$newfs_flags
+[ `jot -r 1 0 1` -eq 1 ] && flags="-j"
+echo "newfs $flags md$mdstart"
+newfs $flags md$mdstart > /dev/null
+mount /dev/md$mdstart $mntpoint
+chmod 777 $mntpoint
+
+export runRUNTIME=3m
+export RUNDIR=$mntpoint/stressX
+
+su $testuser -c 'cd ..; ./run.sh marcus.cfg' > /dev/null 2>&1 &
+
+sleep `jot -r 1 10 40`
+while mdconfig -l | grep md$mdstart; do
+ mdconfig -d -u $mdstart -o force || sleep 1
+done
+sleep 1
+../tools/killall.sh
+wait
+n=0
+while mount | grep $mntpoint | grep -q /dev/md; do
+ umount $mntpoint || sleep 1
+ [ $((n += 1)) -gt 300 ] && { echo FAIL; exit 1; }
+done
+
+mdconfig -a -t vnode -f $diskimage -u $mdstart
+fsck_ffs -Rfy /dev/md$mdstart > /dev/null; s=$?
+if [ $s -eq 0 ]; then
+ mount /dev/md$mdstart $mntpoint
+ ls -lR $mntpoint > /dev/null
+ umount $mntpoint
+fi
+mdconfig -d -u $mdstart
+
+rm -f $diskimage
+exit $s
Added: user/pho/stress2/misc/force3.sh
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/pho/stress2/misc/force3.sh Tue Mar 3 10:02:58 2020 (r358571)
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+#
+# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+#
+# Copyright (c) 2020 Peter Holm
+#
+# 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
+
+# "mdconfig -o force" test scenario.
+# Copy of force.sh with an added "umount -f"
+# Spin seen in umount() with WiP kernel code.
+
+. ../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 1g -u $mdstart
+flags=$newfs_flags
+[ `jot -r 1 0 1` -eq 1 ] && flags="-j"
+echo "newfs $flags md$mdstart"
+newfs $flags md$mdstart > /dev/null
+mount /dev/md$mdstart $mntpoint
+chmod 777 $mntpoint
+
+export runRUNTIME=3m
+export RUNDIR=$mntpoint/stressX
+
+su $testuser -c 'cd ..; ./run.sh marcus.cfg' > /dev/null 2>&1 &
+
+sleep `jot -r 1 10 40`
+while mdconfig -l | grep md$mdstart; do
+ mdconfig -d -u $mdstart -o force || sleep 1
+done
+sleep .`jot -r 1 1 9`
+umount -f $mntpoint
+../tools/killall.sh
+wait
+n=0
+while mount | grep $mntpoint | grep -q /dev/md; do
+ umount $mntpoint || sleep 1
+ [ $((n += 1)) -gt 300 ] && { echo FAIL; exit 1; }
+done
+exit $s
Added: user/pho/stress2/misc/force4.sh
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/pho/stress2/misc/force4.sh Tue Mar 3 10:02:58 2020 (r358571)
@@ -0,0 +1,91 @@
+#!/bin/sh
+
+#
+# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+#
+# Copyright (c) 2020 Peter Holm
+#
+# 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
+
+# "mdconfig -o force" test scenario with nullfs.
+
+. ../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 1g -u $mdstart
+flags=$newfs_flags
+[ `jot -r 1 0 1` -eq 1 ] && flags="-j"
+echo "newfs $flags md$mdstart"
+newfs $flags md$mdstart > /dev/null
+mount /dev/md$mdstart $mntpoint
+chmod 777 $mntpoint
+
+mp2=${mntpoint}2
+mkdir -p $mp2
+mount -t nullfs $mntpoint $mp2 || exit 1
+
+export LOAD=80
+export MAXSWAPPCT=80
+export RUNDIR=$mp2/stressX
+export runRUNTIME=3m
+export rwLOAD=80
+export TESTPROGS='
+testcases/lockf2/lockf2
+testcases/symlink/symlink
+testcases/openat/openat
+testcases/socket/socket
+testcases/rw/rw
+testcases/mmap/mmap
+testcases/fts/fts
+testcases/link/link
+testcases/lockf/lockf
+testcases/creat/creat
+testcases/mkdir/mkdir
+testcases/rename/rename
+testcases/swap/swap
+testcases/mkfifo/mkfifo
+testcases/dirnprename/dirnprename
+testcases/dirrename/dirrename
+'
+
+su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' > /dev/null 2>&1 &
+
+sleep `jot -r 1 20 60`
+while mdconfig -l | grep md$mdstart; do
+ mdconfig -d -u $mdstart -o force || sleep 1
+done
+sleep 1
+../tools/killall.sh
+wait
+umount $mp2
+n=0
+while mount | grep $mntpoint | grep -q /dev/md; do
+ umount $mntpoint || sleep 1
+ [ $((n += 1)) -gt 300 ] && { echo FAIL; exit 1; }
+done
+exit $s
Added: user/pho/stress2/misc/force5.sh
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/pho/stress2/misc/force5.sh Tue Mar 3 10:02:58 2020 (r358571)
@@ -0,0 +1,76 @@
+#!/bin/sh
+
+#
+# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+#
+# Copyright (c) 2020 Peter Holm
+#
+# 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$
+#
+
+# "mdconfig -o force" test scenario.
+# Rename focus
+
+[ `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 1g -u $mdstart
+flags=$newfs_flags
+[ `jot -r 1 0 1` -eq 1 ] && flags="-j"
+echo "newfs $flags md$mdstart"
+newfs $flags md$mdstart > /dev/null
+mount /dev/md$mdstart $mntpoint
+chmod 777 $mntpoint
+
+export LOAD=80
+export MAXSWAPPCT=80
+export RUNDIR=$mntpoint/stressX
+export runRUNTIME=3m
+export rwLOAD=80
+export TESTPROGS='
+testcases/fts/fts
+testcases/rename/rename
+testcases/swap/swap
+testcases/dirnprename/dirnprename
+testcases/dirrename/dirrename
+'
+
+su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' > /dev/null 2>&1 &
+
+sleep `jot -r 1 20 60`
+while mdconfig -l | grep md$mdstart; do
+ mdconfig -d -u $mdstart -o force || sleep 1
+done
+sleep 1
+../tools/killall.sh
+wait
+n=0
+while mount | grep $mntpoint | grep -q /dev/md; do
+ umount $mntpoint || sleep 1
+ [ $((n += 1)) -gt 300 ] && { echo FAIL; exit 1; }
+done
+exit $s
Added: user/pho/stress2/misc/getrandom2.sh
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/pho/stress2/misc/getrandom2.sh Tue Mar 3 10:02:58 2020 (r358571)
@@ -0,0 +1,190 @@
+#!/bin/sh
+
+#
+# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+#
+# Copyright (c) 2020 Peter Holm
+#
+# 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$
+#
+
+# getrandom(2) DoS scenario.
+
+# panic: pmap_growkernel: no memory to grow kernel
+# cpuid = 8
+# time = 1582102582
+# KDB: stack backtrace:
+# db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe03e6992450
+# vpanic() at vpanic+0x185/frame 0xfffffe03e69924b0
+# panic() at panic+0x43/frame 0xfffffe03e6992510
+# pmap_growkernel() at pmap_growkernel+0x2d4/frame 0xfffffe03e6992550
+# vm_map_insert() at vm_map_insert+0x296/frame 0xfffffe03e69925f0
+# vm_map_find() at vm_map_find+0x617/frame 0xfffffe03e69926d0
+# kva_import() at kva_import+0x3c/frame 0xfffffe03e6992710
+# vmem_try_fetch() at vmem_try_fetch+0xde/frame 0xfffffe03e6992760
+# vmem_xalloc() at vmem_xalloc+0x4bb/frame 0xfffffe03e69927e0
+# kva_import_domain() at kva_import_domain+0x36/frame 0xfffffe03e6992810
+# vmem_try_fetch() at vmem_try_fetch+0xde/frame 0xfffffe03e6992860
+# vmem_xalloc() at vmem_xalloc+0x4bb/frame 0xfffffe03e69928e0
+# vmem_alloc() at vmem_alloc+0x8a/frame 0xfffffe03e6992930
+# kmem_malloc_domainset() at kmem_malloc_domainset+0x92/frame 0xfffffe03e69929a0
+# malloc() at malloc+0x162/frame 0xfffffe03e69929f0
+# read_random_uio() at read_random_uio+0xa5/frame 0xfffffe03e6992a40
+# sys_getrandom() at sys_getrandom+0x7b/frame 0xfffffe03e6992ac0
+# amd64_syscall() at amd64_syscall+0x183/frame 0xfffffe03e6992bf0
+# fast_syscall_common() at fast_syscall_common+0x101/frame 0xfffffe03e6992bf0
+# --- syscall (563, FreeBSD ELF64, sys_getrandom), rip = 0x80041899a, rsp = 0x7ffffffc3cb8, rbp = 0x7ffffffc3cd0 ---
+# KDB: enter: panic
+# [ thread pid 12095 tid 186584 ]
+# Stopped at kdb_enter+0x37: movq $0,0x1084916(%rip)
+# db> x/s version
+# version: FreeBSD 13.0-CURRENT #0 r358094: Wed Feb 19 06:25:16 CET 2020\012 pho at t2.osted.lan:/usr/src/sys/amd64/compile/PHO\012
+# db>
+
+. ../default.cfg
+
+dir=/tmp
+odir=`pwd`
+cd $dir
+sed '1,/^EOF/d' < $odir/$0 > $dir/getrandom2.c
+mycc -o getrandom2 -Wall -Wextra -O0 -g getrandom2.c || exit 1
+rm -f getrandom2.c
+cd $odir
+
+cd /tmp
+$dir/getrandom2
+s=$?
+[ -f getrandom2.core -a $s -eq 0 ] &&
+ { ls -l getrandom2.core; s=1; }
+cd $odir
+
+rm -rf $dir/getrandom2
+exit $s
+
+EOF
+#include <sys/param.h>
+#include <sys/mman.h>
+#include <sys/random.h>
+#include <sys/resource.h>
+#include <sys/stat.h>
+#include <sys/sysctl.h>
+#include <sys/wait.h>
+
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdatomic.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+
+static size_t mx;
+static _Atomic(int) *share;
+static int parallel;
+static char *bp;
+
+#define PARALLEL 40000 /* Arbitrary cap */
+#define SYNC 0
+
+static void
+test(void)
+{
+ int i;
+
+ alarm(180);
+ (void)atomic_fetch_add(&share[SYNC], 1);
+ while (atomic_load(&share[SYNC]) != parallel)
+ usleep(200000);
+ for (i = 0; i < 10; i++)
+ getrandom(bp, mx, 0);
+// close(66);
+
+ _exit(0);
+}
+
+int
+main(void)
+{
+ pid_t *pids;
+ struct rlimit rlp;
+ size_t len;
+ size_t f, vsz;
+ u_int pages;
+ int e, i, status;
+
+ e = 0;
+ len = PAGE_SIZE;
+ if ((share = mmap(NULL, len, PROT_READ | PROT_WRITE,
+ MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED)
+ err(1, "mmap");
+
+ if (getrlimit(RLIMIT_NPROC, &rlp) < 0)
+ err(1, "getrlimit");
+ parallel = rlp.rlim_cur / 100 * 80;
+ if (parallel > PARALLEL)
+ parallel = PARALLEL;
+ pids = calloc(parallel, sizeof(pid_t));
+
+ vsz = sizeof(pages);
+ if (sysctlbyname("vm.stats.vm.v_free_count", &pages, &vsz, NULL, 0) != 0)
+ err(1, "sysctl(vm.stats.vm.v_free_count)");
+ f = pages;
+ f *= PAGE_SIZE;
+
+ if (getrlimit(RLIMIT_DATA, &rlp) < 0)
+ err(1,"getrlimit");
+ mx = rlp.rlim_cur;
+ if (mx > f / parallel)
+ mx = f / parallel;
+ if ((bp = mmap(NULL, mx, PROT_READ | PROT_WRITE, MAP_ANON, -1,
+ 0)) == MAP_FAILED)
+ err(1, "mmap");
+ for (;;) {
+ if (getrandom(bp, mx, 0) != -1)
+ break;
+ mx = mx / 2;
+ }
+ printf("Max getrandom() buffer size is %zu, %d threads\n", mx,
+ parallel);
+ for (i = 0; i < parallel; i++) {
+ if ((pids[i] = fork()) == 0)
+ test();
+ if (pids[i] == -1)
+ err(1, "fork()");
+ }
+ for (i = 0; i < parallel; i++) {
+ if (waitpid(pids[i], &status, 0) == -1)
+ err(1, "waitpid(%d)", pids[i]);
+ if (status != 0) {
+ if (WIFSIGNALED(status))
+ fprintf(stderr,
+ "pid %d exit signal %d\n",
+ pids[i], WTERMSIG(status));
+ }
+ e += status == 0 ? 0 : 1;
+ }
+
+ return (e);
+}
More information about the svn-src-user
mailing list