From owner-svn-src-user@freebsd.org Fri Jul 7 10:22:14 2017 Return-Path: Delivered-To: svn-src-user@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5C2CFD9FAC5 for ; Fri, 7 Jul 2017 10:22:14 +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 mx1.freebsd.org (Postfix) with ESMTPS id 38B7574B49; Fri, 7 Jul 2017 10:22:14 +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 v67AMDVF038945; Fri, 7 Jul 2017 10:22:13 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v67AMDjW038942; Fri, 7 Jul 2017 10:22:13 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201707071022.v67AMDjW038942@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Fri, 7 Jul 2017 10:22:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r320767 - 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: 320767 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.23 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: Fri, 07 Jul 2017 10:22:14 -0000 Author: pho Date: Fri Jul 7 10:22:13 2017 New Revision: 320767 URL: https://svnweb.freebsd.org/changeset/base/320767 Log: Added new regression tests. Sponsored by: Dell EMC Isilon Added: user/pho/stress2/misc/mmap30.sh (contents, props changed) user/pho/stress2/misc/ruby.sh (contents, props changed) user/pho/stress2/misc/stack_guard_page.sh (contents, props changed) Added: user/pho/stress2/misc/mmap30.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/mmap30.sh Fri Jul 7 10:22:13 2017 (r320767) @@ -0,0 +1,79 @@ +#!/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$ +# + +# r320344: allow mprotect(2) over the guards to succeed regardless of +# the requested protection. + +. ../default.cfg + +grep -q MAP_GUARD /usr/include/sys/mman.h 2>/dev/null || exit 0 +here=`pwd` +cd /tmp +sed '1,/^EOF/d' < $here/$0 > mmap30.c +mycc -o mmap30 -Wall -Wextra -O2 -g mmap30.c || exit 1 +rm -f mmap30.c /tmp/mmap30.core + +/tmp/mmap30 > /dev/null +s=$? + +rm -f /tmp/mmap30 /tmp/mmap30.core +exit $s +EOF +#include +#include + +#include +#include +#include +#include +#include + +int +main(void) +{ + int pagesz; + void *addr; + + pagesz = getpagesize(); + addr = mmap(NULL, pagesz, PROT_NONE, MAP_GUARD, -1, 0); + if (addr == (char *)MAP_FAILED) + err(1, "FAIL: mmap(MAP_GUARD)"); + + if (mprotect(addr, pagesz, PROT_READ | PROT_WRITE) == -1) + err(1, "mprotect(RW)"); + + if (mprotect(addr, pagesz, PROT_NONE) == -1) + err(1, "mprotect(RW)"); + + if (munmap(addr, pagesz) == -1) + err(1, "munmap"); + + return (0); +} Added: user/pho/stress2/misc/ruby.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/ruby.sh Fri Jul 7 10:22:13 2017 (r320767) @@ -0,0 +1,40 @@ +#!/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$ +# + +# "small MAP_STACK requests" scenario. + +# "
: warning: pthread_create failed for timer: Resource temporarily +# unavailable, scheduling broken" seen. +# Fixed by r320339. + +[ -x "`which ruby`" ] || exit 0 + +ruby -v 2>&1 | tee $log | grep warning && s=1 || s=0 +exit $s Added: user/pho/stress2/misc/stack_guard_page.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/stack_guard_page.sh Fri Jul 7 10:22:13 2017 (r320767) @@ -0,0 +1,53 @@ +#!/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$ +# + +# Setting a negative guard page size will cause "Abort trap" +# Reported by Shawn Webb +# Fixed in r320560. + +[ `sysctl -n security.bsd.stack_guard_page` -eq 0 ] && exit 0 + +old=`sysctl -n security.bsd.stack_guard_page` +trap "sysctl security.bsd.stack_guard_page=$old" EXIT INT + +../misc/marcus.sh > /dev/null 2>&1 & + +start=`date +%s` +while [ $((`date +%s` - start)) -lt 60 ]; do + sysctl security.bsd.stack_guard_page=`jot -r 1 -1 512` > \ + /dev/null 2>&1 + sleep 1 +done +kill $! +../tools/killall.sh +./cleanup.sh +wait + +exit 0 From owner-svn-src-user@freebsd.org Fri Jul 7 11:20:37 2017 Return-Path: Delivered-To: svn-src-user@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3FB04DA08CE for ; Fri, 7 Jul 2017 11:20:37 +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 mx1.freebsd.org (Postfix) with ESMTPS id 0E019761CA; Fri, 7 Jul 2017 11:20:36 +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 v67BKaX7061912; Fri, 7 Jul 2017 11:20:36 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v67BKaQS061911; Fri, 7 Jul 2017 11:20:36 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201707071120.v67BKaQS061911@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Fri, 7 Jul 2017 11:20:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r320768 - 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: 320768 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.23 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: Fri, 07 Jul 2017 11:20:37 -0000 Author: pho Date: Fri Jul 7 11:20:35 2017 New Revision: 320768 URL: https://svnweb.freebsd.org/changeset/base/320768 Log: Handle vm.stats.vm.v_wire_count exceeding vm.max_wired. Sponsored by: Dell EMC Isilon Modified: user/pho/stress2/misc/mmap18.sh Modified: user/pho/stress2/misc/mmap18.sh ============================================================================== --- user/pho/stress2/misc/mmap18.sh Fri Jul 7 10:22:13 2017 (r320767) +++ user/pho/stress2/misc/mmap18.sh Fri Jul 7 11:20:35 2017 (r320768) @@ -46,8 +46,9 @@ mycc -o mmap18 -Wall -Wextra -O2 mmap18.c -lpthread || rm -f mmap18.c s=0 -wire=$((`sysctl -n vm.max_wired` - `sysctl -n vm.stats.vm.v_wire_count`)) for i in `jot 5`; do + wire=$((`sysctl -n vm.max_wired` - \ + `sysctl -n vm.stats.vm.v_wire_count`)) /tmp/mmap18 $wire || s=1 done @@ -267,8 +268,8 @@ main(int argc, char *argv[]) if (getrlimit(RLIMIT_MEMLOCK, &rl) == -1) warn("getrlimit"); maxlock = atol(argv[1]); - if (maxlock == 0) - errx(1, "Argument is zero"); + if (maxlock <= 0) + errx(1, "Bad argument %jd", maxlock); maxlock = (maxlock / 10 * 8) / PARALLEL * PAGE_SIZE; if (maxlock < rl.rlim_cur) { rl.rlim_max = rl.rlim_cur = maxlock; From owner-svn-src-user@freebsd.org Fri Jul 7 11:22:07 2017 Return-Path: Delivered-To: svn-src-user@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 807CADA0A05 for ; Fri, 7 Jul 2017 11:22:07 +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 mx1.freebsd.org (Postfix) with ESMTPS id 4B9B976388; Fri, 7 Jul 2017 11:22:07 +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 v67BM6Iv065825; Fri, 7 Jul 2017 11:22:06 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v67BM6up065824; Fri, 7 Jul 2017 11:22:06 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201707071122.v67BM6up065824@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Fri, 7 Jul 2017 11:22:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r320769 - 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: 320769 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.23 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: Fri, 07 Jul 2017 11:22:07 -0000 Author: pho Date: Fri Jul 7 11:22:06 2017 New Revision: 320769 URL: https://svnweb.freebsd.org/changeset/base/320769 Log: Reintroduce defines mistakenly removed. Sponsored by: Dell EMC Isilon Modified: user/pho/stress2/misc/sigreturn.sh Modified: user/pho/stress2/misc/sigreturn.sh ============================================================================== --- user/pho/stress2/misc/sigreturn.sh Fri Jul 7 11:20:35 2017 (r320768) +++ user/pho/stress2/misc/sigreturn.sh Fri Jul 7 11:22:06 2017 (r320769) @@ -77,6 +77,10 @@ unsigned long buf[] = { 0xffffffe8, 0xe445c7ff, 0x00000000, 0xc76634eb, 0x00200c46, 0xffe845c7 }; +#if !defined(SYS_freebsd4_sigreturn) +#define SYS_freebsd4_sigreturn 344 +#endif + static void hand(int i __unused) { /* handler */ _exit(1); From owner-svn-src-user@freebsd.org Fri Jul 7 11:24:54 2017 Return-Path: Delivered-To: svn-src-user@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 38503DA0A39 for ; Fri, 7 Jul 2017 11:24:54 +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 mx1.freebsd.org (Postfix) with ESMTPS id A11C2765D4; Fri, 7 Jul 2017 11:24:53 +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 v67BOq5b065956; Fri, 7 Jul 2017 11:24:52 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v67BOqHg065955; Fri, 7 Jul 2017 11:24:52 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201707071124.v67BOqHg065955@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Fri, 7 Jul 2017 11:24:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r320770 - 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: 320770 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.23 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: Fri, 07 Jul 2017 11:24:54 -0000 Author: pho Date: Fri Jul 7 11:24:52 2017 New Revision: 320770 URL: https://svnweb.freebsd.org/changeset/base/320770 Log: The default for vfs.lookup_shared has been 1 for a long time now. Sponsored by: Dell EMC Isilon Modified: user/pho/stress2/misc/lookup_shared.sh Modified: user/pho/stress2/misc/lookup_shared.sh ============================================================================== --- user/pho/stress2/misc/lookup_shared.sh Fri Jul 7 11:22:06 2017 (r320769) +++ user/pho/stress2/misc/lookup_shared.sh Fri Jul 7 11:24:52 2017 (r320770) @@ -34,7 +34,6 @@ saved=`sysctl vfs.lookup_shared | awk '{print $NF}'` trap "sysctl vfs.lookup_shared=$saved" EXIT INT 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=0 +(cd ..; ./run.sh disk.cfg) +exit 0 From owner-svn-src-user@freebsd.org Fri Jul 7 11:27:13 2017 Return-Path: Delivered-To: svn-src-user@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5BAA3DA0AE1 for ; Fri, 7 Jul 2017 11:27:13 +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 mx1.freebsd.org (Postfix) with ESMTPS id 2C02B766DF; Fri, 7 Jul 2017 11:27:13 +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 v67BRCYL066080; Fri, 7 Jul 2017 11:27:12 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v67BRC8t066079; Fri, 7 Jul 2017 11:27:12 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201707071127.v67BRC8t066079@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Fri, 7 Jul 2017 11:27:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r320771 - 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: 320771 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.23 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: Fri, 07 Jul 2017 11:27:13 -0000 Author: pho Date: Fri Jul 7 11:27:12 2017 New Revision: 320771 URL: https://svnweb.freebsd.org/changeset/base/320771 Log: Added a new mlockall(2) test that demonstrate leak of wired pages. Sponsored by: Dell EMC Isilon Added: user/pho/stress2/misc/mlockall7.sh (contents, props changed) Added: user/pho/stress2/misc/mlockall7.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/mlockall7.sh Fri Jul 7 11:27:12 2017 (r320771) @@ -0,0 +1,264 @@ +#!/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$ +# + +# Variation of mmap18.sh, where a leak of wired pages is observed: +# vm.stats.vm.v_wire_count was 172817, is 181696. 8879 + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg + +here=`pwd` +cd /tmp +sed '1,/^EOF/d' < $here/$0 > mlockall7.c +mycc -o mlockall7 -Wall -Wextra -O2 mlockall7.c -lpthread || exit 1 +rm -f mlockall7.c + +/tmp/mlockall7 `[ $# -eq 0 ] && echo 1 || echo $1` || s=1 + +sleep 2 +rm -f /tmp/mlockall7 /tmp/mlockall7.core +exit $s +EOF +#include +#include +#include +#include +#include +#include +#include + +#include +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define N 4096 +#define PARALLEL 50 +#define RUNTIME 180 + +static u_int32_t r[N]; +static void *p; + +static unsigned long +makearg(void) +{ + unsigned long val; + unsigned int i; + + val = arc4random(); + i = arc4random() % 100; + if (i < 20) + val = val & 0xff; + if (i >= 20 && i < 40) + val = val & 0xffff; + if (i >= 40 && i < 60) + val = (unsigned long)(r) | (val & 0xffff); +#if defined(__LP64__) + if (i >= 60) { + val = (val << 32) | arc4random(); + if (i > 80) + val = val & 0x00007fffffffffffUL; + } +#endif + + return (val); +} + +static void * +tmmap(void *arg __unused) +{ + size_t len; + time_t start; + + pthread_set_name_np(pthread_self(), __func__); + len = 128LL * 1024 * 1024; + + start = time(NULL); + while (time(NULL) - start < 60) { + if ((p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON, + -1, 0)) != MAP_FAILED) { + usleep(100); + munmap(p, len); + } + } + + return (NULL); +} + +static void * +tmlockall(void *arg __unused) +{ + time_t start; + int flags; + + pthread_set_name_np(pthread_self(), __func__); + start = time(NULL); + while (time(NULL) - start < 60) { + flags = makearg() & 0xff; + mlockall(flags); + usleep(100); + munlockall(); + usleep(1000); + } + + return (NULL); +} + +static void +test(void) +{ + pthread_t tid[2]; + time_t start; + int i, rc; + + if ((rc = pthread_create(&tid[0], NULL, tmmap, NULL)) != 0) + errc(1, rc, "tmmap()"); + if ((rc = pthread_create(&tid[1], NULL, tmlockall, NULL)) != 0) + errc(1, rc, "tmlock()"); + + start = time(NULL); + while (time(NULL) - start < 60) { + if (fork() == 0) { + usleep(10000); + _exit(0); + } + wait(NULL); + } + + for (i = 0; i < 2; i++) + if ((rc = pthread_join(tid[i], NULL)) != 0) + errc(1, rc, "pthread_join"); + _exit(0); +} + +int +testing(int maxl) +{ + struct passwd *pw; + struct rlimit rl; + rlim_t maxlock; + time_t start; + int i; + + maxlock = maxl; + if ((pw = getpwnam("nobody")) == NULL) + err(1, "failed to resolve nobody"); + if (setgroups(1, &pw->pw_gid) || + setegid(pw->pw_gid) || setgid(pw->pw_gid) || + seteuid(pw->pw_uid) || setuid(pw->pw_uid)) + err(1, "Can't drop privileges to \"nobody\""); + endpwent(); + + rl.rlim_max = rl.rlim_cur = 0; + if (setrlimit(RLIMIT_CORE, &rl) == -1) + warn("setrlimit"); + + if (getrlimit(RLIMIT_MEMLOCK, &rl) == -1) + warn("getrlimit"); + if (maxlock <= 0) + errx(1, "Argument is %jd", maxlock); + maxlock = (maxlock / 10 * 8) / PARALLEL * PAGE_SIZE; + if (maxlock < rl.rlim_cur) { + rl.rlim_max = rl.rlim_cur = maxlock; + if (setrlimit(RLIMIT_MEMLOCK, &rl) == -1) + warn("setrlimit"); + } + + for (i = 0; i < N; i++) + r[i] = arc4random(); + + start = time(NULL); + while (time(NULL) - start < RUNTIME) { + for (i = 0; i < PARALLEL; i++) { + if (fork() == 0) + test(); + } + + for (i = 0; i < PARALLEL; i++) + wait(NULL); + } + + _exit(0); +} + +int +main(int argc, char *argv[]) +{ + pid_t pid; + size_t len; + int i, loops, s, status; + int max_wired, wire_count, wire_count_old; + + s = 0; + if (argc != 2) + errx(1, "Usage: %s ", argv[0]); + loops = atoi(argv[1]); + + len = sizeof(max_wired); + if (sysctlbyname("vm.max_wired", &max_wired, &len, NULL, 0) != 0) + err(1, "vm.max_wired"); + + len = sizeof(wire_count); + if (sysctlbyname("vm.stats.vm.v_wire_count", &wire_count, &len, + NULL, 0) != 0) + err(1, "vm.stats.vm.v_wire_count"); + + for (i = 0; i < loops; i++) { + wire_count_old = wire_count; + + if ((pid = fork()) == 0) + testing(max_wired); + if (waitpid(pid, &status, 0) != pid) + err(1, "waitpid(%d)", pid); + if (status != 0) + errx(1, "Exit status %d from pid %d\n", status, pid); + + len = sizeof(wire_count); + if (sysctlbyname("vm.stats.vm.v_wire_count", &wire_count, &len, + NULL, 0) != 0) + err(1, "vm.stats.vm.v_wire_count"); + fprintf(stderr, "vm.stats.vm.v_wire_count was %d, is %d. %d\n", + wire_count_old, wire_count, wire_count - wire_count_old); + if (wire_count - wire_count_old > 0) + s = 1; + } + + return (s); +}