From owner-svn-src-head@FreeBSD.ORG Tue Jul 1 13:59:46 2014 Return-Path: Delivered-To: svn-src-head@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 E182DF07; Tue, 1 Jul 2014 13:59:46 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BADD52405; Tue, 1 Jul 2014 13:59:46 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 49A15B91C; Tue, 1 Jul 2014 09:59:45 -0400 (EDT) From: John Baldwin To: Mateusz Guzik Subject: Re: svn commit: r268074 - head/sys/kern Date: Tue, 1 Jul 2014 09:40:57 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.4-CBSD-20140415; KDE/4.5.5; amd64; ; ) References: <201407010629.s616TFul082441@svn.freebsd.org> In-Reply-To: <201407010629.s616TFul082441@svn.freebsd.org> MIME-Version: 1.0 Message-Id: <201407010940.57602.jhb@freebsd.org> Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Tue, 01 Jul 2014 09:59:45 -0400 (EDT) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Jul 2014 13:59:47 -0000 On Tuesday, July 01, 2014 2:29:15 am Mateusz Guzik wrote: > 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); > } You should KASSERT() in sigacts_shared that P_HADTHREADS is not set so that new code does not call this function unsafely in the future. -- John Baldwin