svn commit: r341181 - in head/sys: kern sys
Mateusz Guzik
mjg at FreeBSD.org
Thu Nov 29 05:08:47 UTC 2018
Author: mjg
Date: Thu Nov 29 05:08:46 2018
New Revision: 341181
URL: https://svnweb.freebsd.org/changeset/base/341181
Log:
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
Modified:
head/sys/kern/kern_racct.c
head/sys/kern/subr_trap.c
head/sys/sys/racct.h
Modified: head/sys/kern/kern_racct.c
==============================================================================
--- head/sys/kern/kern_racct.c Thu Nov 29 04:48:22 2018 (r341180)
+++ head/sys/kern/kern_racct.c Thu Nov 29 05:08:46 2018 (r341181)
@@ -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().
Modified: head/sys/kern/subr_trap.c
==============================================================================
--- head/sys/kern/subr_trap.c Thu Nov 29 04:48:22 2018 (r341180)
+++ head/sys/kern/subr_trap.c Thu Nov 29 05:08:46 2018 (r341181)
@@ -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
}
Modified: head/sys/sys/racct.h
==============================================================================
--- head/sys/sys/racct.h Thu Nov 29 04:48:22 2018 (r341180)
+++ head/sys/sys/racct.h Thu Nov 29 05:08:46 2018 (r341181)
@@ -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
More information about the svn-src-head
mailing list