summaryrefslogtreecommitdiff
path: root/sys/kern/kern_resource.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2005-09-27 18:07:05 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2005-09-27 18:07:05 +0000
commitb2149bde1f1bab65167cb33be2a5827130f392f7 (patch)
tree046251fc9192b3cf153a08e952de366ce537e9e7 /sys/kern/kern_resource.c
parenta11ea6e325e82028f9a5d9c38b0b60aef05090a0 (diff)
Notes
Diffstat (limited to 'sys/kern/kern_resource.c')
-rw-r--r--sys/kern/kern_resource.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c
index b70b97f5b720..cb5b73d2f005 100644
--- a/sys/kern/kern_resource.c
+++ b/sys/kern/kern_resource.c
@@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/proc.h>
+#include <sys/refcount.h>
#include <sys/resourcevar.h>
#include <sys/sched.h>
#include <sys/sx.h>
@@ -901,8 +902,7 @@ lim_alloc()
struct plimit *limp;
limp = malloc(sizeof(struct plimit), M_PLIMIT, M_WAITOK);
- limp->pl_refcnt = 1;
- limp->pl_mtx = mtx_pool_alloc(mtxpool_sleep);
+ refcount_init(&limp->pl_refcnt, 1);
return (limp);
}
@@ -911,9 +911,7 @@ lim_hold(limp)
struct plimit *limp;
{
- LIM_LOCK(limp);
- limp->pl_refcnt++;
- LIM_UNLOCK(limp);
+ refcount_acquire(&limp->pl_refcnt);
return (limp);
}
@@ -922,14 +920,9 @@ lim_free(limp)
struct plimit *limp;
{
- LIM_LOCK(limp);
KASSERT(limp->pl_refcnt > 0, ("plimit refcnt underflow"));
- if (--limp->pl_refcnt == 0) {
- LIM_UNLOCK(limp);
+ if (refcount_release(&limp->pl_refcnt))
free((void *)limp, M_PLIMIT);
- return;
- }
- LIM_UNLOCK(limp);
}
/*