FreeBSD/sys/kern/kern_rctl.c
/*
 * Called every second for proc, uidinfo, loginclass, and jail containers.
 * If the limit isn't exceeded, it decreases the usage amount to zero.
 * Otherwise, it decreases it by the value of the limit.  This way
 * resource consumption exceeding the limit "carries over" to the next
 * period.
 */
Called every second for proc, uidinfo, loginclass, and jail containers.
If the limit isn't exceeded, it decreases the usage amount to zero.
Otherwise, it decreases it by the value of the limit.  This way
resource consumption exceeding the limit "carries over" to the next
period.
Called every second for proc uidinfo loginclass and jail containers . If the limit isn ' t exceeded it decreases the usage amount to zero . Otherwise it decreases it by the value of the limit . This way resource consumption exceeding the limit " carries over " to the next period .
void
rctl_throttle_decay(struct racct *racct, int resource)
{
	struct rctl_rule *rule;
	struct rctl_rule_link *link;
	int64_t minavailable;
	ASSERT_RACCT_ENABLED();
	RACCT_LOCK_ASSERT();
	minavailable = INT64_MAX;
	LIST_FOREACH(link, &racct->r_rule_links, rrl_next) {
		rule = link->rrl_rule;
		if (rule->rr_resource != resource)
			continue;
		if (rule->rr_action != RCTL_ACTION_THROTTLE)
			continue;
		if (rule->rr_amount < minavailable)
			minavailable = rule->rr_amount;
	}
	if (racct->r_resources[resource] < minavailable) {
		racct->r_resources[resource] = 0;
	} else {
		if (racct->r_resources[resource] > minavailable * 10)
			racct->r_resources[resource] = minavailable * 10;
		racct->r_resources[resource] -= minavailable;
	}
}
void rctl_throttle_decay ( struct racct * racct , int resource ) { struct rctl_rule * rule ; struct rctl_rule_link * link ; int64_t minavailable ; ASSERT_RACCT_ENABLED ( ) ; RACCT_LOCK_ASSERT ( ) ; minavailable = INT64_MAX ; LIST_FOREACH ( link , & racct -> r_rule_links , rrl_next ) { rule = link -> rrl_rule ; if ( rule -> rr_resource != resource ) continue ; if ( rule -> rr_action != RCTL_ACTION_THROTTLE ) continue ; if ( rule -> rr_amount < minavailable ) minavailable = rule -> rr_amount ; } if ( racct -> r_resources [ resource ] < minavailable ) { racct -> r_resources [ resource ] = 0 ; } else { if ( racct -> r_resources [ resource ] > minavailable * 10 ) racct -> r_resources [ resource ] = minavailable * 10 ; racct -> r_resources [ resource ] -= minavailable ; } }
Called every second for proc, uidinfo, loginclass, and jail containers.
Called every second for proc uidinfo loginclass and jail containers .
/*
		 * Cap utilization counter at ten times the limit.  Otherwise,
		 * if we changed the rule lowering the allowed amount, it could
		 * take unreasonably long time for the accumulated resource
		 * usage to drop.
		 */