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
Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D27858
This commit is contained in:
Jason A. Harmening 2020-12-30 15:29:44 -08:00
parent 2defbe9f0e
commit e8a5a1ad71

View File

@ -600,6 +600,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