From owner-svn-src-all@FreeBSD.ORG Sat Nov 29 17:18:21 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 430DEC8; Sat, 29 Nov 2014 17:18:21 +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 1614BE90; Sat, 29 Nov 2014 17:18:21 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sATHIK0L000475; Sat, 29 Nov 2014 17:18:20 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sATHIKi8000474; Sat, 29 Nov 2014 17:18:20 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201411291718.sATHIKi8000474@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 29 Nov 2014 17:18:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r275260 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Nov 2014 17:18:21 -0000 Author: kib Date: Sat Nov 29 17:18:20 2014 New Revision: 275260 URL: https://svnweb.freebsd.org/changeset/base/275260 Log: Remove lock recursion for the pipe pair mutex, and disable the recursion on mutex initialization. The only places where the recursive acquire is performed are read and write filters, since knlist, which uses the pipe pair mutex as lock, is locked when filter is called. The recursion was added in r93296, and consistent locking for kn_fop->f_event() introduced in r133741. Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 month Modified: head/sys/kern/sys_pipe.c Modified: head/sys/kern/sys_pipe.c ============================================================================== --- head/sys/kern/sys_pipe.c Sat Nov 29 16:07:15 2014 (r275259) +++ head/sys/kern/sys_pipe.c Sat Nov 29 17:18:20 2014 (r275260) @@ -318,7 +318,7 @@ pipe_zone_init(void *mem, int size, int 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); } @@ -1792,7 +1792,7 @@ filt_piperead(struct knote *kn, long hin 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; @@ -1801,11 +1801,9 @@ filt_piperead(struct knote *kn, long hin 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; } @@ -1816,12 +1814,11 @@ filt_pipewrite(struct knote *kn, long hi 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) ? @@ -1829,7 +1826,6 @@ filt_pipewrite(struct knote *kn, long hi if (wpipe->pipe_state & PIPE_DIRECTW) kn->kn_data = 0; - PIPE_UNLOCK(wpipe); return (kn->kn_data >= PIPE_BUF); }