aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason A. Harmening <jah@FreeBSD.org>2020-12-30 23:29:44 +0000
committerJason A. Harmening <jah@FreeBSD.org>2021-01-26 03:57:44 +0000
commit70cdab054c8ffe7f5561ab8f31db33ee62d12c9c (patch)
treedbe9f17356c4aa84f45922c4e8ffb045d7133edb
parent7baf7a45385962d06cd2a2213109b910d40a7936 (diff)
downloadsrc-70cdab054c8ffe7f5561ab8f31db33ee62d12c9c.tar.gz
src-70cdab054c8ffe7f5561ab8f31db33ee62d12c9c.zip
rctl(4): support throttling resource usage to 0
For rate-based resources that support throttling (e.g. readiops/writeips), this fixes a divide-by-zero panic when rctl(8) passes 0 as the throttle value. For these resources, treat zero-throttle requests as requests to suspend forward progress as long as possible using the duration specified in kern.racct.rctl.throttle_max. PR: 251803 Reported by: chris@cretaforce.gr (cherry picked from commit e8a5a1ad7154dc34e3a5234267e19faa86d5ff33)
-rw-r--r--sys/kern/kern_rctl.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/sys/kern/kern_rctl.c b/sys/kern/kern_rctl.c
index d79192927b54..138f73eabb21 100644
--- a/sys/kern/kern_rctl.c
+++ b/sys/kern/kern_rctl.c
@@ -596,6 +596,11 @@ rctl_enforce(struct proc *p, int resource, uint64_t amount)
if (p->p_state != PRS_NORMAL)
continue;
+ if (rule->rr_amount == 0) {
+ racct_proc_throttle(p, rctl_throttle_max);
+ continue;
+ }
+
/*
* Make the process sleep for a fraction of second
* proportional to the ratio of process' resource