summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authormjg <mjg@FreeBSD.org>2014-08-17 06:52:35 +0000
committermjg <mjg@FreeBSD.org>2014-08-17 06:52:35 +0000
commitf377401ca1805797120d71090b9ebe10d945f91a (patch)
tree5db1fcd1d86938275c603bee03617acb8d7c25f7 /sys/kern
parent766feae5960e52702bf39860cee7f6650554f681 (diff)
downloadFreeBSD-src-f377401ca1805797120d71090b9ebe10d945f91a.zip
FreeBSD-src-f377401ca1805797120d71090b9ebe10d945f91a.tar.gz
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.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_exec.c9
-rw-r--r--sys/kern/kern_sig.c6
2 files changed, 5 insertions, 10 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 19ba76d..3738b89 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -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);
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 99ca131..17a0e61 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -3463,10 +3463,6 @@ sigacts_copy(struct sigacts *dest, struct sigacts *src)
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);
}
OpenPOWER on IntegriCloud