Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 Aug 2014 06:52:35 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r270084 - stable/10/sys/kern
Message-ID:  <201408170652.s7H6qZeH028464@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Sun Aug 17 06:52:35 2014
New Revision: 270084
URL: http://svnweb.freebsd.org/changeset/base/270084

Log:
  MFC r268074:
  
  Perform a lockless check in sigacts_shared.
  
  It is used only during execve (i.e. singlethreaded), so there is no fear
  of returning 'not shared' which soon becomes 'shared'.
  
  While here reorganize the code a little to avoid proc lock/unlock in
  shared case.

Modified:
  stable/10/sys/kern/kern_exec.c
  stable/10/sys/kern/kern_sig.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/kern/kern_exec.c
==============================================================================
--- stable/10/sys/kern/kern_exec.c	Sun Aug 17 06:28:57 2014	(r270083)
+++ stable/10/sys/kern/kern_exec.c	Sun Aug 17 06:52:35 2014	(r270084)
@@ -624,18 +624,17 @@ interpret:
 	 * handlers. In execsigs(), the new process will have its signals
 	 * reset.
 	 */
-	PROC_LOCK(p);
-	oldcred = crcopysafe(p, newcred);
 	if (sigacts_shared(p->p_sigacts)) {
 		oldsigacts = p->p_sigacts;
-		PROC_UNLOCK(p);
 		newsigacts = sigacts_alloc();
 		sigacts_copy(newsigacts, oldsigacts);
-		PROC_LOCK(p);
-		p->p_sigacts = newsigacts;
 	} else
 		oldsigacts = NULL;
 
+	PROC_LOCK(p);
+	if (oldsigacts)
+		p->p_sigacts = newsigacts;
+	oldcred = crcopysafe(p, newcred);
 	/* Stop profiling */
 	stopprofclock(p);
 

Modified: stable/10/sys/kern/kern_sig.c
==============================================================================
--- stable/10/sys/kern/kern_sig.c	Sun Aug 17 06:28:57 2014	(r270083)
+++ stable/10/sys/kern/kern_sig.c	Sun Aug 17 06:52:35 2014	(r270084)
@@ -3463,10 +3463,6 @@ sigacts_copy(struct sigacts *dest, struc
 int
 sigacts_shared(struct sigacts *ps)
 {
-	int shared;
 
-	mtx_lock(&ps->ps_mtx);
-	shared = ps->ps_refcnt > 1;
-	mtx_unlock(&ps->ps_mtx);
-	return (shared);
+	return (ps->ps_refcnt > 1);
 }



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