Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 29 Nov 2014 17:18:20 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r275260 - head/sys/kern
Message-ID:  <201411291718.sATHIKi8000474@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201411291718.sATHIKi8000474>