Index: user/pho/stress2/misc/kevent.sh =================================================================== --- user/pho/stress2/misc/kevent.sh (revision 333013) +++ user/pho/stress2/misc/kevent.sh (revision 333014) @@ -1,176 +1,176 @@ #!/bin/sh # # Copyright (c) 2008 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # panic: KN_INFLUX set when not suppose to be . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > kevent.c -mycc -o kevent -Wall kevent.c -pthread +mycc -o kevent -Wall kevent.c -pthread || exit 1 rm -f kevent.c [ -d "$RUNDIR" ] || mkdir -p $RUNDIR cd $RUNDIR for i in `jot 10`; do for j in `jot 12`; do /tmp/kevent > /dev/null 2>&1 & done wait done rm -f /tmp/kevent exit EOF -#include #include #include + #include +#include #include #include #include #include #include pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t cond = PTHREAD_COND_INITIALIZER; static int waiting; static int fd1[2]; static int fd2[2]; static int fd3[2]; #define RUNTIME 12 -void * +static void * thr1(void *arg) { - int n, r; - int kq = -1; struct kevent ev[3]; + int kq, n, r; if ((kq = kqueue()) < 0) err(1, "kqueue(). %s:%d", __FILE__, __LINE__); n = 0; EV_SET(&ev[n], fd1[1], EVFILT_WRITE, EV_ADD | EV_ENABLE | EV_CLEAR, 0, 0, 0); n++; EV_SET(&ev[n], fd2[1], EVFILT_WRITE, EV_ADD | EV_ENABLE | EV_CLEAR, 0, 0, 0); n++; EV_SET(&ev[n], fd3[1], EVFILT_WRITE, EV_ADD | EV_ENABLE | EV_CLEAR, 0, 0, 0); n++; if (kevent(kq, ev, n, NULL, 0, NULL) < 0) err(1, "kevent(). %s:%d", __FILE__, __LINE__); if ((r = pthread_mutex_lock(&mutex)) != 0) errc(1, r, "pthread_mutex_lock"); waiting = 0; if ((r = pthread_cond_signal(&cond)) != 0) errc(1, r, "pthread_cond_signal"); if ((r = pthread_mutex_unlock(&mutex)) != 0) errc(1, r, "pthread_mutex_unlock"); n = 0; EV_SET(&ev[n], fd1[1], EVFILT_WRITE, EV_DELETE, 0, 0, 0); n++; if (kevent(kq, ev, n, NULL, 0, NULL) < 0) warn("kevent(). %s:%d", __FILE__, __LINE__); close(kq); return (0); } -void * +static void * thr2(void *arg) { int r; if ((r = pthread_mutex_lock(&mutex)) != 0) errc(1, r, "pthread_mutex_lock"); while (waiting == 1) { if ((r = pthread_cond_wait(&cond, &mutex)) != 0) errc(1, r, "pthread_cond_wait"); } if ((r = pthread_mutex_unlock(&mutex)) != 0) errc(1, r, "pthread_mutex_unlock"); close(fd1[0]); close(fd1[1]); close(fd2[0]); close(fd2[1]); close(fd3[0]); close(fd3[1]); return (0); } int main(int argc, char **argv) { pthread_t threads[2]; time_t start; int r; start = time(NULL); while (time(NULL) - start < RUNTIME) { waiting = 1; if (pipe(fd1) == -1) err(1, "pipe()"); if (pipe(fd2) == -1) err(1, "pipe()"); if (pipe(fd3) == -1) err(1, "pipe()"); if ((r = pthread_mutex_init(&mutex, 0)) != 0) errc(1, r, "pthread_mutex_init"); if ((r = pthread_cond_init(&cond, NULL)) != 0) errc(1, r, "pthread_cond_init"); if ((r = pthread_create(&threads[0], NULL, thr1, 0)) != 0) errc(1, r, "pthread_create()"); if ((r = pthread_create(&threads[1], NULL, thr2, 0)) != 0) errc(1, r, "pthread_create()"); if ((r = pthread_join(threads[0], NULL)) != 0) errc(1, r, "pthread_join(%d)", 0); if ((r = pthread_join(threads[1], NULL)) != 0) errc(1, r, "pthread_join(%d)", 1); if ((r = pthread_mutex_destroy(&mutex)) != 0) errc(1, r, "pthread_mutex_destroy"); if ((r = pthread_cond_destroy(&cond)) != 0) errc(1, r, "pthread_cond_destroy)"); } return (0); } Index: user/pho/stress2/misc/kevent10.sh =================================================================== --- user/pho/stress2/misc/kevent10.sh (revision 333013) +++ user/pho/stress2/misc/kevent10.sh (revision 333014) @@ -1,68 +1,71 @@ #!/bin/sh # Regression test for # https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=217435 # by Tim Newsham # panic: Assertion size > 0 failed at ../../../kern/subr_vmem.c:1082 # cpuid = 2 # time = 1501182301 # KDB: stack backtrace: # db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe0173117650 # vpanic() at vpanic+0x19c/frame 0xfffffe01731176d0 # kassert_panic() at kassert_panic+0x126/frame 0xfffffe0173117740 # vmem_alloc() at vmem_alloc+0x11b/frame 0xfffffe0173117780 # kmem_malloc() at kmem_malloc+0x33/frame 0xfffffe01731177b0 # uma_large_malloc() at uma_large_malloc+0x48/frame 0xfffffe01731177f0 # malloc() at malloc+0xe3/frame 0xfffffe0173117840 # ktrgenio() at ktrgenio+0x60/frame 0xfffffe0173117880 # sys_kevent() at sys_kevent+0x12f/frame 0xfffffe0173117930 # amd64_syscall() at amd64_syscall+0x7d2/frame 0xfffffe0173117ab0 # Fixed by r315155. +# $FreeBSD$ + . ../default.cfg cat > /tmp/kevent10.c < #include #include #include #include #include #include #include #include #include #include #include int main(void) { - char *fn = "/tmp/trace"; struct kevent changes; struct kevent events; + char *fn = "/tmp/kevent10.trace"; if (open(fn, O_RDWR | O_CREAT, 0666) == -1) err(1, "%s", fn); if (ktrace(fn, KTRFLAG_DESCEND | KTROP_SET, KTRFAC_GENIO, 0) == -1) err(1, "ktrace"); memset(&changes, 0, sizeof(struct kevent)); memset(&events, 0, sizeof(struct kevent)); if (kevent(0, &changes, -1, &events, 1, 0) == -1) if (errno != EBADF) err(1, "kevent"); + return (0); } EOF mycc -o /tmp/kevent10 -Wall -Wextra -O2 /tmp/kevent10.c || exit 1 rm /tmp/kevent10.c /tmp/kevent10 s=$? -rm /tmp/kevent10 +rm /tmp/kevent10 /tmp/kevent10.trace exit $s Index: user/pho/stress2/misc/kevent11.sh =================================================================== --- user/pho/stress2/misc/kevent11.sh (revision 333013) +++ user/pho/stress2/misc/kevent11.sh (revision 333014) @@ -1,181 +1,180 @@ #!/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$ # # Variation of kevent5.sh # OOM seen: https://people.freebsd.org/~pho/stress/log/mark018.txt . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/kevent11.c mycc -o kevent11 -Wall -Wextra -O0 -g kevent11.c || exit 1 rm -f kevent11.c cd $odir set -e mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 2g -u $mdstart bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint set +e (cd $odir/../testcases/swap; ./swap -t 5m -i 20 -h -l 100 > /dev/null) & cd $mntpoint $dir/kevent11 s=$? [ -f kevent11.core -a $s -eq 0 ] && { ls -l kevent11.core; mv kevent11.core /tmp; s=1; } cd $odir while pkill -9 swap; do :; done wait for i in `jot 6`; do mount | grep -q "on $mntpoint " || break umount $mntpoint && break || sleep 10 done [ $i -eq 6 ] && exit 1 mdconfig -d -u $mdstart rm -rf $dir/kevent11 exit $s EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include static volatile u_int *share; static char *file = "file"; #define PARALLEL 256 #define RUNTIME (3 * 60) #define SYNC 0 static void test(void) { struct kevent ev[2]; struct timespec ts; - int kq = -1; - int fd, n; + int kq, fd, n; if ((fd = open(file, O_RDONLY, 0)) == -1) err(1, "open(%s). %s:%d", file, __func__, __LINE__); if ((kq = kqueue()) < 0) err(1, "kqueue()"); n = 0; EV_SET(&ev[n], fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR, NOTE_DELETE, 0, 0); n++; if (kevent(kq, ev, n, NULL, 0, NULL) < 0) err(1, "kevent()"); setproctitle("presync"); atomic_add_int(&share[SYNC], 1); while (share[SYNC] != PARALLEL) usleep(10000); setproctitle("postsync"); memset(&ev, 0, sizeof(ev)); n = kevent(kq, NULL, 0, ev, 1, &ts); close(fd); close(kq); _exit(0); } int main(void) { pid_t pids[PARALLEL]; size_t len; time_t start; int e, fd, 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"); start = time(NULL); while ((time(NULL) - start) < RUNTIME && e == 0) { if ((fd = open(file, O_CREAT | O_TRUNC | O_RDWR, 0660)) == -1) err(1, "open(%s)", file); close(fd); share[SYNC] = 0; for (i = 0; i < PARALLEL; i++) { if ((pids[i] = fork()) == 0) test(); if (pids[i] == -1) err(1, "fork()"); } while (share[SYNC] != PARALLEL) usleep(10000); if (unlink(file) == -1) err(1, "unlink(%s). %s:%d\n", file, __FILE__, __LINE__); 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); } Index: user/pho/stress2/misc/kevent2.sh =================================================================== --- user/pho/stress2/misc/kevent2.sh (revision 333013) +++ user/pho/stress2/misc/kevent2.sh (revision 333014) @@ -1,176 +1,172 @@ #!/bin/sh # # Copyright (c) 2008 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > kevent2.c -mycc -o kevent2 -Wall kevent2.c -pthread +mycc -o kevent2 -Wall kevent2.c -pthread || exit 1 rm -f kevent2.c cd $RUNDIR for i in `jot 10`; do for j in `jot 12`; do /tmp/kevent2 > /dev/null 2>&1 & done wait done rm -f /tmp/kevent2 exit EOF -#include #include -#include #include +#include + #include +#include #include #include #include #include pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t cond = PTHREAD_COND_INITIALIZER; static int waiting; static int fd1[2]; static int fd2[2]; static int fd3[2]; -void * +static void * thr1(void *arg) { - int n, r; - int kq = -1; struct kevent ev[3]; struct timespec ts; + int kq, n, r; if ((kq = kqueue()) < 0) err(1, "kqueue(). %s:%d", __FILE__, __LINE__); n = 0; EV_SET(&ev[n], fd1[1], EVFILT_WRITE, EV_ADD | EV_ENABLE | EV_CLEAR, 0, 0, 0); n++; EV_SET(&ev[n], fd2[1], EVFILT_WRITE, EV_ADD | EV_ENABLE | EV_CLEAR, 0, 0, 0); n++; EV_SET(&ev[n], fd3[1], EVFILT_WRITE, EV_ADD | EV_ENABLE | EV_CLEAR, 0, 0, 0); n++; if (kevent(kq, ev, n, NULL, 0, NULL) < 0) err(1, "kevent(). %s:%d", __FILE__, __LINE__); if ((r = pthread_mutex_lock(&mutex)) != 0) errc(1, r, "pthread_mutex_lock"); waiting = 0; if ((r = pthread_cond_signal(&cond)) != 0) errc(1, r, "pthread_cond_signal"); if ((r = pthread_mutex_unlock(&mutex)) != 0) errc(1, r, "pthread_mutex_unlock"); n = 0; EV_SET(&ev[n], fd1[1], EVFILT_WRITE, EV_DELETE, 0, 0, 0); n++; ts.tv_sec = 0; ts.tv_nsec = 0; if (kevent(kq, ev, n, NULL, 0, &ts) < 0) err(1, "kevent(). %s:%d", __FILE__, __LINE__); close(kq); -// printf("%s:%d\n", __FILE__, __LINE__); fflush(stdout); close(fd1[1]); close(fd2[1]); close(fd3[1]); return (0); } -void * +static void * thr2(void *arg) { int r; if ((r = pthread_mutex_lock(&mutex)) != 0) errc(1, r, "pthread_mutex_lock"); while (waiting == 1) { if ((r = pthread_cond_wait(&cond, &mutex)) != 0) errc(1, r, "pthread_cond_wait"); } if ((r = pthread_mutex_unlock(&mutex)) != 0) errc(1, r, "pthread_mutex_unlock"); -// printf("%s:%d\n", __FILE__, __LINE__); fflush(stdout); close(fd1[0]); close(fd2[0]); close(fd3[0]); return (0); } int main(int argc, char **argv) { pthread_t threads[2]; - int r; - int i; + int i, r; for (i = 0; i < 1000; i++) { waiting = 1; -// printf("%s:%d\n", __FILE__, __LINE__); fflush(stdout); if (pipe(fd1) == -1) err(1, "pipe()"); if (pipe(fd2) == -1) err(1, "pipe()"); if (pipe(fd3) == -1) err(1, "pipe()"); if ((r = pthread_mutex_init(&mutex, 0)) != 0) errc(1, r, "pthread_mutex_init"); if ((r = pthread_cond_init(&cond, NULL)) != 0) errc(1, r, "pthread_cond_init"); if ((r = pthread_create(&threads[0], NULL, thr1, 0)) != 0) errc(1, r, "pthread_create()"); if ((r = pthread_create(&threads[1], NULL, thr2, 0)) != 0) errc(1, r, "pthread_create()"); if ((r = pthread_join(threads[0], NULL)) != 0) errc(1, r, "pthread_join(%d)", 0); if ((r = pthread_join(threads[1], NULL)) != 0) errc(1, r, "pthread_join(%d)", 1); if ((r = pthread_mutex_destroy(&mutex)) != 0) errc(1, r, "pthread_mutex_destroy"); if ((r = pthread_cond_destroy(&cond)) != 0) errc(1, r, "pthread_condattr_destroy"); } return (0); } Index: user/pho/stress2/misc/kevent3.sh =================================================================== --- user/pho/stress2/misc/kevent3.sh (revision 333013) +++ user/pho/stress2/misc/kevent3.sh (revision 333014) @@ -1,73 +1,76 @@ #!/bin/sh # # Copyright (c) 2008 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > kevent3.c -mycc -o kevent3 -Wall kevent3.c -pthread +mycc -o kevent3 -Wall kevent3.c -pthread || exit 1 rm -f kevent3.c cd $RUNDIR for i in `jot 64`; do for j in `jot 12`; do /tmp/kevent3 > /dev/null 2>&1 & done for j in `jot 12`; do wait done done rm -f /tmp/kevent3 -exit +exit 0 EOF /* * Obtained from: * http://projects.info-pull.com/mokb/MOKB-24-11-2006.html */ #include #include #include + #include #include int main(void) { struct kevent ke; int kq; + kq = kqueue(); EV_SET(&ke, getpid(), EVFILT_PROC, EV_ADD, NOTE_EXIT|NOTE_EXEC|NOTE_TRACK, 0, NULL); kevent(kq, &ke, 1, NULL, 0, NULL); if (fork() != 0) kevent(kq, NULL, 0, &ke, 1, NULL); + return (0); } Index: user/pho/stress2/misc/kevent4.sh =================================================================== --- user/pho/stress2/misc/kevent4.sh (revision 333013) +++ user/pho/stress2/misc/kevent4.sh (revision 333014) @@ -1,203 +1,177 @@ #!/bin/sh # # Copyright (c) 2008 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # Test scenario by kib@ . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > kevent4.c -mycc -o kevent4 -Wall kevent4.c -pthread +mycc -o kevent4 -Wall kevent4.c -pthread || exit 1 rm -f kevent4.c cd $odir export runRUNTIME=3m (cd ..; ./run.sh > /dev/null 2>&1) & rpid=$! (cd $RUNDIR; /tmp/kevent4 $rpid > /dev/null) & sleep 120 kill $rpid ../tools/killall.sh > /dev/null 2>&1 kill $! wait rm -f /tmp/kevent4 exit EOF // $FreeBSD$ -#include #include #include + +#include #include #include #include #include #ifndef true # define true 1 #endif -int kq; +static int kq; -void +static void err(const char *msg, int err_no) { fprintf(stderr, "%s: %s\n", msg, strerror(err_no)); exit(1); } -void +static void init_kq() { kq = kqueue(); if (kq == -1) err("kqueue", errno); } -void +static void add_watch(pid_t pid) { struct kevent kev; + bzero(&kev, sizeof(kev)); kev.ident = pid; kev.flags = EV_ADD | EV_ENABLE; kev.filter = EVFILT_PROC; kev.fflags = NOTE_EXIT | NOTE_FORK | NOTE_EXEC | NOTE_TRACK; while (true) { int res = kevent(kq, &kev, 1, NULL, 0, NULL); if (res == -1) { if (errno == EINTR) continue; if (errno == ESRCH) break; int err_no = errno; char msg[64]; snprintf(msg, sizeof(msg), "kevent - add watch for pid %u", pid); err(msg, err_no); } else break; } } -void -del_watch(pid_t pid) +static void polling() { - struct kevent kev; - bzero(&kev, sizeof(kev)); - kev.ident = pid; - kev.flags = EV_DELETE; - kev.filter = EVFILT_PROC; - - while (true) { - int res = kevent(kq, &kev, 1, NULL, 0, NULL); - if (res == -1) { - if (errno == EINTR) - continue; - if (errno == ESRCH) - break; - - int err_no = errno; - char msg[64]; - snprintf(msg, sizeof(msg), - "kevent - del watch for pid %u", pid); - err(msg, err_no); - } - else - break; - } -} - -void polling() -{ struct kevent kev[10]; pid_t pid; int i; while (true) { bzero(&kev, sizeof(kev)); int res = kevent(kq, NULL, 0, kev, sizeof(kev) / sizeof(kev[0]), NULL); if (res == -1) { if (errno == EINTR) continue; if (errno == ESRCH) continue; err("kevent", errno); } for (i = 0; i < res; i++) { pid = kev[i].ident; if (kev[i].fflags & NOTE_CHILD) { add_watch(pid); - printf("%u - new process, parent %u\n", pid, (unsigned int)kev[i].data); + printf("%u - new process, parent %u\n", pid, + (unsigned int)kev[i].data); } if (kev[i].fflags & NOTE_FORK) { printf("%u forked\n", pid); } if (kev[i].fflags & NOTE_EXEC) { printf("%u called exec\n", pid); } if (kev[i].fflags & NOTE_EXIT) { printf("%u exited\n", pid); -// del_watch(pid); } if (kev[i].fflags & NOTE_TRACK) { printf("%u forked - track\n", pid); } if (kev[i].fflags & NOTE_TRACKERR) { fprintf(stderr, "%u - track error\n", pid); } } } } int main(int argc, char *argv[]) { if (argc != 2) { fprintf(stderr, "pid ?\n"); return (2); } pid_t parent = atoi(argv[1]); init_kq(); add_watch(parent); polling(); return (0); } Index: user/pho/stress2/misc/kevent5.sh =================================================================== --- user/pho/stress2/misc/kevent5.sh (revision 333013) +++ user/pho/stress2/misc/kevent5.sh (revision 333014) @@ -1,166 +1,185 @@ #!/bin/sh # # Copyright (c) 2008 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # Test EVFILT_VNODE. Found page fault in knlist_add+0x39 # # Test scenario by kib@ . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > kevent5.c mycc -o kevent5 -Wall -Wextra -O2 -g kevent5.c || exit 1 rm -f kevent5.c [ -d $RUNDIR ] || mkdir -p $RUNDIR cd $RUNDIR -/tmp/kevent5 kevent5.xxx kevent5.yyy > /dev/null 2>&1 +/tmp/kevent5 kevent5.xxx kevent5.yyy +s=$? rm -f /tmp/kevent5 kevent.xxx kevent.yyy -exit +exit $s EOF -#include +#include #include #include #include +#include + #include #include #include #include #include #include #include #include +volatile u_int *share; + static char *file1, *file2; #define N 1000 +#define SYNC 0 - -void +static void test(void) { - int kq = -1; - int n; + struct kevent ev[2]; struct timespec ts; - int fd; + int fd, kq, n; if ((fd = open(file1, O_RDONLY, 0)) == -1) err(1, "open(%s)(2)", file1); + atomic_add_int(&share[SYNC], 1); if ((kq = kqueue()) < 0) err(1, "kqueue()"); n = 0; EV_SET(&ev[n], fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR, NOTE_DELETE, 0, 0); n++; ts.tv_sec = 5; ts.tv_nsec = 0; if (kevent(kq, ev, n, NULL, 0, &ts) < 0) err(1, "kevent()"); memset(&ev, 0, sizeof(ev)); n = kevent(kq, NULL, 0, ev, 1, NULL); -// printf("Event 1\n"); close(fd); close(kq); /* Once the rendezvous file is gone create a new kevent */ if ((fd = open(file2, O_RDONLY, 0)) == -1) err(1, "open(%s)(2)", file2); if ((kq = kqueue()) < 0) err(1, "kqueue()"); n = 0; EV_SET(&ev[n], fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR, NOTE_DELETE, 0, 0); n++; if (kevent(kq, ev, n, NULL, 0, NULL) < 0) err(1, "kevent()"); memset(&ev, 0, sizeof(ev)); n = kevent(kq, NULL, 0, ev, 1, &ts); -// printf("Event 2\n"); close(fd); close(kq); } int main(int argc, char **argv) { - int i, j; - int fd; - int status; + size_t len; + int e, fd, i, j, status; if (argc != 3) { - fprintf(stderr, "Usage: %s \n", argv[0]); + fprintf(stderr, "Usage: %s \n", + argv[0]); return (1); } + len = PAGE_SIZE; + if ((share = mmap(NULL, len, PROT_READ | PROT_WRITE, + MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED) + err(1, "mmap"); + + e = 0; file1 = argv[1]; file2 = argv[2]; - for (j = 0; j < 100; j++) { - if ((fd = open(file1, O_CREAT | O_TRUNC | O_RDWR, 0660)) == -1) + for (j = 0; j < 100 && e == 0; j++) { + if ((fd = open(file1, O_CREAT | O_TRUNC | O_RDWR, 0660)) == + -1) err(1, "open(%s)", file1); close(fd); - if ((fd = open(file2, O_CREAT | O_TRUNC | O_RDWR, 0660)) == -1) + if ((fd = open(file2, O_CREAT | O_TRUNC | O_RDWR, 0660)) == + -1) err(1, "open(%s)", file2); close(fd); + share[SYNC] = 0; for (i = 0; i < N; i++) { if (fork() == 0) { test(); return (0); } } + while (share[SYNC] != N) + usleep(200); + sleep(1); if (unlink(file1) == -1) - err(1, "unlink(%s). %s:%d\n", file1, __FILE__, __LINE__); - sleep(1); + err(1, "unlink(%s). %s:%d\n", file1, __FILE__, + __LINE__); + sleep(2); if (unlink(file2) == -1) - err(1, "unlink(%s). %s:%d\n", file2, __FILE__, __LINE__); + err(1, "unlink(%s). %s:%d\n", file2, __FILE__, + __LINE__); for (i = 0; i < N; i++) { if (wait(&status) == -1) err(1, "wait(), %s:%d", __FILE__, __LINE__); + if (status != 0) + e = 1; } } - return (0); + return (e); } Index: user/pho/stress2/misc/kevent6.sh =================================================================== --- user/pho/stress2/misc/kevent6.sh (revision 333013) +++ user/pho/stress2/misc/kevent6.sh (revision 333014) @@ -1,169 +1,171 @@ #!/bin/sh # # Copyright (c) 2013 EMC Corp. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # "Sleeping thread (tid 101094, pid 13104) owns a non-sleepable lock" seen. # Fixed in r255798. # panic: Memory modified after free: # https://people.freebsd.org/~pho/stress/log/alan011.txt # https://people.freebsd.org/~pho/stress/log/kevent6.txt # Fixed by: r286921 +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > kevent6.c mycc -o kevent6 -Wall -Wextra -O2 -g kevent6.c -lpthread || exit 1 rm -f kevent6.c cd $odir mount | grep "on $mntpoint " | grep -q md$mdstart && umount -f $mntpoint mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 2g -u $mdstart bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint chmod 777 $mntpoint su $testuser -c "(cd $mntpoint; /tmp/kevent6)" while mount | grep -q $mntpoint; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart mount -o size=1g -t tmpfs tmpfs $mntpoint chmod 777 $mntpoint su $testuser -c "(cd $mntpoint; /tmp/kevent6)" while mount | grep -q $mntpoint; do umount $mntpoint || sleep 1 done rm -f /tmp/kevent6 exit EOF #include +#include +#include +#include + #include #include #include #include #include #include #include #include #include -#include -#include -#include #include #define LOOPS 500000 #define PARALLEL 8 +static int fd; static char path[80]; -int fd; - -void * +static void * spin(void *arg __unused) { int i; for (i= 0;; i++) { snprintf(path, sizeof(path), "file.%06d.%d", getpid(), i); - if ((fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0622)) == -1) + if ((fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0622)) == + -1) err(1, "creat()"); close(fd); usleep(10000); fd = 0; unlink(path); } return (NULL); } -void * +static void * test(void *arg __unused) { int kq; int i, n; struct kevent ev; struct timespec ts; for (i = 0; i < LOOPS; i++) { if ((kq = kqueue()) < 0) err(1, "kqueue()"); n = 0; memset(&ev, 0, sizeof(ev)); EV_SET(&ev, fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR, NOTE_DELETE|NOTE_RENAME|NOTE_EXTEND, 0, 0); n++; if (kevent(kq, &ev, n, NULL, 0, NULL) < 0) { close(kq); continue; } memset(&ev, 0, sizeof(ev)); ts.tv_sec = 0; ts.tv_nsec = 1000000; if ((n = kevent(kq, NULL, 0, &ev, 1, &ts)) == -1) err(1, "kevent()"); close(kq); } return (NULL); } int main(void) { pthread_t cp[PARALLEL], sp; int e, i; if ((e = pthread_create(&sp, NULL, spin, NULL)) != 0) errc(1, e, "pthread_create"); for (i = 0; i < PARALLEL; i++) { if ((e = pthread_create(&cp[i], NULL, test, NULL)) != 0) errc(1, e, "pthread_create"); } for (i = 0; i < PARALLEL; i++) pthread_join(cp[i], NULL); close(fd); return (0); } Index: user/pho/stress2/misc/kevent8.sh =================================================================== --- user/pho/stress2/misc/kevent8.sh (revision 333013) +++ user/pho/stress2/misc/kevent8.sh (revision 333014) @@ -1,161 +1,166 @@ #!/bin/sh # # Copyright (c) 2013 EMC Corp. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # Out of VM seen due to missing close of kqueue handle. # Fixed in 256849 . ../default.cfg -ulimit -k 10000 || { echo FAIL; exit 1; } +[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 +ulimit -k 5000 || { echo FAIL; exit 1; } odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > kevent8.c mycc -o kevent8 -Wall -Wextra -O2 -g kevent8.c -lpthread || exit 1 rm -f kevent8.c cd $odir mount | grep "on $mntpoint " | grep -q md$mdstart && umount -f $mntpoint mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart -mdconfig -a -t swap -s 2g -u ${mdstart} +mdconfig -a -t swap -s 2g -u $mdstart bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint chmod 777 $mntpoint su $testuser -c "(cd $mntpoint; /tmp/kevent8)" & -sleep 99 +for i in `jot 99`; do + sleep 1 + kill -0 $! 2>/dev/null || break +done umount -f $mntpoint pkill kevent8 wait while mount | grep -q $mntpoint; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/kevent8 exit EOF #include -#include #include +#include +#include + #include #include #include #include +#include +#include #include #include #include #include -#include -#include -#include #define PARALLEL 64 +static int fd; static char path[80]; -int fd; - -void * +static void * spin(void *arg __unused) { int i; setproctitle("spin"); for (i= 0;; i++) { snprintf(path, sizeof(path), "file.%06d.%d", getpid(), i); - if ((fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0622)) == -1) + if ((fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0622)) == + -1) err(1, "creat()"); close(fd); fd = 0; unlink(path); } return (NULL); } -void * +static void * test(void *arg __unused) { int kq; int i, n; struct kevent ev; struct timespec ts; for (i = 0; i < 500000; i++) { if ((kq = kqueue()) < 0) if (errno != ENOMEM) err(1, "kqueue()"); n = 0; memset(&ev, 0, sizeof(ev)); EV_SET(&ev, fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR, NOTE_DELETE|NOTE_RENAME|NOTE_EXTEND, 0, 0); n++; if (kevent(kq, &ev, n, NULL, 0, NULL) < 0) continue; /* Note: missing close(kq)! */ memset(&ev, 0, sizeof(ev)); ts.tv_sec = 0; ts.tv_nsec = 1000000; if ((n = kevent(kq, NULL, 0, &ev, 1, &ts)) == -1) err(1, "kevent()"); close(kq); } return (NULL); } int main(void) { pthread_t cp[PARALLEL], sp; int e, i; if ((e = pthread_create(&sp, NULL, spin, NULL)) != 0) errc(1, e, "pthread_create"); for (i = 0; i < PARALLEL; i++) { if ((e = pthread_create(&cp[i], NULL, test, NULL)) != 0) errc(1, e, "pthread_create"); } for (i = 0; i < PARALLEL; i++) pthread_join(cp[i], NULL); close(fd); return (0); } Index: user/pho/stress2/misc/kevent9.sh =================================================================== --- user/pho/stress2/misc/kevent9.sh (revision 333013) +++ user/pho/stress2/misc/kevent9.sh (revision 333014) @@ -1,206 +1,208 @@ #!/bin/sh # $FreeBSD$ # Test scenario by Eric Badger # userret: returning with the following locks held: # exclusive sleep mutex process lock (process lock) r = 0 (0xcb714758) # locked @ kern/kern_event.c:2125 # panic: witness_warn # https://people.freebsd.org/~pho/stress/log/kevent9.txt # Fixed in r302235. . ../default.cfg [ `sysctl -n hw.ncpu` -ne 4 ] && echo "For best results use hw.ncpu == 4" cd /tmp cat > /tmp/kevent9-1.c < -#include -#include -#include #include #include +#include #include -#include +#include + +#include #include #include -#include +#include +#include #include -#include +#include +#include #define NUM_PROCS 4000 void *procmaker(void *arg __unused) { pthread_set_name_np(pthread_self(), "procmaker"); for (int i = 0; i < NUM_PROCS; ++i) { struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = 50000; nanosleep(&ts, NULL); switch(fork()) { case -1: err(1, "fork"); break; case 0: execl("./kevent9-2", "kevent9-2", NULL); _exit(127); break; default: break; } } printf("done forking\n"); return NULL; } void *reaper(void *arg __unused) { pthread_set_name_np(pthread_self(), "reaper"); int counter = 0; while (counter < NUM_PROCS) { int status; if (wait(&status) > 0) { ++counter; } } printf("Reaped %d\n", counter); return NULL; } int main() { pthread_set_name_np(pthread_self(), "main"); int kqfd = kqueue(); if (kqfd == -1) { err(1, "kqueue()"); } struct kevent change; memset(&change, 0, sizeof(change)); change.ident = getpid(); change.filter = EVFILT_PROC; change.flags = EV_ADD | EV_ENABLE; change.fflags = NOTE_EXIT | NOTE_EXEC | NOTE_FORK | NOTE_TRACK; if (kevent(kqfd, &change, 1, NULL, 0, NULL) == -1) { err(1, "kevent change"); } pthread_t t; pthread_create(&t, NULL, procmaker, NULL); pthread_create(&t, NULL, reaper, NULL); int numexecs = 0; int numexits = 0; int numforks = 0; int nummults = 0; int numchlds = 0; int numterrs = 0; while (1) { struct kevent event; struct timespec to; to.tv_sec = 1; to.tv_nsec = 0; int ret = kevent(kqfd, NULL, 0, &event, 1, &to); if (ret == -1) { err(1, "kevent event"); } else if (ret == 0) { printf("numexecs: %d numexits: %d numforks: %d numchlds: %d numterrs: %d nummults: %d\n", numexecs, numexits, numforks, numchlds, numterrs, nummults); // Sometimes we miss a NOTE_EXIT. If it hasn't arrived by the timeout, bail out since // it will probably never arrive. break; /* if (numexits == NUM_PROCS) { break; } else { continue; } */ } int numflags = 0; if (event.fflags & NOTE_EXEC) { ++numflags; ++numexecs; } if (event.fflags & NOTE_EXIT) { ++numflags; ++numexits; } if (event.fflags & NOTE_FORK) { ++numflags; ++numforks; } if (event.fflags & NOTE_CHILD) { ++numflags; ++numchlds; } if (event.fflags & NOTE_TRACKERR) { ++numflags; ++numterrs; } if (numflags > 1) { ++nummults; } /* struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = 50000; nanosleep(&ts, NULL); */ } return 0; } EOF cat > /tmp/kevent9-2.c < int main() { struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = 1000; nanosleep(&ts, NULL); return 0; } EOF mycc -o kevent9-1 -Wall -Wextra -O2 -g kevent9-1.c -lpthread || exit 1 mycc -o kevent9-2 -Wall -Wextra -O2 -g kevent9-2.c || exit 1 rm kevent9-1.c kevent9-2.c start=`date '+%s'` while [ $((`date '+%s'` - start)) -lt 300 ]; do ./kevent9-1 > /dev/null done rm kevent9-1 kevent9-2 +exit 0