thread: batch resource limit free calls
This commit is contained in:
parent
5ef7b7a0f3
commit
fb8ab68084
@ -1236,6 +1236,14 @@ lim_free(struct plimit *limp)
|
||||
free((void *)limp, M_PLIMIT);
|
||||
}
|
||||
|
||||
void
|
||||
lim_freen(struct plimit *limp, int n)
|
||||
{
|
||||
|
||||
if (refcount_releasen(&limp->pl_refcnt, n))
|
||||
free((void *)limp, M_PLIMIT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Make a copy of the plimit structure.
|
||||
* We share these structures copy-on-write after fork.
|
||||
|
@ -537,6 +537,8 @@ thread_reap(void)
|
||||
struct thread *itd, *ntd;
|
||||
struct tidbatch tidbatch;
|
||||
int tdcount;
|
||||
struct plimit *lim;
|
||||
int limcount;
|
||||
|
||||
/*
|
||||
* Reading upfront is pessimal if followed by concurrent atomic_swap,
|
||||
@ -552,11 +554,23 @@ thread_reap(void)
|
||||
|
||||
tidbatch_prep(&tidbatch);
|
||||
tdcount = 0;
|
||||
lim = NULL;
|
||||
limcount = 0;
|
||||
while (itd != NULL) {
|
||||
ntd = itd->td_zombie;
|
||||
EVENTHANDLER_DIRECT_INVOKE(thread_dtor, itd);
|
||||
tidbatch_add(&tidbatch, itd);
|
||||
thread_cow_free(itd);
|
||||
MPASS(itd->td_realucred != NULL);
|
||||
crcowfree(itd);
|
||||
MPASS(itd->td_limit != NULL);
|
||||
if (lim != itd->td_limit) {
|
||||
if (limcount != 0) {
|
||||
lim_freen(lim, limcount);
|
||||
limcount = 0;
|
||||
}
|
||||
}
|
||||
lim = itd->td_limit;
|
||||
limcount++;
|
||||
thread_free_batched(itd);
|
||||
tidbatch_process(&tidbatch);
|
||||
tdcount++;
|
||||
@ -571,6 +585,8 @@ thread_reap(void)
|
||||
if (tdcount != 0) {
|
||||
thread_count_sub(tdcount);
|
||||
}
|
||||
MPASS(limcount != 0);
|
||||
lim_freen(lim, limcount);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -145,6 +145,7 @@ rlim_t lim_cur(struct thread *td, int which);
|
||||
rlim_t lim_cur_proc(struct proc *p, int which);
|
||||
void lim_fork(struct proc *p1, struct proc *p2);
|
||||
void lim_free(struct plimit *limp);
|
||||
void lim_freen(struct plimit *limp, int n);
|
||||
struct plimit
|
||||
*lim_hold(struct plimit *limp);
|
||||
rlim_t lim_max(struct thread *td, int which);
|
||||
|
Loading…
x
Reference in New Issue
Block a user