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:
parent
fe6d8dd8ee
commit
27e39ae4d8
@ -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);
|
||||
}
|
||||
|
@ -558,17 +558,10 @@ again:
|
||||
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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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 */
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user