aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2018-11-29 05:08:46 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2018-11-29 05:08:46 +0000
commit64cf6a62d419ba4df40ebb12c0dd9130128e0724 (patch)
tree76eb199cecc19e24c63240fe68ab7e0b5f6652e4 /sys
parente272bf479b763fbe9bfe72877ccf8889434d4e87 (diff)
downloadsrc-64cf6a62d419ba4df40ebb12c0dd9130128e0724.tar.gz
src-64cf6a62d419ba4df40ebb12c0dd9130128e0724.zip
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
Notes
Notes: svn path=/head/; revision=341181
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_racct.c16
-rw-r--r--sys/kern/subr_trap.c12
-rw-r--r--sys/sys/racct.h1
3 files changed, 19 insertions, 10 deletions
diff --git a/sys/kern/kern_racct.c b/sys/kern/kern_racct.c
index f80bb64fa029..4b7b0bfba0b7 100644
--- a/sys/kern/kern_racct.c
+++ b/sys/kern/kern_racct.c
@@ -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().
diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c
index 72a0b8f8d481..2dee196f2a02 100644
--- a/sys/kern/subr_trap.c
+++ b/sys/kern/subr_trap.c
@@ -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
}
diff --git a/sys/sys/racct.h b/sys/sys/racct.h
index 84de705f24af..73ec04a0a0cd 100644
--- a/sys/sys/racct.h
+++ b/sys/sys/racct.h
@@ -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