From owner-svn-src-stable@FreeBSD.ORG Sun Aug 17 06:52:36 2014 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0E624B62; Sun, 17 Aug 2014 06:52:36 +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 EDF4C20C6; Sun, 17 Aug 2014 06:52:35 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s7H6qZuL028467; Sun, 17 Aug 2014 06:52:35 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s7H6qZeH028464; Sun, 17 Aug 2014 06:52:35 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201408170652.s7H6qZeH028464@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 17 Aug 2014 06:52:35 +0000 (UTC) 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 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Aug 2014 06:52:36 -0000 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); }