Property changes on: . ___________________________________________________________________ Modified: svn:mergeinfo Merged /head/sys:r193951 Index: kern/uipc_mqueue.c =================================================================== --- kern/uipc_mqueue.c (revision 202809) +++ kern/uipc_mqueue.c (working copy) @@ -1502,8 +1502,8 @@ mq->mq_msgsize = default_msgsize; } mtx_init(&mq->mq_mutex, "mqueue", NULL, MTX_DEF); - knlist_init(&mq->mq_rsel.si_note, &mq->mq_mutex, NULL, NULL, NULL); - knlist_init(&mq->mq_wsel.si_note, &mq->mq_mutex, NULL, NULL, NULL); + knlist_init_mtx(&mq->mq_rsel.si_note, &mq->mq_mutex); + knlist_init_mtx(&mq->mq_wsel.si_note, &mq->mq_mutex); atomic_add_int(&curmq, 1); return (mq); } Index: kern/init_main.c =================================================================== --- kern/init_main.c (revision 202809) +++ kern/init_main.c (working copy) @@ -435,7 +435,7 @@ p->p_sysent = &null_sysvec; p->p_flag = P_SYSTEM | P_INMEM; p->p_state = PRS_NORMAL; - knlist_init(&p->p_klist, &p->p_mtx, NULL, NULL, NULL); + knlist_init_mtx(&p->p_klist, &p->p_mtx); STAILQ_INIT(&p->p_ktr); p->p_nice = NZERO; td->td_tid = PID_MAX + 1; Index: kern/uipc_socket.c =================================================================== --- kern/uipc_socket.c (revision 202809) +++ kern/uipc_socket.c (working copy) @@ -370,10 +370,8 @@ #ifdef MAC mac_create_socket(cred, so); #endif - knlist_init(&so->so_rcv.sb_sel.si_note, SOCKBUF_MTX(&so->so_rcv), - NULL, NULL, NULL); - knlist_init(&so->so_snd.sb_sel.si_note, SOCKBUF_MTX(&so->so_snd), - NULL, NULL, NULL); + knlist_init_mtx(&so->so_rcv.sb_sel.si_note, SOCKBUF_MTX(&so->so_rcv)); + knlist_init_mtx(&so->so_snd.sb_sel.si_note, SOCKBUF_MTX(&so->so_snd)); so->so_count = 1; /* * Auto-sizing of socket buffers is managed by the protocols and @@ -439,10 +437,8 @@ mac_create_socket_from_socket(head, so); SOCK_UNLOCK(head); #endif - knlist_init(&so->so_rcv.sb_sel.si_note, SOCKBUF_MTX(&so->so_rcv), - NULL, NULL, NULL); - knlist_init(&so->so_snd.sb_sel.si_note, SOCKBUF_MTX(&so->so_snd), - NULL, NULL, NULL); + knlist_init_mtx(&so->so_rcv.sb_sel.si_note, SOCKBUF_MTX(&so->so_rcv)); + knlist_init_mtx(&so->so_snd.sb_sel.si_note, SOCKBUF_MTX(&so->so_snd)); if (soreserve(so, head->so_snd.sb_hiwat, head->so_rcv.sb_hiwat) || (*so->so_proto->pr_usrreqs->pru_attach)(so, 0, NULL)) { sodealloc(so); Index: kern/tty.c =================================================================== --- kern/tty.c (revision 202809) +++ kern/tty.c (working copy) @@ -2904,8 +2904,8 @@ mtx_lock(&tty_list_mutex); TAILQ_INSERT_TAIL(&tty_list, tp, t_list); mtx_unlock(&tty_list_mutex); - knlist_init(&tp->t_rsel.si_note, &tp->t_mtx, NULL, NULL, NULL); - knlist_init(&tp->t_wsel.si_note, &tp->t_mtx, NULL, NULL, NULL); + knlist_init_mtx(&tp->t_rsel.si_note, &tp->t_mtx); + knlist_init_mtx(&tp->t_wsel.si_note, &tp->t_mtx); return (tp); } Index: kern/kern_event.c =================================================================== --- kern/kern_event.c (revision 202809) +++ kern/kern_event.c (working copy) @@ -206,11 +206,13 @@ } while (0) #ifdef INVARIANTS #define KNL_ASSERT_LOCKED(knl) do { \ - if (!knl->kl_locked((knl)->kl_lockarg)) \ + if (knl->kl_locked != NULL && \ + !knl->kl_locked((knl)->kl_lockarg)) \ panic("knlist not locked, but should be"); \ } while (0) #define KNL_ASSERT_UNLOCKED(knl) do { \ - if (knl->kl_locked((knl)->kl_lockarg)) \ + if (knl->kl_locked != NULL && \ + knl->kl_locked((knl)->kl_lockarg)) \ panic("knlist locked, but should not be"); \ } while (0) #else /* !INVARIANTS */ @@ -576,7 +578,7 @@ mtx_init(&kq->kq_lock, "kqueue", NULL, MTX_DEF|MTX_DUPOK); TAILQ_INIT(&kq->kq_head); kq->kq_fdp = fdp; - knlist_init(&kq->kq_sel.si_note, &kq->kq_lock, NULL, NULL, NULL); + knlist_init_mtx(&kq->kq_sel.si_note, &kq->kq_lock); TASK_INIT(&kq->kq_task, 0, kqueue_task, kq); FILEDESC_XLOCK(fdp); @@ -1774,7 +1776,7 @@ knl->kl_unlock = knlist_mtx_unlock; else knl->kl_unlock = kl_unlock; - if (kl_locked == NULL) + if (kl_locked == NULL && kl_lock == NULL && kl_unlock == NULL) knl->kl_locked = knlist_mtx_locked; else knl->kl_locked = kl_locked; @@ -1783,6 +1785,13 @@ } void +knlist_init_mtx(struct knlist *knl, struct mtx *lock) +{ + + knlist_init(knl, lock, NULL, NULL, NULL); +} + +void knlist_destroy(struct knlist *knl) { Index: kern/kern_fork.c =================================================================== --- kern/kern_fork.c (revision 202809) +++ kern/kern_fork.c (working copy) @@ -294,7 +294,7 @@ #ifdef MAC mac_init_proc(newproc); #endif - knlist_init(&newproc->p_klist, &newproc->p_mtx, NULL, NULL, NULL); + knlist_init_mtx(&newproc->p_klist, &newproc->p_mtx); STAILQ_INIT(&newproc->p_ktr); /* We have to lock the process tree while we look for a pid. */ Index: kern/vfs_aio.c =================================================================== --- kern/vfs_aio.c (revision 202809) +++ kern/vfs_aio.c (working copy) @@ -1486,7 +1486,7 @@ aiocbe = uma_zalloc(aiocb_zone, M_WAITOK | M_ZERO); aiocbe->inputcharge = 0; aiocbe->outputcharge = 0; - knlist_init(&aiocbe->klist, AIO_MTX(ki), NULL, NULL, NULL); + knlist_init_mtx(&aiocbe->klist, AIO_MTX(ki)); error = ops->copyin(job, &aiocbe->uaiocb); if (error) { @@ -2108,7 +2108,7 @@ lj->lioj_flags = 0; lj->lioj_count = 0; lj->lioj_finished_count = 0; - knlist_init(&lj->klist, AIO_MTX(ki), NULL, NULL, NULL); + knlist_init_mtx(&lj->klist, AIO_MTX(ki)); ksiginfo_init(&lj->lioj_ksi); /* Index: kern/sys_pipe.c =================================================================== --- kern/sys_pipe.c (revision 202809) +++ kern/sys_pipe.c (working copy) @@ -332,10 +332,8 @@ rpipe = &pp->pp_rpipe; wpipe = &pp->pp_wpipe; - knlist_init(&rpipe->pipe_sel.si_note, PIPE_MTX(rpipe), NULL, NULL, - NULL); - knlist_init(&wpipe->pipe_sel.si_note, PIPE_MTX(wpipe), NULL, NULL, - NULL); + knlist_init_mtx(&rpipe->pipe_sel.si_note, PIPE_MTX(rpipe)); + knlist_init_mtx(&wpipe->pipe_sel.si_note, PIPE_MTX(wpipe)); /* Only the forward direction pipe is backed by default */ if ((error = pipe_create(rpipe, 1)) != 0 || Index: kern/vfs_subr.c =================================================================== --- kern/vfs_subr.c (revision 202809) +++ kern/vfs_subr.c (working copy) @@ -107,7 +107,6 @@ static void vgonel(struct vnode *); static void vfs_knllock(void *arg); static void vfs_knlunlock(void *arg); -static int vfs_knllocked(void *arg); static void destroy_vpollinfo(struct vpollinfo *vi); /* @@ -3227,7 +3226,7 @@ vi = uma_zalloc(vnodepoll_zone, M_WAITOK); mtx_init(&vi->vpi_lock, "vnode pollinfo", NULL, MTX_DEF); knlist_init(&vi->vpi_selinfo.si_note, vp, vfs_knllock, - vfs_knlunlock, vfs_knllocked); + vfs_knlunlock, NULL); VI_LOCK(vp); if (vp->v_pollinfo != NULL) { VI_UNLOCK(vp); @@ -3945,7 +3944,7 @@ static void vfs_event_init(void *arg) { - knlist_init(&fs_knlist, NULL, NULL, NULL, NULL); + knlist_init_mtx(&fs_knlist, NULL); } /* XXX - correct order? */ SYSINIT(vfs_knlist, SI_SUB_VFS, SI_ORDER_ANY, vfs_event_init, NULL); @@ -4058,14 +4057,6 @@ VOP_UNLOCK(vp, 0, curthread); } -static int -vfs_knllocked(void *arg) -{ - struct vnode *vp = arg; - - return (VOP_ISLOCKED(vp, curthread) == LK_EXCLUSIVE); -} - int vfs_kqfilter(struct vop_kqfilter_args *ap) { @@ -4116,27 +4107,37 @@ { struct vnode *vp = (struct vnode *)kn->kn_hook; struct vattr va; + int res; /* * filesystem is gone, so set the EOF flag and schedule * the knote for deletion. */ if (hint == NOTE_REVOKE) { + VI_LOCK(vp); kn->kn_flags |= (EV_EOF | EV_ONESHOT); + VI_UNLOCK(vp); return (1); } if (VOP_GETATTR(vp, &va, curthread->td_ucred, curthread)) return (0); + VI_LOCK(vp); kn->kn_data = va.va_size - kn->kn_fp->f_offset; - return (kn->kn_data != 0); + res = (kn->kn_data != 0); + VI_UNLOCK(vp); + return (res); } /*ARGSUSED*/ static int filt_vfswrite(struct knote *kn, long hint) { + struct vnode *vp = (struct vnode *)kn->kn_hook; + + VI_LOCK(vp); + /* * filesystem is gone, so set the EOF flag and schedule * the knote for deletion. @@ -4145,19 +4146,27 @@ kn->kn_flags |= (EV_EOF | EV_ONESHOT); kn->kn_data = 0; + VI_UNLOCK(vp); return (1); } static int filt_vfsvnode(struct knote *kn, long hint) { + struct vnode *vp = (struct vnode *)kn->kn_hook; + int res; + + VI_LOCK(vp); if (kn->kn_sfflags & hint) kn->kn_fflags |= hint; if (hint == NOTE_REVOKE) { kn->kn_flags |= EV_EOF; + VI_UNLOCK(vp); return (1); } - return (kn->kn_fflags != 0); + res = (kn->kn_fflags != 0); + VI_UNLOCK(vp); + return (res); } int Index: cam/scsi/scsi_target.c =================================================================== --- cam/scsi/scsi_target.c (revision 202809) +++ cam/scsi/scsi_target.c (working copy) @@ -194,7 +194,7 @@ TAILQ_INIT(&softc->work_queue); TAILQ_INIT(&softc->abort_queue); TAILQ_INIT(&softc->user_ccb_queue); - knlist_init(&softc->read_select.si_note, NULL, NULL, NULL, NULL); + knlist_init_mtx(&softc->read_select.si_note, NULL); return (0); } Index: net/bpf.c =================================================================== --- net/bpf.c (revision 202809) +++ net/bpf.c (working copy) @@ -425,7 +425,7 @@ #endif mtx_init(&d->bd_mtx, devtoname(dev), "bpf cdev lock", MTX_DEF); callout_init(&d->bd_callout, CALLOUT_MPSAFE); - knlist_init(&d->bd_sel.si_note, &d->bd_mtx, NULL, NULL, NULL); + knlist_init_mtx(&d->bd_sel.si_note, &d->bd_mtx); return (0); } Index: net/if_tap.c =================================================================== --- net/if_tap.c (revision 202809) +++ net/if_tap.c (working copy) @@ -462,7 +462,7 @@ tp->tap_flags |= TAP_INITED; mtx_unlock(&tp->tap_mtx); - knlist_init(&tp->tap_rsel.si_note, NULL, NULL, NULL, NULL); + knlist_init_mtx(&tp->tap_rsel.si_note, NULL); TAPDEBUG("interface %s is created. minor = %#x\n", ifp->if_xname, minor(dev)); Index: net/if_tun.c =================================================================== --- net/if_tun.c (revision 202809) +++ net/if_tun.c (working copy) @@ -380,7 +380,7 @@ IFQ_SET_MAXLEN(&ifp->if_snd, ifqmaxlen); ifp->if_snd.ifq_drv_maxlen = 0; IFQ_SET_READY(&ifp->if_snd); - knlist_init(&sc->tun_rsel.si_note, NULL, NULL, NULL, NULL); + knlist_init_mtx(&sc->tun_rsel.si_note, NULL); if_attach(ifp); bpfattach(ifp, DLT_NULL, sizeof(u_int32_t)); Index: i386/acpica/acpi_machdep.c =================================================================== --- i386/acpica/acpi_machdep.c (revision 202809) +++ i386/acpica/acpi_machdep.c (working copy) @@ -258,7 +258,7 @@ clone->acpi_sc = acpi_sc; clone->notify_status = APM_EV_NONE; bzero(&clone->sel_read, sizeof(clone->sel_read)); - knlist_init(&clone->sel_read.si_note, &acpi_mutex, NULL, NULL, NULL); + knlist_init_mtx(&clone->sel_read.si_note, &acpi_mutex); /* * The acpi device is always managed by devd(8) and is considered Property changes on: contrib/pf ___________________________________________________________________ Modified: svn:mergeinfo Merged /head/sys/contrib/pf:r193951 Property changes on: contrib/dev/acpica ___________________________________________________________________ Modified: svn:mergeinfo Merged /head/sys/contrib/dev/acpica:r193951 Property changes on: cddl/contrib/opensolaris ___________________________________________________________________ Modified: svn:mergeinfo Merged /head/sys/cddl/contrib/opensolaris:r193951 Index: security/audit/audit_pipe.c =================================================================== --- security/audit/audit_pipe.c (revision 202809) +++ security/audit/audit_pipe.c (working copy) @@ -579,8 +579,7 @@ return (NULL); ap->ap_qlimit = AUDIT_PIPE_QLIMIT_DEFAULT; TAILQ_INIT(&ap->ap_queue); - knlist_init(&ap->ap_selinfo.si_note, AUDIT_PIPE_MTX(ap), NULL, NULL, - NULL); + knlist_init_mtx(&ap->ap_selinfo.si_note, AUDIT_PIPE_MTX(ap)); AUDIT_PIPE_LOCK_INIT(ap); AUDIT_PIPE_SX_LOCK_INIT(ap); cv_init(&ap->ap_cv, "audit_pipe"); Index: sys/event.h =================================================================== --- sys/event.h (revision 202809) +++ sys/event.h (working copy) @@ -209,6 +209,7 @@ struct thread; struct proc; struct knlist; +struct mtx; extern void knote(struct knlist *list, long hint, int lockflags); extern void knote_fork(struct knlist *list, int pid); @@ -219,6 +220,7 @@ extern void knlist_init(struct knlist *knl, void *lock, void (*kl_lock)(void *), void (*kl_unlock)(void *), int (*kl_locked)(void *)); +extern void knlist_init_mtx(struct knlist *knl, struct mtx *lock); extern void knlist_destroy(struct knlist *knl); extern void knlist_cleardel(struct knlist *knl, struct thread *td, int islocked, int killkn);