Deinline racct throttling out of syscall exit path.

racct is not enabled by default and even when it is enabled processes are
typically not throttled. The order of checks is left unchanged since
racct_enable will be annotated as __read_frequently, while checking for the
flag in the processes would probably require an extra fetch.

Sponsored by:	The FreeBSD Foundation
This commit is contained in:
mjg 2018-11-29 05:08:46 +00:00
parent 7afd77afea
commit ea1fbe943e
3 changed files with 19 additions and 10 deletions

View File

@ -1087,6 +1087,22 @@ racct_move(struct racct *dest, struct racct *src)
RACCT_UNLOCK();
}
void
racct_proc_throttled(struct proc *p)
{
ASSERT_RACCT_ENABLED();
PROC_LOCK(p);
while (p->p_throttled != 0) {
msleep(p->p_racct, &p->p_mtx, 0, "racct",
p->p_throttled < 0 ? 0 : p->p_throttled);
if (p->p_throttled > 0)
p->p_throttled = 0;
}
PROC_UNLOCK(p);
}
/*
* Make the process sleep in userret() for 'timeout' ticks. Setting
* timeout to -1 makes it sleep until woken up by racct_proc_wakeup().

View File

@ -198,16 +198,8 @@ userret(struct thread *td, struct trapframe *frame)
(td->td_vnet_lpush != NULL) ? td->td_vnet_lpush : "N/A"));
#endif
#ifdef RACCT
if (racct_enable && p->p_throttled != 0) {
PROC_LOCK(p);
while (p->p_throttled != 0) {
msleep(p->p_racct, &p->p_mtx, 0, "racct",
p->p_throttled < 0 ? 0 : p->p_throttled);
if (p->p_throttled > 0)
p->p_throttled = 0;
}
PROC_UNLOCK(p);
}
if (__predict_false(racct_enable && p->p_throttled != 0))
racct_proc_throttled(p);
#endif
}

View File

@ -194,6 +194,7 @@ void racct_proc_exit(struct proc *p);
void racct_proc_ucred_changed(struct proc *p, struct ucred *oldcred,
struct ucred *newcred);
void racct_move(struct racct *dest, struct racct *src);
void racct_proc_throttled(struct proc *p);
void racct_proc_throttle(struct proc *p, int timeout);
#else