aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/racct.h
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2018-09-18 01:24:30 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2018-09-18 01:24:30 +0000
commit2554f86a8d426f6280857d184019506827e328d1 (patch)
tree6d18832ff7055fe7776f343e73b1e6cb1660334e /sys/sys/racct.h
parentaf734c774648e8374f97ad47be48dfc8cd37659f (diff)
downloadsrc-2554f86a8d426f6280857d184019506827e328d1.tar.gz
src-2554f86a8d426f6280857d184019506827e328d1.zip
vm: stop taking proc lock in mmap to satisfy racct if it is disabled
Limits can be safely obtained with lim_cur from the thread. racct is compiled in but disabled by default. Note that racct enablement is a boot-only tunable. This eliminates second most common place of taking the lock while pkg building. While here don't take the lock in mlockall either. Reviewed by: kib Approved by: re (gjb) Differential Revision: https://reviews.freebsd.org/D17210
Notes
Notes: svn path=/head/; revision=338743
Diffstat (limited to 'sys/sys/racct.h')
-rw-r--r--sys/sys/racct.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/sys/sys/racct.h b/sys/sys/racct.h
index ec3322bdfdf9..84de705f24af 100644
--- a/sys/sys/racct.h
+++ b/sys/sys/racct.h
@@ -164,6 +164,15 @@ extern struct mtx racct_lock;
#define RACCT_UNLOCK() mtx_unlock(&racct_lock)
#define RACCT_LOCK_ASSERT() mtx_assert(&racct_lock, MA_OWNED)
+#define RACCT_PROC_LOCK(p) do { \
+ if (__predict_false(racct_enable)) \
+ PROC_LOCK(p); \
+} while (0)
+#define RACCT_PROC_UNLOCK(p) do { \
+ if (__predict_false(racct_enable)) \
+ PROC_UNLOCK(p); \
+} while (0)
+
int racct_add(struct proc *p, int resource, uint64_t amount);
void racct_add_cred(struct ucred *cred, int resource, uint64_t amount);
void racct_add_force(struct proc *p, int resource, uint64_t amount);
@@ -189,6 +198,9 @@ void racct_proc_throttle(struct proc *p, int timeout);
#else
+#define RACCT_PROC_LOCK(p) do { } while (0)
+#define RACCT_PROC_UNLOCK(p) do { } while (0)
+
static inline int
racct_add(struct proc *p, int resource, uint64_t amount)
{