Remove the PL_SHAREMOD flag from struct plimit, which could have been

used to share resource limits between rfork threads, but never was.
Removing it makes resource limit locking much simpler -- only the current
process can change the contents of the structure that p_limit points to.
This commit is contained in:
Tim J. Robbins 2003-02-20 04:18:42 +00:00
parent fe6d8dd8ee
commit 27e39ae4d8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=111163
4 changed files with 6 additions and 21 deletions

View File

@ -294,8 +294,7 @@ acct_process(td)
/*
* Eliminate any file size rlimit.
*/
if (p->p_limit->p_refcnt > 1 &&
(p->p_limit->p_lflags & PL_SHAREMOD) == 0) {
if (p->p_limit->p_refcnt > 1) {
p->p_limit->p_refcnt--;
p->p_limit = limcopy(p->p_limit);
}

View File

@ -558,17 +558,10 @@ fork1(td, flags, pages, procp)
PROC_UNLOCK(p2);
/*
* If p_limit is still copy-on-write, bump refcnt,
* otherwise get a copy that won't be modified.
* (If PL_SHAREMOD is clear, the structure is shared
* copy-on-write.)
* p_limit is copy-on-write, bump refcnt,
*/
if (p1->p_limit->p_lflags & PL_SHAREMOD)
p2->p_limit = limcopy(p1->p_limit);
else {
p2->p_limit = p1->p_limit;
p2->p_limit->p_refcnt++;
}
p2->p_limit = p1->p_limit;
p2->p_limit->p_refcnt++;
/*
* Setup linkage for kernel based threading

View File

@ -555,8 +555,7 @@ dosetrlimit(td, which, limp)
return (error);
if (limp->rlim_cur > limp->rlim_max)
limp->rlim_cur = limp->rlim_max;
if (p->p_limit->p_refcnt > 1 &&
(p->p_limit->p_lflags & PL_SHAREMOD) == 0) {
if (p->p_limit->p_refcnt > 1) {
p->p_limit->p_refcnt--;
p->p_limit = limcopy(p->p_limit);
alimp = &p->p_rlimit[which];
@ -828,7 +827,6 @@ limcopy(lim)
MALLOC(copy, struct plimit *, sizeof(struct plimit),
M_SUBPROC, M_WAITOK);
bcopy(lim->pl_rlimit, copy->pl_rlimit, sizeof(struct plimit));
copy->p_lflags = 0;
copy->p_refcnt = 1;
return (copy);
}

View File

@ -72,15 +72,10 @@ struct pstats {
/*
* Kernel shareable process resource limits. Because this structure
* is moderately large but changes infrequently, it is normally
* shared copy-on-write after forks. If a group of processes
* ("threads") share modifications, the PL_SHAREMOD flag is set,
* and a copy must be made for the child of a new fork that isn't
* sharing modifications to the limits.
* shared copy-on-write after forks.
*/
struct plimit {
struct rlimit pl_rlimit[RLIM_NLIMITS];
#define PL_SHAREMOD 0x01 /* modifications are shared */
int p_lflags;
int p_refcnt; /* number of references */
};