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 @@ -725,6 +725,18 @@ racct_set_locked(struct proc *p, int resource, uint64_t amount, int force) * Note that decreasing the allocation always returns 0, * 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) { 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);