From 517ef2d35127d2138a5e90592861babfc9888aa5 Mon Sep 17 00:00:00 2001 From: kib Date: Mon, 29 Dec 2014 00:30:38 +0000 Subject: MFC r275260: Remove lock recursion for the pipe pair mutex, and disable the recursion on mutex initialization. --- sys/kern/sys_pipe.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'sys/kern') diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index 9ee4fde..1e63dba 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -315,7 +315,7 @@ pipe_zone_init(void *mem, int size, int flags) pp = (struct pipepair *)mem; - mtx_init(&pp->pp_mtx, "pipe mutex", NULL, MTX_DEF | MTX_RECURSE); + mtx_init(&pp->pp_mtx, "pipe mutex", NULL, MTX_DEF); return (0); } @@ -1770,7 +1770,7 @@ filt_piperead(struct knote *kn, long hint) struct pipe *wpipe = rpipe->pipe_peer; int ret; - PIPE_LOCK(rpipe); + PIPE_LOCK_ASSERT(rpipe, MA_OWNED); kn->kn_data = rpipe->pipe_buffer.cnt; if ((kn->kn_data == 0) && (rpipe->pipe_state & PIPE_DIRECTW)) kn->kn_data = rpipe->pipe_map.cnt; @@ -1779,11 +1779,9 @@ filt_piperead(struct knote *kn, long hint) wpipe->pipe_present != PIPE_ACTIVE || (wpipe->pipe_state & PIPE_EOF)) { kn->kn_flags |= EV_EOF; - PIPE_UNLOCK(rpipe); return (1); } ret = kn->kn_data > 0; - PIPE_UNLOCK(rpipe); return ret; } @@ -1794,12 +1792,11 @@ filt_pipewrite(struct knote *kn, long hint) struct pipe *wpipe; wpipe = kn->kn_hook; - PIPE_LOCK(wpipe); + PIPE_LOCK_ASSERT(wpipe, MA_OWNED); if (wpipe->pipe_present != PIPE_ACTIVE || (wpipe->pipe_state & PIPE_EOF)) { kn->kn_data = 0; kn->kn_flags |= EV_EOF; - PIPE_UNLOCK(wpipe); return (1); } kn->kn_data = (wpipe->pipe_buffer.size > 0) ? @@ -1807,7 +1804,6 @@ filt_pipewrite(struct knote *kn, long hint) if (wpipe->pipe_state & PIPE_DIRECTW) kn->kn_data = 0; - PIPE_UNLOCK(wpipe); return (kn->kn_data >= PIPE_BUF); } -- cgit v1.1