From owner-svn-src-all@FreeBSD.ORG Tue Jul 1 06:29:16 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 375604C8; Tue, 1 Jul 2014 06:29:16 +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 2638C2991; Tue, 1 Jul 2014 06:29:16 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s616TGXP082443; Tue, 1 Jul 2014 06:29:16 GMT (envelope-from mjg@svn.freebsd.org) Received: (from mjg@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s616TFul082441; Tue, 1 Jul 2014 06:29:15 GMT (envelope-from mjg@svn.freebsd.org) Message-Id: <201407010629.s616TFul082441@svn.freebsd.org> From: Mateusz Guzik Date: Tue, 1 Jul 2014 06:29:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r268074 - 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 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: Tue, 01 Jul 2014 06:29:16 -0000 Author: mjg Date: Tue Jul 1 06:29:15 2014 New Revision: 268074 URL: http://svnweb.freebsd.org/changeset/base/268074 Log: 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. MFC after: 1 week Modified: head/sys/kern/kern_exec.c head/sys/kern/kern_sig.c Modified: head/sys/kern/kern_exec.c ============================================================================== --- head/sys/kern/kern_exec.c Tue Jul 1 06:23:48 2014 (r268073) +++ head/sys/kern/kern_exec.c Tue Jul 1 06:29:15 2014 (r268074) @@ -621,18 +621,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: head/sys/kern/kern_sig.c ============================================================================== --- head/sys/kern/kern_sig.c Tue Jul 1 06:23:48 2014 (r268073) +++ head/sys/kern/kern_sig.c Tue Jul 1 06:29:15 2014 (r268074) @@ -3453,10 +3453,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); }