From owner-svn-src-user@FreeBSD.ORG Mon Aug 11 06:55:42 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9D757809 for ; Mon, 11 Aug 2014 06:55:42 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8B63526AE for ; Mon, 11 Aug 2014 06:55:42 +0000 (UTC) Received: from pho (uid 788) (envelope-from pho@FreeBSD.org) id 2869 by svn.freebsd.org (DragonFly Mail Agent v0.9+); Mon, 11 Aug 2014 06:55:42 +0000 From: Peter Holm Date: Mon, 11 Aug 2014 06:55:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r269801 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <53e868ee.2869.145f87bf@svn.freebsd.org> X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18 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: Mon, 11 Aug 2014 06:55:42 -0000 Author: pho Date: Mon Aug 11 06:55:41 2014 New Revision: 269801 URL: http://svnweb.freebsd.org/changeset/base/269801 Log: Added two socketpair(2) regression tests. Sponsored by: EMC / Isilon storage division Added: user/pho/stress2/misc/socketpair.sh (contents, props changed) user/pho/stress2/misc/socketpair2.sh (contents, props changed) Added: user/pho/stress2/misc/socketpair.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/socketpair.sh Mon Aug 11 06:55:41 2014 (r269801) @@ -0,0 +1,103 @@ +#!/bin/sh + +# +# Copyright (c) 2012 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 due to recursion. Fixed in r216150. + +. ../default.cfg + +here=`pwd` +cd /tmp +sed '1,/^EOF/d' < $here/$0 > socketpair.c +cc -o socketpair -Wall -Wextra -O2 socketpair.c +rm -f socketpair.c +[ -d $RUNDIR ] || mkdir -p $RUNDIR +cd $RUNDIR + +ulimit -b 10485760 +/tmp/socketpair + +cd $here +rm -f /tmp/socketpair +exit 0 +EOF +/* From http://lkml.org/lkml/2010/11/25/8 */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int +send_fd(int unix_fd, int fd) +{ + struct msghdr msgh; + struct cmsghdr *cmsg; + char buf[CMSG_SPACE(sizeof(fd))]; + memset(&msgh, 0, sizeof(msgh)); + memset(buf, 0, sizeof(buf)); + + msgh.msg_control = buf; + msgh.msg_controllen = sizeof(buf); + + cmsg = CMSG_FIRSTHDR(&msgh); + cmsg->cmsg_len = CMSG_LEN(sizeof(fd)); + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = SCM_RIGHTS; + + msgh.msg_controllen = cmsg->cmsg_len; + + memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd)); + return sendmsg(unix_fd, &msgh, 0); +} + +int +main() +{ + int fd[2], ff[2]; + + if (socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fd) == -1) + return 1; + for (;;) { + if (socketpair(PF_UNIX, SOCK_SEQPACKET, 0, ff) == -1) + return 2; + send_fd(ff[0], fd[0]); + send_fd(ff[0], fd[1]); + close(fd[1]); + close(fd[0]); + fd[0] = ff[0]; + fd[1] = ff[1]; + } +} Added: user/pho/stress2/misc/socketpair2.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/socketpair2.sh Mon Aug 11 06:55:41 2014 (r269801) @@ -0,0 +1,275 @@ +#!/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$ +# + +# Default unix domain socket limits causes hang: +# 1001 880 871 0 52 0 5780 1524 keglimit D+ 0 0:00.35 /tmp/socketpair2 + +# Test scenario by peter@ + +# Fixed in r269489. + +. ../default.cfg + +here=`pwd` +cd /tmp +sed '1,/^EOF/d' < $here/$0 > socketpair2.c +cc -o socketpair2 -Wall -Wextra -O2 socketpair2.c || exit +rm -f socketpair2.c + +/tmp/socketpair2 > /dev/null 2>&1 + +rm -f /tmp/socketpair2 +exit 0 +EOF +/* + Peter Wemm + + Some systems seem to base how much can be written to the pipe based + on the size of the socket receive buffer (read-side), while others + on the size of the socket send buffer (send-side). + + This little hack tries to make an educated guess as to what is the + case on this particular system. +*/ + +#include +#include + +#include +#include +#include +#include +#include +#include + +#ifndef MIN +#define MIN(a,b) ((a) < (b) ? (a) : (b)) +#endif /* !MIN */ + +#ifndef MAX +#define MAX(a,b) ((a) > (b) ? (a) : (b)) +#endif /* !MAX */ + +#if NEED_AF_LOCAL +#define AF_LOCAL AF_UNIX +#endif /* NEED_AF_LOCAL */ + +#define PACKETSIZE (1024) + +#define SEND_PIPE (0) +#define RECV_PIPE (1) + +#define EXIT_SENDSIDE (1) +#define EXIT_READSIDE (0) /* looking for readside - exit 0 */ +#define EXIT_UNKNOWN (1) + +static void +setsockets(const int doreverse, const size_t packetsize, + const int s, const int r, + size_t *sndbuf, size_t *sndbuf_set, + size_t *rcvbuf, size_t *rcvbuf_set); + +static size_t +sendtest(const int s, const char *buf, const size_t buflen); + +int +main(void) +{ + size_t sent, packetcount, sndbuf, sndbuf_set, rcvbuf, rcvbuf_set; + char buf[PACKETSIZE - 64]; /* allow for some padding between messages. */ + int datapipev[2]; + + if (socketpair(AF_LOCAL, SOCK_DGRAM, 0, datapipev) != 0) { + perror("socketpair()"); + exit(EXIT_UNKNOWN); + } + + setsockets(0, + PACKETSIZE, + datapipev[SEND_PIPE], + datapipev[RECV_PIPE], + &sndbuf, &sndbuf_set, + &rcvbuf, &rcvbuf_set); + + packetcount = MIN(sndbuf, sndbuf_set) / PACKETSIZE; + fprintf(stderr, "Requested sndbuf to be %ld, is %ld. " + "Requested rcvbuf to be %ld, is %ld.\n" + "Calculated packetcount is %lu\n", + (long)sndbuf, (long)sndbuf_set, + (long)rcvbuf, (long)rcvbuf_set, (unsigned long)packetcount); + + sent = sendtest(datapipev[SEND_PIPE], buf, sizeof(buf)); + if (sent >= (size_t)sndbuf) { + fprintf(stderr, "status determined by send-side\n"); + return EXIT_SENDSIDE; + } + + /* + * Try the reverse. Perhaps this system wants a large rcvbuf rather than + * a large sndbuf. + */ + close(datapipev[SEND_PIPE]); + close(datapipev[RECV_PIPE]); + + if (socketpair(AF_LOCAL, SOCK_DGRAM, 0, datapipev) != 0) { + perror("socketpair()"); + exit(EXIT_UNKNOWN); + } + + setsockets(1, + PACKETSIZE, + datapipev[SEND_PIPE], + datapipev[RECV_PIPE], + &sndbuf, &sndbuf_set, + &rcvbuf, &rcvbuf_set); + + packetcount = MIN(rcvbuf, rcvbuf_set) / PACKETSIZE; + fprintf(stderr, "Requested sndbuf to be %ld, is %ld. " + "Requested rcvbuf to be %ld, is %ld.\n" + "Calculated packetcount is %lu\n", + (long)sndbuf, (long)sndbuf_set, + (long)rcvbuf, (long)rcvbuf_set, (unsigned long)packetcount); + + sent = sendtest(datapipev[SEND_PIPE], buf, sizeof(buf)); + if (sent >= (size_t)rcvbuf) { + fprintf(stderr, "status determined by read-side\n"); + return EXIT_READSIDE; + } + + fprintf(stderr, "status is unknown\n"); + return EXIT_UNKNOWN; +} + +static void +setsockets(doreverse, packetsize, s, r, sndbuf, sndbuf_set, rcvbuf, rcvbuf_set) + const int doreverse; + const size_t packetsize; + const int s; + const int r; + size_t *sndbuf, *sndbuf_set; + size_t *rcvbuf, *rcvbuf_set; +{ + socklen_t len; + int p; + + if ((p = fcntl(s, F_GETFL, 0)) == -1 + || fcntl(s, F_SETFL, p | O_NONBLOCK) == -1 + || fcntl(r, F_SETFL, p | O_NONBLOCK) == -1) { + perror("fcntl(F_SETFL/F_GETFL, O_NONBLOCK) failed"); + exit(EXIT_UNKNOWN); + } + + len = sizeof(*sndbuf_set); + + if (doreverse) { + *sndbuf = packetsize; + if (setsockopt(s, SOL_SOCKET, SO_SNDBUF, sndbuf, sizeof(*sndbuf)) != 0) { + perror("setsockopt(SO_SNDBUF)"); + exit(EXIT_UNKNOWN); + } + + if (getsockopt(s, SOL_SOCKET, SO_SNDBUF, sndbuf_set, &len) != 0) { + perror("getsockopt(SO_SNDBUF)"); + exit(EXIT_UNKNOWN); + } + + *rcvbuf = *sndbuf_set * 10; + if (setsockopt(r, SOL_SOCKET, SO_RCVBUF, rcvbuf, sizeof(*rcvbuf)) != 0) { + perror("setsockopt(SO_RCVBUF)"); + exit(EXIT_UNKNOWN); + } + } + else { + *rcvbuf = packetsize; + if (setsockopt(r, SOL_SOCKET, SO_RCVBUF, rcvbuf, sizeof(*rcvbuf)) != 0) { + perror("setsockopt(SO_RCVBUF)"); + exit(EXIT_UNKNOWN); + } + + if (getsockopt(r, SOL_SOCKET, SO_RCVBUF, rcvbuf_set, &len) != 0) { + perror("getsockopt(SO_RCVBUF)"); + exit(EXIT_UNKNOWN); + } + + *sndbuf = *rcvbuf_set * 10; + if (setsockopt(s, SOL_SOCKET, SO_SNDBUF, sndbuf, sizeof(*sndbuf)) != 0) { + perror("setsockopt(SO_SNDBUF)"); + exit(EXIT_UNKNOWN); + } + } + + if (getsockopt(s, SOL_SOCKET, SO_SNDBUF, sndbuf_set, &len) != 0 + || getsockopt(r, SOL_SOCKET, SO_RCVBUF, rcvbuf_set, &len) != 0) { + perror("getsockopt(SO_SNDBUF/SO_RCVBUF)"); + exit(EXIT_UNKNOWN); + } + + fprintf(stderr, "sndbuf is %lu, rcvbuf is %lu\n", + (unsigned long)*sndbuf_set, (unsigned long)*rcvbuf_set); + + if (doreverse) { + if (*rcvbuf_set < *rcvbuf) { + fprintf(stderr, "failed to set rcvbuf to %lu. Is %lu\n", + (unsigned long)*rcvbuf, (unsigned long)*rcvbuf_set); + exit(EXIT_UNKNOWN); + } + } + else { + if (*sndbuf_set < *sndbuf) { + fprintf(stderr, "failed to set sndbuf to %lu (is %lu)\n", + (unsigned long)*sndbuf, (unsigned long)*sndbuf_set); + exit(EXIT_UNKNOWN); + } + } +} + +static size_t +sendtest(s, buf, buflen) + const int s; + const char *buf; + const size_t buflen; +{ + ssize_t rc; + int i; + + i = 1; + errno = 0; + while (errno == 0) { + if ((rc = sendto(s, buf, buflen, 0, NULL, 0)) != (ssize_t)buflen) + fprintf(stderr, "sendto(2) failed on iteration %d, sent %ld/%lu. " + "Total bytes sent: %lu. Error on last packet: %s\n", + i, (long)rc, (unsigned long)buflen, + (unsigned long)(i * buflen + MAX(rc, 0)), strerror(errno)); + else + ++i; + } + + return (size_t)(i * buflen + MAX(rc, 0)); +} From owner-svn-src-user@FreeBSD.ORG Mon Aug 11 07:04:09 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D050AC2A for ; Mon, 11 Aug 2014 07:04:09 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BF550279C for ; Mon, 11 Aug 2014 07:04:09 +0000 (UTC) Received: from pho (uid 788) (envelope-from pho@FreeBSD.org) id 2bf7 by svn.freebsd.org (DragonFly Mail Agent v0.9+); Mon, 11 Aug 2014 07:04:09 +0000 From: Peter Holm Date: Mon, 11 Aug 2014 07:04:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r269804 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <53e86ae9.2bf7.3225afae@svn.freebsd.org> X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18 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: Mon, 11 Aug 2014 07:04:09 -0000 Author: pho Date: Mon Aug 11 07:04:08 2014 New Revision: 269804 URL: http://svnweb.freebsd.org/changeset/base/269804 Log: Let procfs.sh be less verbose and added two procfs scenarios. Sponsored by: EMC / Isilon storage division Added: user/pho/stress2/misc/procfs3.sh (contents, props changed) user/pho/stress2/misc/procfs4.sh (contents, props changed) Modified: user/pho/stress2/misc/procfs.sh Modified: user/pho/stress2/misc/procfs.sh ============================================================================== --- user/pho/stress2/misc/procfs.sh Mon Aug 11 07:01:29 2014 (r269803) +++ user/pho/stress2/misc/procfs.sh Mon Aug 11 07:04:08 2014 (r269804) @@ -47,7 +47,7 @@ if [ $# -eq 0 ]; then for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) ./$0 $m & - ./$0 find $m & + ./$0 find $m > /dev/null 2>&1 & done for i in `jot $mounts`; do Added: user/pho/stress2/misc/procfs3.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/procfs3.sh Mon Aug 11 07:04:08 2014 (r269804) @@ -0,0 +1,152 @@ +#!/bin/sh + +# +# Copyright (c) 2012 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$ +# + +# procfs(5) test scenario. +# "panic: wchan 0xc10a4f68 has no wmesg" seen + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg + +here=`pwd` +cd /tmp +sed '1,/^EOF/d' < $here/$0 > procfs3.c +cc -o procfs3 -Wall -Wextra -O2 procfs3.c || exit 1 +rm -f procfs3.c +cd $here + +su $testuser -c /tmp/procfs3 + +rm -f /tmp/procfs3 +exit 0 +EOF +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PARALLEL 10 + +void +handler(int i __unused) +{ +} + +int +test(void) +{ + + FTS *fts; + FTSENT *p; + int ftsoptions; + char *args[2]; + int fd, i; + char buf[1629]; + + ftsoptions = FTS_PHYSICAL; + args[0] = "/proc"; + args[1] = 0; + + if ((fts = fts_open(args, ftsoptions, NULL)) == NULL) + err(1, "fts_open"); + + while ((p = fts_read(fts)) != NULL) { + switch (p->fts_info) { + case FTS_F: /* Ignore. */ + break; + case FTS_D: /* Ignore. */ + continue; + case FTS_DP: + continue; + case FTS_DC: /* Ignore. */ + continue; + case FTS_SL: /* Ignore. */ + continue; + case FTS_DNR: /* Warn, continue. */ + case FTS_ERR: + case FTS_NS: + case FTS_DEFAULT: + warnx("%s: %s", p->fts_path, strerror(p->fts_errno)); + break; + default: + printf("%s: default, %d\n", getprogname(), p->fts_info); + break; + } + + if ((fd = open(p->fts_path, O_RDONLY)) == -1) + continue; + signal(SIGALRM, handler); + alarm(1); + + for (i = 0; i < 2; i++) { + read(fd, buf, 1629); + } + close(fd); + } + + if (errno != 0 && errno != ENOENT) + err(1, "fts_read"); + if (fts_close(fts) == -1) + err(1, "fts_close()"); + + return (0); +} + +int +main(void) +{ + int i, j; + + for (i = 0; i < PARALLEL; i++) { + if (fork() == 0) { + for (j = 0; j < 50; j++) { + test(); + } + _exit(0); + } + } + + for (i = 0; i < PARALLEL; i++) + wait(NULL); + + return (0); +} Added: user/pho/stress2/misc/procfs4.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/procfs4.sh Mon Aug 11 07:04:08 2014 (r269804) @@ -0,0 +1,146 @@ +#!/bin/sh + +# +# Copyright (c) 2012 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 scenario idea by kib@ + +# "panic: double fault" seen due to recurtion + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg + +mount | grep -q procfs || mount -t procfs procfs /proc +here=`pwd` +cd /tmp +sed '1,/^EOF/d' < $here/$0 > procfs4.c +cc -o procfs4 -Wall -Wextra -O2 procfs4.c +rm -f procfs4.c +cd $here + +su $testuser -c /tmp/procfs4 + +rm -f /tmp/procfs4 +exit 0 +EOF +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PARALLEL 10 +#define LOOPS 1000 + +char *files[] = { + "cmdline", + "ctl", + "dbregs", + "etype", + "file", + "fpregs", + "map", + "mem", + "note", + "notepg", + "osrel", + "regs", + "rlimit", + "status" +}; + +void +test(void) +{ + pid_t p; + int fd, i, j, n, opens; + char path[128]; + + for (i = 0; i < 64; i++) { + if ((p = fork()) == 0) { + setproctitle("Sleeper"); + usleep(20000); + usleep(arc4random() % 200); + for (j = 0; j < 10000; j++) + getpid(); + _exit(0); + } + opens = 0; + setproctitle("load"); + for (j = 0; j < 14; j++) { + snprintf(path, sizeof(path), "/proc/%d/%s", p, files[j]); + if ((fd = open(path, O_RDWR)) == -1) + if ((fd = open(path, O_RDONLY)) == -1) + continue; + + ioctl(fd, FIONREAD, &n); + if (ioctl(fd, FIONBIO, &n) != -1) + opens++; + + close(fd); + } + kill(p, SIGHUP); +#if 0 + if (opens < 1) + fprintf(stderr, "Warn %d open(s) for pid %d\n", opens, getpid()); +#endif + } + + for (i = 0; i < 64; i++) + wait(NULL); + + _exit(0); +} + +int +main(void) +{ + int i, j; + + for (i = 0; i < LOOPS; i++) { + for (j = 0; j < PARALLEL; j++) { + if (fork() == 0) + test(); + } + + for (j = 0; j < PARALLEL; j++) + wait(NULL); + usleep(10000); + } + + return (0); +} From owner-svn-src-user@FreeBSD.ORG Mon Aug 11 20:36:10 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2F7B09B9 for ; Mon, 11 Aug 2014 20:36:10 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 03A3B20E3 for ; Mon, 11 Aug 2014 20:36:10 +0000 (UTC) Received: from jceel (uid 1267) (envelope-from jceel@FreeBSD.org) id 2aa2 by svn.freebsd.org (DragonFly Mail Agent v0.9+); Mon, 11 Aug 2014 20:36:09 +0000 From: Jakub Wojciech Klama Date: Mon, 11 Aug 2014 20:36:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r269835 - in user/jceel/soc2014_evdev/head: etc/mtree include X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <53e92939.2aa2.1990ee48@svn.freebsd.org> X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18 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: Mon, 11 Aug 2014 20:36:10 -0000 Author: jceel Date: Mon Aug 11 20:36:09 2014 New Revision: 269835 URL: http://svnweb.freebsd.org/changeset/base/269835 Log: Install evdev headers in /usr/include. Modified: user/jceel/soc2014_evdev/head/etc/mtree/BSD.include.dist user/jceel/soc2014_evdev/head/include/Makefile Modified: user/jceel/soc2014_evdev/head/etc/mtree/BSD.include.dist ============================================================================== --- user/jceel/soc2014_evdev/head/etc/mtree/BSD.include.dist Mon Aug 11 20:00:51 2014 (r269834) +++ user/jceel/soc2014_evdev/head/etc/mtree/BSD.include.dist Mon Aug 11 20:36:09 2014 (r269835) @@ -108,6 +108,8 @@ .. ciss .. + evdev + .. filemon .. firewire Modified: user/jceel/soc2014_evdev/head/include/Makefile ============================================================================== --- user/jceel/soc2014_evdev/head/include/Makefile Mon Aug 11 20:00:51 2014 (r269834) +++ user/jceel/soc2014_evdev/head/include/Makefile Mon Aug 11 20:36:09 2014 (r269835) @@ -151,7 +151,7 @@ copies: done .endif .endfor -.for i in ${LDIRS} ${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/bktr:Ndev/nand:Ndev/pci} ${LSUBSUBDIRS} +.for i in ${LDIRS} ${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/bktr:Ndev/evdev:Ndev/nand:Ndev/pci} ${LSUBSUBDIRS} cd ${.CURDIR}/../sys; \ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 $i/*.h \ ${DESTDIR}${INCLUDEDIR}/$i @@ -172,6 +172,11 @@ copies: ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 nand_dev.h \ ${DESTDIR}${INCLUDEDIR}/dev/nand .endif + cd ${.CURDIR}/../sys/dev/evdev; \ + ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 input.h \ + ${DESTDIR}${INCLUDEDIR}/dev/evdev; \ + ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 uinput.h \ + ${DESTDIR}${INCLUDEDIR}/dev/evdev cd ${.CURDIR}/../sys/dev/pci; \ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 pcireg.h \ ${DESTDIR}${INCLUDEDIR}/dev/pci @@ -236,7 +241,7 @@ symlinks: ln -fs ../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \ done .endfor -.for i in ${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/bktr:Ndev/nand:Ndev/pci} +.for i in ${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/bktr:Ndev/evdev:Ndev/nand:Ndev/pci} cd ${.CURDIR}/../sys/$i; \ for h in *.h; do \ ln -fs ../../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \ @@ -264,6 +269,11 @@ symlinks: ${DESTDIR}${INCLUDEDIR}/dev/nand; \ done .endif + cd ${.CURDIR}/../sys/dev/evdev; \ + for h in input.h uinput.h; do \ + ln -fs ../../../../sys/dev/evdev/$$h \ + ${DESTDIR}${INCLUDEDIR}/dev/evdev; \ + done cd ${.CURDIR}/../sys/dev/pci; \ for h in pcireg.h; do \ ln -fs ../../../../sys/dev/pci/$$h \ From owner-svn-src-user@FreeBSD.ORG Tue Aug 12 12:40:58 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 19531C66 for ; Tue, 12 Aug 2014 12:40:58 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E324C28EB for ; Tue, 12 Aug 2014 12:40:57 +0000 (UTC) Received: from pho (uid 788) (envelope-from pho@FreeBSD.org) id 6733 by svn.freebsd.org (DragonFly Mail Agent v0.9+); Tue, 12 Aug 2014 12:40:57 +0000 From: Peter Holm Date: Tue, 12 Aug 2014 12:40:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r269868 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <53ea0b59.6733.1c2389e4@svn.freebsd.org> X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18 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: Tue, 12 Aug 2014 12:40:58 -0000 Author: pho Date: Tue Aug 12 12:40:57 2014 New Revision: 269868 URL: http://svnweb.freebsd.org/changeset/base/269868 Log: Tune scenario to create more load. Sponsored by: EMC / Isilon storage division Modified: user/pho/stress2/misc/crossmp2.sh Modified: user/pho/stress2/misc/crossmp2.sh ============================================================================== --- user/pho/stress2/misc/crossmp2.sh Tue Aug 12 12:36:06 2014 (r269867) +++ user/pho/stress2/misc/crossmp2.sh Tue Aug 12 12:40:57 2014 (r269868) @@ -54,15 +54,16 @@ if [ $# -eq 0 ]; then done else if [ $1 = find ]; then - for i in `jot 64`; do + for i in `jot 128`; do find ${mntpoint}* -maxdepth 1 -type f > /dev/null 2>&1 done else # The test: Parallel mount and unmounts - for i in `jot 64`; do + for i in `jot 128`; do m=$1 mount -t nfs -o tcp -o nfsv3 -o retrycnt=3 -o intr -o soft -o rw 127.0.0.1:/tmp ${mntpoint}$m + sleep .5 opt=`[ $(( m % 2 )) -eq 0 ] && echo -f` n=0 while mount | grep -qw ${mntpoint}$m; do From owner-svn-src-user@FreeBSD.ORG Tue Aug 12 12:42:51 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8C29DD93 for ; Tue, 12 Aug 2014 12:42:51 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6239E2907 for ; Tue, 12 Aug 2014 12:42:51 +0000 (UTC) Received: from pho (uid 788) (envelope-from pho@FreeBSD.org) id 6a69 by svn.freebsd.org (DragonFly Mail Agent v0.9+); Tue, 12 Aug 2014 12:42:51 +0000 From: Peter Holm Date: Tue, 12 Aug 2014 12:42:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r269869 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <53ea0bcb.6a69.699e907b@svn.freebsd.org> X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18 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: Tue, 12 Aug 2014 12:42:51 -0000 Author: pho Date: Tue Aug 12 12:42:51 2014 New Revision: 269869 URL: http://svnweb.freebsd.org/changeset/base/269869 Log: Added description of problem fount with this scenario. Fixed error and made cleaning up more safe. Modified: user/pho/stress2/misc/crossmp3.sh Modified: user/pho/stress2/misc/crossmp3.sh ============================================================================== --- user/pho/stress2/misc/crossmp3.sh Tue Aug 12 12:40:57 2014 (r269868) +++ user/pho/stress2/misc/crossmp3.sh Tue Aug 12 12:42:51 2014 (r269869) @@ -29,7 +29,9 @@ # # Parallel mount and umount of file systems -# No problems seen. +# "panic: Bad link elm 0xfffff8052a20cc00 prev->next != elm" seen: +# http://people.freebsd.org/~pho/stress/log/crossmp3.txt +# Fixed in r269853 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 @@ -39,14 +41,13 @@ N=`sysctl -n hw.ncpu` size=$((`sysctl -n hw.usermem` / 1024 / 1024 / N)) mounts=$N # Number of parallel scripts -mdstart=$mdstart # Use md unit numbers from this point if [ $# -eq 0 ]; then for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) [ ! -d ${mntpoint}$m ] && mkdir ${mntpoint}$m - mount | grep "$mntpoint" | grep -q md$m && umount ${mntpoint}$m - mdconfig -l | grep -q md$m && mdconfig -d -u $m + mount | grep "${mntpoint}$m" | grep -q md$m && umount ${mntpoint}$m + mdconfig -l | grep -q md$m && mdconfig -d -u $m mdconfig -a -t swap -s ${size}m -u $m bsdlabel -w md$m auto @@ -85,7 +86,7 @@ else chmod 777 ${mntpoint}$m export RUNDIR=${mntpoint}$m/stressX export CTRLDIR=${mntpoint}$m/stressX.control - (cd ${mntpoint}$m; find . -delete) + (cd ${mntpoint}$m && find . -delete) su $testuser -c 'cd ..; ./run.sh disk.cfg' > \ /dev/null 2>&1 From owner-svn-src-user@FreeBSD.ORG Tue Aug 12 12:44:41 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2929BEEC for ; Tue, 12 Aug 2014 12:44:41 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F35C22929 for ; Tue, 12 Aug 2014 12:44:40 +0000 (UTC) Received: from pho (uid 788) (envelope-from pho@FreeBSD.org) id 6a79 by svn.freebsd.org (DragonFly Mail Agent v0.9+); Tue, 12 Aug 2014 12:44:40 +0000 From: Peter Holm Date: Tue, 12 Aug 2014 12:44:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r269870 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <53ea0c38.6a79.6abd27e@svn.freebsd.org> X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18 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: Tue, 12 Aug 2014 12:44:41 -0000 Author: pho Date: Tue Aug 12 12:44:40 2014 New Revision: 269870 URL: http://svnweb.freebsd.org/changeset/base/269870 Log: Expanded comment a bit. Sponsored by: EMC / Isilon storage division Modified: user/pho/stress2/misc/crossmp4.sh Modified: user/pho/stress2/misc/crossmp4.sh ============================================================================== --- user/pho/stress2/misc/crossmp4.sh Tue Aug 12 12:42:51 2014 (r269869) +++ user/pho/stress2/misc/crossmp4.sh Tue Aug 12 12:44:40 2014 (r269870) @@ -28,7 +28,8 @@ # $FreeBSD$ # -# Parallel mount and umount of file systems +# Parallel mount and umount of file systems. Nullfs version. + # "panic: Lock (lockmgr) null not locked @ kern/vfs_default.c:523." seen. # http://people.freebsd.org/~pho/stress/log/kostik698.txt # Fixed by r269708. From owner-svn-src-user@FreeBSD.ORG Tue Aug 12 12:45:30 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6EADE1AB for ; Tue, 12 Aug 2014 12:45:30 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5E0842935 for ; Tue, 12 Aug 2014 12:45:30 +0000 (UTC) Received: from pho (uid 788) (envelope-from pho@FreeBSD.org) id 6a9c by svn.freebsd.org (DragonFly Mail Agent v0.9+); Tue, 12 Aug 2014 12:45:30 +0000 From: Peter Holm Date: Tue, 12 Aug 2014 12:45:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r269872 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <53ea0c6a.6a9c.1c0e0ed@svn.freebsd.org> X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18 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: Tue, 12 Aug 2014 12:45:30 -0000 Author: pho Date: Tue Aug 12 12:45:30 2014 New Revision: 269872 URL: http://svnweb.freebsd.org/changeset/base/269872 Log: Added new test scenario. Sponsored by: EMC / Isilon storage division Added: user/pho/stress2/misc/crossmp5.sh (contents, props changed) Added: user/pho/stress2/misc/crossmp5.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/crossmp5.sh Tue Aug 12 12:45:30 2014 (r269872) @@ -0,0 +1,98 @@ +#!/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 crossmp3.sh + +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 + +. ../default.cfg + +N=`sysctl -n hw.ncpu` +size=$((`sysctl -n hw.usermem` / 1024 / 1024 / N)) + +mounts=$N # Number of parallel scripts + +if [ $# -eq 0 ]; then + for i in `jot $mounts`; do + m=$(( i + mdstart - 1 )) + [ ! -d ${mntpoint}$m ] && mkdir ${mntpoint}$m + mount | grep "${mntpoint}$m" | grep -q md$m && + umount ${mntpoint}$m + mdconfig -l | grep -q md$m && mdconfig -d -u $m + + mdconfig -a -t swap -s ${size}m -u $m + bsdlabel -w md$m auto + newfs $newfs_flags md${m}$part > /dev/null 2>&1 + done + + # start the parallel tests + for i in `jot $mounts`; do + m=$(( i + mdstart - 1 )) + ./$0 $m & + ./$0 find & + done + + for i in `jot $mounts`; do + wait; wait + done + + for i in `jot $mounts`; do + m=$(( i + mdstart - 1 )) + mdconfig -d -u $m + rm -f $D$m + done + +else + touch /tmp/crossmp.continue + if [ $1 = find ]; then + while [ -f /tmp/crossmp.continue ]; do + find ${mntpoint}* -type f > /dev/null 2>&1 + done + else + # The test: Parallel mount and unmounts + m=$1 + for i in `jot 200`; do + mount /dev/md${m}${part} ${mntpoint}$m + chmod 777 ${mntpoint}$m + l=`od -An -N2 -t u2 /dev/random | + sed 's/ //g'` + dd if=/dev/zero of=$mntpoint/$i bs=$l count=100 \ + 2>&1 | egrep -v 'records|transferred' + rm -f $mntpoint/$i + + while mount | grep -q "on ${mntpoint}$m "; do + opt=$([ $((`date '+%s'` % 2)) -eq 0 ] && + echo "-f") + umount $opt ${mntpoint}$m > /dev/null 2>&1 + done + done + rm -f /tmp/crossmp.continue + fi +fi From owner-svn-src-user@FreeBSD.ORG Tue Aug 12 20:03:25 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7B186346 for ; Tue, 12 Aug 2014 20:03:25 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5AF90296E for ; Tue, 12 Aug 2014 20:03:25 +0000 (UTC) Received: from jceel (uid 1267) (envelope-from jceel@FreeBSD.org) id 6aff by svn.freebsd.org (DragonFly Mail Agent v0.9+); Tue, 12 Aug 2014 20:03:23 +0000 From: Jakub Wojciech Klama Date: Tue, 12 Aug 2014 20:03:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r269891 - in user/jceel/soc2014_evdev/contrib/libevdev: libevdev test X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <53ea730c.6aff.29f9cfe8@svn.freebsd.org> X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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: Tue, 12 Aug 2014 20:03:25 -0000 Author: jceel Date: Tue Aug 12 20:03:23 2014 New Revision: 269891 URL: http://svnweb.freebsd.org/changeset/base/269891 Log: Use correct include paths under FreeBSD. Modified: user/jceel/soc2014_evdev/contrib/libevdev/libevdev/libevdev-uinput.c user/jceel/soc2014_evdev/contrib/libevdev/libevdev/libevdev.h user/jceel/soc2014_evdev/contrib/libevdev/libevdev/make-event-names.py user/jceel/soc2014_evdev/contrib/libevdev/test/test-common-uinput.c user/jceel/soc2014_evdev/contrib/libevdev/test/test-kernel.c user/jceel/soc2014_evdev/contrib/libevdev/test/test-libevdev-events.c user/jceel/soc2014_evdev/contrib/libevdev/test/test-libevdev-has-event.c user/jceel/soc2014_evdev/contrib/libevdev/test/test-uinput.c Modified: user/jceel/soc2014_evdev/contrib/libevdev/libevdev/libevdev-uinput.c ============================================================================== --- user/jceel/soc2014_evdev/contrib/libevdev/libevdev/libevdev-uinput.c Tue Aug 12 19:57:12 2014 (r269890) +++ user/jceel/soc2014_evdev/contrib/libevdev/libevdev/libevdev-uinput.c Tue Aug 12 20:03:23 2014 (r269891) @@ -30,7 +30,12 @@ #include #include #include -#include + +#ifdef __FreeBSD__ +#include +#else +#include +#endif #include "libevdev.h" #include "libevdev-int.h" Modified: user/jceel/soc2014_evdev/contrib/libevdev/libevdev/libevdev.h ============================================================================== --- user/jceel/soc2014_evdev/contrib/libevdev/libevdev/libevdev.h Tue Aug 12 19:57:12 2014 (r269890) +++ user/jceel/soc2014_evdev/contrib/libevdev/libevdev/libevdev.h Tue Aug 12 20:03:23 2014 (r269891) @@ -27,7 +27,11 @@ extern "C" { #endif +#ifdef __FreeBSD__ +#include +#else #include +#endif #include #define LIBEVDEV_ATTRIBUTE_PRINTF(_format, _args) __attribute__ ((format (printf, _format, _args))) Modified: user/jceel/soc2014_evdev/contrib/libevdev/libevdev/make-event-names.py ============================================================================== --- user/jceel/soc2014_evdev/contrib/libevdev/libevdev/make-event-names.py Tue Aug 12 19:57:12 2014 (r269890) +++ user/jceel/soc2014_evdev/contrib/libevdev/libevdev/make-event-names.py Tue Aug 12 20:03:23 2014 (r269891) @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Parses linux/input.h scanning for #define KEY_FOO 134 +# Parses input.h scanning for #define KEY_FOO 134 # Prints C header files or Python files that can be used as # mapping and lookup tables. # Modified: user/jceel/soc2014_evdev/contrib/libevdev/test/test-common-uinput.c ============================================================================== --- user/jceel/soc2014_evdev/contrib/libevdev/test/test-common-uinput.c Tue Aug 12 19:57:12 2014 (r269890) +++ user/jceel/soc2014_evdev/contrib/libevdev/test/test-common-uinput.c Tue Aug 12 20:03:23 2014 (r269891) @@ -27,7 +27,11 @@ #include #include #include +#ifdef __FreeBSD__ +#include +#else #include +#endif #include #include Modified: user/jceel/soc2014_evdev/contrib/libevdev/test/test-kernel.c ============================================================================== --- user/jceel/soc2014_evdev/contrib/libevdev/test/test-kernel.c Tue Aug 12 19:57:12 2014 (r269890) +++ user/jceel/soc2014_evdev/contrib/libevdev/test/test-kernel.c Tue Aug 12 20:03:23 2014 (r269891) @@ -29,7 +29,12 @@ #include #include #include + +#ifdef __FreeBSD__ +#include +#else #include +#endif #include #include Modified: user/jceel/soc2014_evdev/contrib/libevdev/test/test-libevdev-events.c ============================================================================== --- user/jceel/soc2014_evdev/contrib/libevdev/test/test-libevdev-events.c Tue Aug 12 19:57:12 2014 (r269890) +++ user/jceel/soc2014_evdev/contrib/libevdev/test/test-libevdev-events.c Tue Aug 12 20:03:23 2014 (r269891) @@ -21,7 +21,11 @@ */ #include +#ifdef __FreeBSD__ +#include +#else #include +#endif #include #include #include Modified: user/jceel/soc2014_evdev/contrib/libevdev/test/test-libevdev-has-event.c ============================================================================== --- user/jceel/soc2014_evdev/contrib/libevdev/test/test-libevdev-has-event.c Tue Aug 12 19:57:12 2014 (r269890) +++ user/jceel/soc2014_evdev/contrib/libevdev/test/test-libevdev-has-event.c Tue Aug 12 20:03:23 2014 (r269891) @@ -21,7 +21,11 @@ */ #include +#ifdef __FreeBSD__ +#include +#else #include +#endif #include #include #include Modified: user/jceel/soc2014_evdev/contrib/libevdev/test/test-uinput.c ============================================================================== --- user/jceel/soc2014_evdev/contrib/libevdev/test/test-uinput.c Tue Aug 12 19:57:12 2014 (r269890) +++ user/jceel/soc2014_evdev/contrib/libevdev/test/test-uinput.c Tue Aug 12 20:03:23 2014 (r269891) @@ -21,7 +21,11 @@ */ #include +#ifdef __FreeBSD__ +#include +#else #include +#endif #include #include #include From owner-svn-src-user@FreeBSD.ORG Tue Aug 12 20:08:21 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 48C00742 for ; Tue, 12 Aug 2014 20:08:21 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1F08529D4 for ; Tue, 12 Aug 2014 20:08:21 +0000 (UTC) Received: from jceel (uid 1267) (envelope-from jceel@FreeBSD.org) id 6b1f by svn.freebsd.org (DragonFly Mail Agent v0.9+); Tue, 12 Aug 2014 20:08:21 +0000 From: Jakub Wojciech Klama Date: Tue, 12 Aug 2014 20:08:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r269892 - user/jceel/soc2014_evdev/contrib/libevdev/libevdev X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <53ea7435.6b1f.3551a8c2@svn.freebsd.org> X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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: Tue, 12 Aug 2014 20:08:21 -0000 Author: jceel Date: Tue Aug 12 20:08:20 2014 New Revision: 269892 URL: http://svnweb.freebsd.org/changeset/base/269892 Log: Fix copy-paste-induced typo. Modified: user/jceel/soc2014_evdev/contrib/libevdev/libevdev/libevdev-uinput.c Modified: user/jceel/soc2014_evdev/contrib/libevdev/libevdev/libevdev-uinput.c ============================================================================== --- user/jceel/soc2014_evdev/contrib/libevdev/libevdev/libevdev-uinput.c Tue Aug 12 20:03:23 2014 (r269891) +++ user/jceel/soc2014_evdev/contrib/libevdev/libevdev/libevdev-uinput.c Tue Aug 12 20:08:20 2014 (r269892) @@ -32,9 +32,9 @@ #include #ifdef __FreeBSD__ -#include +#include #else -#include +#include #endif #include "libevdev.h" From owner-svn-src-user@FreeBSD.ORG Tue Aug 12 20:40:16 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DA1D41F3 for ; Tue, 12 Aug 2014 20:40:16 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AFD2A2ED8 for ; Tue, 12 Aug 2014 20:40:16 +0000 (UTC) Received: from jceel (uid 1267) (envelope-from jceel@FreeBSD.org) id 66e6 by svn.freebsd.org (DragonFly Mail Agent v0.9+); Tue, 12 Aug 2014 20:40:16 +0000 From: Jakub Wojciech Klama Date: Tue, 12 Aug 2014 20:40:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r269893 - user/jceel/soc2014_evdev/contrib/libevdev/tools X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <53ea7bb0.66e6.32b37a03@svn.freebsd.org> X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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: Tue, 12 Aug 2014 20:40:16 -0000 Author: jceel Date: Tue Aug 12 20:40:16 2014 New Revision: 269893 URL: http://svnweb.freebsd.org/changeset/base/269893 Log: Fix input.h include path in one more place. Modified: user/jceel/soc2014_evdev/contrib/libevdev/tools/libevdev-events.c Modified: user/jceel/soc2014_evdev/contrib/libevdev/tools/libevdev-events.c ============================================================================== --- user/jceel/soc2014_evdev/contrib/libevdev/tools/libevdev-events.c Tue Aug 12 20:08:20 2014 (r269892) +++ user/jceel/soc2014_evdev/contrib/libevdev/tools/libevdev-events.c Tue Aug 12 20:40:16 2014 (r269893) @@ -29,7 +29,11 @@ #include #include #include +#ifdef __FreeBSD__ +#include +#else #include +#endif #include "libevdev.h" From owner-svn-src-user@FreeBSD.ORG Tue Aug 12 21:51:32 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2AB267A6 for ; Tue, 12 Aug 2014 21:51:32 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F265B27B8 for ; Tue, 12 Aug 2014 21:51:31 +0000 (UTC) Received: from jceel (uid 1267) (envelope-from jceel@FreeBSD.org) id 6340 by svn.freebsd.org (DragonFly Mail Agent v0.9+); Tue, 12 Aug 2014 21:51:31 +0000 From: Jakub Wojciech Klama Date: Tue, 12 Aug 2014 21:51:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r269894 - user/jceel/soc2014_evdev/contrib/python-evdev/evdev X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Message-Id: <53ea8c63.6340.33b6dacd@svn.freebsd.org> X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 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: Tue, 12 Aug 2014 21:51:32 -0000 Author: jceel Date: Tue Aug 12 21:51:31 2014 New Revision: 269894 URL: http://svnweb.freebsd.org/changeset/base/269894 Log: Remove usage of linux-ish data types. Modified: user/jceel/soc2014_evdev/contrib/python-evdev/evdev/uinput.c Modified: user/jceel/soc2014_evdev/contrib/python-evdev/evdev/uinput.c ============================================================================== --- user/jceel/soc2014_evdev/contrib/python-evdev/evdev/uinput.c Tue Aug 12 20:40:16 2014 (r269893) +++ user/jceel/soc2014_evdev/contrib/python-evdev/evdev/uinput.c Tue Aug 12 21:51:31 2014 (r269894) @@ -50,7 +50,7 @@ uinput_open(PyObject *self, PyObject *ar static PyObject * uinput_create(PyObject *self, PyObject *args) { int fd, len, i, abscode; - __u16 vendor, product, version, bustype; + uint16_t vendor, product, version, bustype; PyObject *absinfo = NULL, *item = NULL; @@ -150,7 +150,7 @@ static PyObject * uinput_enable_event(PyObject *self, PyObject *args) { int fd; - __u16 type, code; + uint16_t type, code; unsigned long req; int ret = PyArg_ParseTuple(args, "ihh", &fd, &type, &code); From owner-svn-src-user@FreeBSD.ORG Wed Aug 13 05:03:10 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 78FF6CB0; Wed, 13 Aug 2014 05:03:10 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 669852A09; Wed, 13 Aug 2014 05:03:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s7D53AHD091712; Wed, 13 Aug 2014 05:03:10 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s7D53A3n091711; Wed, 13 Aug 2014 05:03:10 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201408130503.s7D53A3n091711@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Wed, 13 Aug 2014 05:03:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r269905 - user/pho/stress2/misc X-SVN-Group: user 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.18-1 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: Wed, 13 Aug 2014 05:03:10 -0000 Author: pho Date: Wed Aug 13 05:03:09 2014 New Revision: 269905 URL: http://svnweb.freebsd.org/changeset/base/269905 Log: Added new test scenario. Sponsored by: EMC / Isilon storage division Modified: user/pho/stress2/misc/crossmp5.sh Modified: user/pho/stress2/misc/crossmp5.sh ============================================================================== --- user/pho/stress2/misc/crossmp5.sh Wed Aug 13 04:56:27 2014 (r269904) +++ user/pho/stress2/misc/crossmp5.sh Wed Aug 13 05:03:09 2014 (r269905) @@ -76,7 +76,7 @@ else find ${mntpoint}* -type f > /dev/null 2>&1 done else - # The test: Parallel mount and unmounts + # The test: Parallel mount and unmount m=$1 for i in `jot 200`; do mount /dev/md${m}${part} ${mntpoint}$m From owner-svn-src-user@FreeBSD.ORG Sat Aug 16 07:01:43 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5A06913C; Sat, 16 Aug 2014 07:01:43 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 3AA99267A; Sat, 16 Aug 2014 07:01:43 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s7G71gjE070407; Sat, 16 Aug 2014 07:01:42 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s7G71g7I069881; Sat, 16 Aug 2014 07:01:42 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201408160701.s7G71g7I069881@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Sat, 16 Aug 2014 07:01:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r270037 - user/pho/stress2/misc X-SVN-Group: user 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.18-1 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: Sat, 16 Aug 2014 07:01:43 -0000 Author: pho Date: Sat Aug 16 07:01:42 2014 New Revision: 270037 URL: http://svnweb.freebsd.org/changeset/base/270037 Log: Added new regression test, fixed trailing blanks in old tests. Sponsored by: EMC / Isilon storage division Added: user/pho/stress2/misc/ptrace3.sh (contents, props changed) Modified: user/pho/stress2/misc/ptrace.sh user/pho/stress2/misc/ptrace2.sh Modified: user/pho/stress2/misc/ptrace.sh ============================================================================== --- user/pho/stress2/misc/ptrace.sh Sat Aug 16 03:05:02 2014 (r270036) +++ user/pho/stress2/misc/ptrace.sh Sat Aug 16 07:01:42 2014 (r270037) @@ -37,7 +37,7 @@ cc -o ptrace -Wall -Wextra -g ptrace.c | rm -f ptrace.c cd $here -/tmp/ptrace +/tmp/ptrace rm -f /tmp/ptrace exit Modified: user/pho/stress2/misc/ptrace2.sh ============================================================================== --- user/pho/stress2/misc/ptrace2.sh Sat Aug 16 03:05:02 2014 (r270036) +++ user/pho/stress2/misc/ptrace2.sh Sat Aug 16 07:01:42 2014 (r270037) @@ -43,7 +43,7 @@ cat > race1.c < #include -int +int main(void) { pid_t pid; @@ -92,7 +92,7 @@ cat > race2.c < #include -int +int main(void) { pid_t pid; Added: user/pho/stress2/misc/ptrace3.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/ptrace3.sh Sat Aug 16 07:01:42 2014 (r270037) @@ -0,0 +1,130 @@ +#!/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$ +# + +# A regression test for a bug introduced in r269656. +# Page fault in proc_realparent+0x70 seen. +# Fixed in r270024. + +# Test scenario by Mark Johnston markj@ + +here=`pwd` +cd /tmp +sed '1,/^EOF/d' < $here/$0 > ptrace3.c +cc -o ptrace3 -Wall -Wextra -g ptrace3.c || exit 1 +rm -f ptrace3.c +cd $here + +/tmp/ptrace3 + +rm -f /tmp/ptrace3 +exit +EOF +#include +#include +#include + +#include +#include +#include + +/* + * A regression test for a bug introduced in r269656. The test process p creates + * child processes c1 and c2 which do nothing but sleep; a third child process + * (c3) uses ptrace(2) to reparent c1 and c2 from p to c3. Then c3 detaches from + * c1 and c2, causing a crash when c1 and c2 are removed from p's now-corrupt + * orphan list. + */ + +pid_t +sleeper() +{ + pid_t p; + + p = fork(); + if (p == -1) + err(1, "fork"); + else if (p == 0) + while (1) + sleep(1000000); + return (p); +} + +void +attach(pid_t p) +{ + int status; + + if (ptrace(PT_ATTACH, p, 0, 0) == -1) + err(1, "ptrace"); + + if (waitpid(p, &status, 0) == -1) + err(1, "waitpid"); + else if (!WIFSTOPPED(status)) + errx(1, "failed to stop child"); +} + +void +detach(pid_t p) +{ + + if (ptrace(PT_DETACH, p, 0, 0) == -1) + err(1, "ptrace"); +} + +int +main(void) +{ + int status; + pid_t c1, c2, p; + + c1 = sleeper(); + c2 = sleeper(); + + p = fork(); + if (p == -1) { + err(1, "fork"); + } else if (p == 0) { + attach(c1); + attach(c2); + detach(c1); + detach(c2); + } else { + if (waitpid(p, &status, 0) == -1) + err(1, "waitpid"); + if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) + errx(1, "child exited abnormally"); + } + + /* Clean up. */ + (void)kill(c1, SIGKILL); + (void)kill(c2, SIGKILL); + + return (0); +}