summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2005-09-27 18:03:15 +0000
committerjhb <jhb@FreeBSD.org>2005-09-27 18:03:15 +0000
commit03582b6378977bd655ebe3c4cb36b2f4f77463fc (patch)
tree39c58b9dcb1431dbe2768290ee31d9ddbaf6399f /sys/kern
parent9824060b9c83743ddf280113bc454ee482019ad0 (diff)
downloadFreeBSD-src-03582b6378977bd655ebe3c4cb36b2f4f77463fc.zip
FreeBSD-src-03582b6378977bd655ebe3c4cb36b2f4f77463fc.tar.gz
Use the refcount API to implement reference counts on process argument
structures rather than using a global mutex to protect the reference counts. Tested on: i386, alpha, sparc64
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_proc.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index 308c2e9..6474569 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/proc.h>
+#include <sys/refcount.h>
#include <sys/sysent.h>
#include <sys/sched.h>
#include <sys/smp.h>
@@ -90,7 +91,6 @@ struct proclist allproc;
struct proclist zombproc;
struct sx allproc_lock;
struct sx proctree_lock;
-struct mtx pargs_ref_lock;
struct mtx ppeers_lock;
uma_zone_t proc_zone;
uma_zone_t ithread_zone;
@@ -109,7 +109,6 @@ procinit()
sx_init(&allproc_lock, "allproc");
sx_init(&proctree_lock, "proctree");
- mtx_init(&pargs_ref_lock, "struct pargs.ref", NULL, MTX_DEF);
mtx_init(&ppeers_lock, "p_peers", NULL, MTX_DEF);
LIST_INIT(&allproc);
LIST_INIT(&zombproc);
@@ -1090,7 +1089,7 @@ pargs_alloc(int len)
MALLOC(pa, struct pargs *, sizeof(struct pargs) + len, M_PARGS,
M_WAITOK);
- pa->ar_ref = 1;
+ refcount_init(&pa->ar_ref, 1);
pa->ar_length = len;
return (pa);
}
@@ -1108,9 +1107,7 @@ pargs_hold(struct pargs *pa)
if (pa == NULL)
return;
- PARGS_LOCK(pa);
- pa->ar_ref++;
- PARGS_UNLOCK(pa);
+ refcount_acquire(&pa->ar_ref);
}
void
@@ -1119,12 +1116,8 @@ pargs_drop(struct pargs *pa)
if (pa == NULL)
return;
- PARGS_LOCK(pa);
- if (--pa->ar_ref == 0) {
- PARGS_UNLOCK(pa);
+ if (refcount_release(&pa->ar_ref))
pargs_free(pa);
- } else
- PARGS_UNLOCK(pa);
}
/*
OpenPOWER on IntegriCloud