FreeBSD/sys/kern/kern_rctl.c
/*
 * Special version of rctl_get_available() for the %CPU resource.
 * We slightly cheat here and return less than we normally would.
 */
Special version of rctl_get_available() for the %CPU resource.
We slightly cheat here and return less than we normally would.
Special version of rctl_get_available () for the %CPU resource . We slightly cheat here and return less than we normally would .
int64_t
rctl_pcpu_available(const struct proc *p) {
	struct rctl_rule *rule;
	struct rctl_rule_link *link;
	int64_t available, minavailable, limit;
	ASSERT_RACCT_ENABLED();
	RACCT_LOCK_ASSERT();
	minavailable = INT64_MAX;
	limit = 0;
	LIST_FOREACH(link, &p->p_racct->r_rule_links, rrl_next) {
		rule = link->rrl_rule;
		if (rule->rr_resource != RACCT_PCTCPU)
			continue;
		if (rule->rr_action != RCTL_ACTION_DENY)
			continue;
		available = rctl_available_resource(p, rule);
		if (available < minavailable) {
			minavailable = available;
			limit = rule->rr_amount;
		}
	}
	if (limit != 0) {
		if (limit > 2 * RCTL_PCPU_SHIFT)
			minavailable -= RCTL_PCPU_SHIFT;
		else
			minavailable -= (limit / 2);
	}
	return (minavailable);
}
int64_t rctl_pcpu_available ( const struct proc * p ) { struct rctl_rule * rule ; struct rctl_rule_link * link ; int64_t available , minavailable , limit ; ASSERT_RACCT_ENABLED ( ) ; RACCT_LOCK_ASSERT ( ) ; minavailable = INT64_MAX ; limit = 0 ; LIST_FOREACH ( link , & p -> p_racct -> r_rule_links , rrl_next ) { rule = link -> rrl_rule ; if ( rule -> rr_resource != RACCT_PCTCPU ) continue ; if ( rule -> rr_action != RCTL_ACTION_DENY ) continue ; available = rctl_available_resource ( p , rule ) ; if ( available < minavailable ) { minavailable = available ; limit = rule -> rr_amount ; } } if ( limit != 0 ) { if ( limit > 2 * RCTL_PCPU_SHIFT ) minavailable -= RCTL_PCPU_SHIFT ; else minavailable -= ( limit / 2 ) ; } return ( minavailable ) ; }
Special version of rctl_get_available() for the %CPU resource.
Special version of rctl_get_available () for the %CPU resource .
/*
	 * Return slightly less than actual value of the available
	 * %cpu resource.  This makes %cpu throttling more aggressive
	 * and lets us act sooner than the limits are already exceeded.
	 */