- Convert the plimit lock to a pool mutex lock.

- Hide struct plimit from userland.

Submitted by:	bde (2)
This commit is contained in:
John Baldwin 2004-02-06 19:35:14 +00:00
parent f4daf05619
commit a875f38546
2 changed files with 9 additions and 15 deletions

View File

@ -837,9 +837,9 @@ lim_alloc()
struct plimit *limp;
limp = (struct plimit *)malloc(sizeof(struct plimit), M_PLIMIT,
M_WAITOK | M_ZERO);
M_WAITOK);
limp->pl_refcnt = 1;
mtx_init(&limp->pl_mtx, "plimit lock", NULL, MTX_DEF);
limp->pl_mtx = mtx_pool_alloc(mtxpool_sleep);
return (limp);
}
@ -862,7 +862,7 @@ lim_free(limp)
LIM_LOCK(limp);
KASSERT(limp->pl_refcnt > 0, ("plimit refcnt underflow"));
if (--limp->pl_refcnt == 0) {
mtx_destroy(&limp->pl_mtx);
LIM_UNLOCK(limp);
free((void *)limp, M_PLIMIT);
return;
}

View File

@ -68,6 +68,8 @@ struct pstats {
struct timeval p_start; /* starting time */
};
#ifdef _KERNEL
/*
* Kernel shareable process resource limits. Because this structure
* is moderately large but changes infrequently, it is normally
@ -76,20 +78,12 @@ struct pstats {
struct plimit {
struct rlimit pl_rlimit[RLIM_NLIMITS];
int pl_refcnt; /* number of references */
struct mtx pl_mtx;
struct mtx *pl_mtx;
};
#ifdef _KERNEL
/*
* Lock order for operations involving the plimit lock:
* filedesc <important to avoid deadlocks in the descriptor code>
* proc
* plimit
*/
#define LIM_LOCK(lim) mtx_lock(&(lim)->pl_mtx)
#define LIM_UNLOCK(lim) mtx_unlock(&(lim)->pl_mtx)
#define LIM_LOCK_ASSERT(lim, f) mtx_assert(&(lim)->pl_mtx, (f))
#define LIM_LOCK(lim) mtx_lock((lim)->pl_mtx)
#define LIM_UNLOCK(lim) mtx_unlock((lim)->pl_mtx)
#define LIM_LOCK_ASSERT(lim, f) mtx_assert((lim)->pl_mtx, (f))
/*
* Per uid resource consumption