diff options
author | mjg <mjg@FreeBSD.org> | 2014-08-17 07:20:37 +0000 |
---|---|---|
committer | mjg <mjg@FreeBSD.org> | 2014-08-17 07:20:37 +0000 |
commit | 46f8d5c454d6442279238a41dcb20c620f0e8b95 (patch) | |
tree | 0a33ae6ae95763a9ec78a785d22527f47b27edcc /sys/kern | |
parent | 789b35542c82c8e4b795eb04c7b904644f307848 (diff) | |
download | FreeBSD-src-46f8d5c454d6442279238a41dcb20c620f0e8b95.zip FreeBSD-src-46f8d5c454d6442279238a41dcb20c620f0e8b95.tar.gz |
MFC r268634:
Manage struct sigacts refcnt with atomics instead of a mutex.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_sig.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 17a0e61..1d21f06 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include <sys/lock.h> #include <sys/malloc.h> #include <sys/mutex.h> +#include <sys/refcount.h> #include <sys/namei.h> #include <sys/proc.h> #include <sys/procdesc.h> @@ -3432,21 +3433,17 @@ void sigacts_free(struct sigacts *ps) { - mtx_lock(&ps->ps_mtx); - ps->ps_refcnt--; - if (ps->ps_refcnt == 0) { - mtx_destroy(&ps->ps_mtx); - free(ps, M_SUBPROC); - } else - mtx_unlock(&ps->ps_mtx); + if (refcount_release(&ps->ps_refcnt) == 0) + return; + mtx_destroy(&ps->ps_mtx); + free(ps, M_SUBPROC); } struct sigacts * sigacts_hold(struct sigacts *ps) { - mtx_lock(&ps->ps_mtx); - ps->ps_refcnt++; - mtx_unlock(&ps->ps_mtx); + + refcount_acquire(&ps->ps_refcnt); return (ps); } |