summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2018-12-07 16:47:34 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2018-12-07 16:47:34 +0000
commit448db4f761b6bd0c4099ce1aa08a7562bc09ebb8 (patch)
tree85002640706bb71796412097ed9739de1399af89
parent82f4b826347e72f3963df37c1be4daf7052b112b (diff)
Notes
-rw-r--r--sys/kern/kern_racct.c12
-rw-r--r--sys/sys/racct.h7
2 files changed, 17 insertions, 2 deletions
diff --git a/sys/kern/kern_racct.c b/sys/kern/kern_racct.c
index f6d2add90a51..a25d7fa8da52 100644
--- a/sys/kern/kern_racct.c
+++ b/sys/kern/kern_racct.c
@@ -726,6 +726,18 @@ racct_set_locked(struct proc *p, int resource, uint64_t amount, int force)
* even if it's above the limit.
*/
int
+racct_set_unlocked(struct proc *p, int resource, uint64_t amount)
+{
+ int error;
+
+ ASSERT_RACCT_ENABLED();
+ PROC_LOCK(p);
+ error = racct_set(p, resource, amount);
+ PROC_UNLOCK(p);
+ return (error);
+}
+
+int
racct_set(struct proc *p, int resource, uint64_t amount)
{
int error;
diff --git a/sys/sys/racct.h b/sys/sys/racct.h
index 57291e1d45ba..17af3276d691 100644
--- a/sys/sys/racct.h
+++ b/sys/sys/racct.h
@@ -164,12 +164,14 @@ extern struct mtx racct_lock;
#define RACCT_UNLOCK() mtx_unlock(&racct_lock)
#define RACCT_LOCK_ASSERT() mtx_assert(&racct_lock, MA_OWNED)
+#define RACCT_ENABLED() __predict_false(racct_enable)
+
#define RACCT_PROC_LOCK(p) do { \
- if (__predict_false(racct_enable)) \
+ if (RACCT_ENABLED()) \
PROC_LOCK(p); \
} while (0)
#define RACCT_PROC_UNLOCK(p) do { \
- if (__predict_false(racct_enable)) \
+ if (RACCT_ENABLED()) \
PROC_UNLOCK(p); \
} while (0)
@@ -178,6 +180,7 @@ void racct_add_cred(struct ucred *cred, int resource, uint64_t amount);
void racct_add_force(struct proc *p, int resource, uint64_t amount);
void racct_add_buf(struct proc *p, const struct buf *bufp, int is_write);
int racct_set(struct proc *p, int resource, uint64_t amount);
+int racct_set_unlocked(struct proc *p, int resource, uint64_t amount);
void racct_set_force(struct proc *p, int resource, uint64_t amount);
void racct_sub(struct proc *p, int resource, uint64_t amount);
void racct_sub_cred(struct ucred *cred, int resource, uint64_t amount);