Add lim_cowsync, similar to crcowsync

This commit is contained in:
Mateusz Guzik 2022-02-01 14:10:21 +01:00
parent f0000eb41d
commit 8a0cb04df4
3 changed files with 23 additions and 4 deletions

View File

@ -1216,6 +1216,26 @@ lim_hold(struct plimit *limp)
return (limp);
}
struct plimit *
lim_cowsync(void)
{
struct thread *td;
struct proc *p;
struct plimit *oldlimit;
td = curthread;
p = td->td_proc;
PROC_LOCK_ASSERT(p, MA_OWNED);
if (td->td_limit == p->p_limit)
return (NULL);
oldlimit = td->td_limit;
td->td_limit = lim_hold(p->p_limit);
return (oldlimit);
}
void
lim_fork(struct proc *p1, struct proc *p2)
{

View File

@ -859,10 +859,7 @@ thread_cow_update(struct thread *td)
oldlimit = NULL;
PROC_LOCK(p);
oldcred = crcowsync();
if (td->td_limit != p->p_limit) {
oldlimit = td->td_limit;
td->td_limit = lim_hold(p->p_limit);
}
oldlimit = lim_cowsync();
td->td_cowgen = p->p_cowgen;
PROC_UNLOCK(p);
if (oldcred != NULL)

View File

@ -148,6 +148,8 @@ void lim_free(struct plimit *limp);
void lim_freen(struct plimit *limp, int n);
struct plimit
*lim_hold(struct plimit *limp);
struct plimit
*lim_cowsync(void);
rlim_t lim_max(struct thread *td, int which);
rlim_t lim_max_proc(struct proc *p, int which);
void lim_rlimit(struct thread *td, int which, struct rlimit *rlp);