Lines Matching refs:resource
95 static void racct_sub_cred_locked(struct ucred *cred, int resource,
97 static void racct_add_cred_locked(struct ucred *cred, int resource,
397 * Update resource usage in dest.
401 ("%s: resource %d propagation meltdown: dest < 0",
404 ("%s: resource %d propagation meltdown: src < 0",
419 * Update resource usage in dest.
424 ("%s: resource %d propagation meltdown: dest < 0",
427 ("%s: resource %d propagation meltdown: src < 0",
430 ("%s: resource %d propagation meltdown: src > dest",
478 "%ju allocated for resource %d\n",
498 * Increase consumption of 'resource' by 'amount' for 'racct',
503 racct_adjust_resource(struct racct *racct, int resource,
511 racct->r_resources[resource] += amount;
512 if (racct->r_resources[resource] < 0) {
513 KASSERT(RACCT_IS_SLOPPY(resource) || RACCT_IS_DECAYING(resource),
514 ("%s: resource %d usage < 0", __func__, resource));
515 racct->r_resources[resource] = 0;
519 * There are some cases where the racct %cpu resource would grow
523 * resource could grow too much. Also, the 4BSD scheduler sometimes
527 if ((resource == RACCT_PCTCPU) &&
533 racct_add_locked(struct proc *p, int resource, uint64_t amount, int force)
547 error = rctl_enforce(p, resource, amount);
548 if (error && !force && RACCT_IS_DENIABLE(resource)) {
549 SDT_PROBE3(racct, , rusage, add__failure, p, resource, amount);
553 racct_adjust_resource(p->p_racct, resource, amount);
554 racct_add_cred_locked(p->p_ucred, resource, amount);
560 * Increase allocation of 'resource' by 'amount' for process 'p'.
564 racct_add(struct proc *p, int resource, uint64_t amount)
571 SDT_PROBE3(racct, , rusage, add, p, resource, amount);
574 error = racct_add_locked(p, resource, amount, 0);
580 * Increase allocation of 'resource' by 'amount' for process 'p'.
584 racct_add_force(struct proc *p, int resource, uint64_t amount)
590 SDT_PROBE3(racct, , rusage, add__force, p, resource, amount);
593 racct_add_locked(p, resource, amount, 1);
598 racct_add_cred_locked(struct ucred *cred, int resource, uint64_t amount)
604 racct_adjust_resource(cred->cr_ruidinfo->ui_racct, resource, amount);
606 racct_adjust_resource(pr->pr_prison_racct->prr_racct, resource,
608 racct_adjust_resource(cred->cr_loginclass->lc_racct, resource, amount);
612 * Increase allocation of 'resource' by 'amount' for credential 'cred'.
616 racct_add_cred(struct ucred *cred, int resource, uint64_t amount)
622 SDT_PROBE3(racct, , rusage, add__cred, cred, resource, amount);
625 racct_add_cred_locked(cred, resource, amount);
630 * Account for disk IO resource consumption. Checks for limits,
654 racct_set_locked(struct proc *p, int resource, uint64_t amount, int force)
668 old_amount = p->p_racct->r_resources[resource];
673 if (resource == RACCT_PCTCPU) {
685 KASSERT(diff_proc >= 0 || RACCT_CAN_DROP(resource),
686 ("%s: usage of non-droppable resource %d dropping", __func__,
687 resource));
691 error = rctl_enforce(p, resource, diff_proc);
692 if (error && !force && RACCT_IS_DENIABLE(resource)) {
693 SDT_PROBE3(racct, , rusage, set__failure, p, resource,
699 racct_adjust_resource(p->p_racct, resource, diff_proc);
701 racct_add_cred_locked(p->p_ucred, resource, diff_cred);
703 racct_sub_cred_locked(p->p_ucred, resource, -diff_cred);
709 * Set allocation of 'resource' to 'amount' for process 'p'.
716 racct_set_unlocked(struct proc *p, int resource, uint64_t amount)
722 error = racct_set(p, resource, amount);
728 racct_set(struct proc *p, int resource, uint64_t amount)
735 SDT_PROBE3(racct, , rusage, set__force, p, resource, amount);
738 error = racct_set_locked(p, resource, amount, 0);
744 racct_set_force(struct proc *p, int resource, uint64_t amount)
750 SDT_PROBE3(racct, , rusage, set, p, resource, amount);
753 racct_set_locked(p, resource, amount, 1);
758 * Returns amount of 'resource' the process 'p' can keep allocated.
759 * Allocating more than that would be denied, unless the resource
760 * is marked undeniable. Amount of already allocated resource does
764 racct_get_limit(struct proc *p, int resource)
773 available = rctl_get_limit(p, resource);
784 * Returns amount of 'resource' the process 'p' can keep allocated.
785 * Allocating more than that would be denied, unless the resource
786 * is marked undeniable. Amount of already allocated resource does
790 racct_get_available(struct proc *p, int resource)
799 available = rctl_get_available(p, resource);
810 * Returns amount of the %cpu resource that process 'p' can add to its %cpu
834 * Decrease allocation of 'resource' by 'amount' for process 'p'.
837 racct_sub(struct proc *p, int resource, uint64_t amount)
843 SDT_PROBE3(racct, , rusage, sub, p, resource, amount);
849 KASSERT(RACCT_CAN_DROP(resource),
850 ("%s: called for non-droppable resource %d", __func__, resource));
853 KASSERT(amount <= p->p_racct->r_resources[resource],
854 ("%s: freeing %ju of resource %d, which is more "
855 "than allocated %jd for %s (pid %d)", __func__, amount, resource,
856 (intmax_t)p->p_racct->r_resources[resource], p->p_comm, p->p_pid));
858 racct_adjust_resource(p->p_racct, resource, -amount);
859 racct_sub_cred_locked(p->p_ucred, resource, amount);
864 racct_sub_cred_locked(struct ucred *cred, int resource, uint64_t amount)
870 racct_adjust_resource(cred->cr_ruidinfo->ui_racct, resource, -amount);
872 racct_adjust_resource(pr->pr_prison_racct->prr_racct, resource,
874 racct_adjust_resource(cred->cr_loginclass->lc_racct, resource, -amount);
878 * Decrease allocation of 'resource' by 'amount' for credential 'cred'.
881 racct_sub_cred(struct ucred *cred, int resource, uint64_t amount)
887 SDT_PROBE3(racct, , rusage, sub__cred, cred, resource, amount);
890 KASSERT(RACCT_CAN_DROP(resource),
891 ("%s: called for resource %d which can not drop", __func__,
892 resource));
896 racct_sub_cred_locked(cred, resource, amount);
901 * Inherit resource usage information from the parent process.
931 * Inherit resource usage.
1034 * Called after credentials change, to move resource utilisation
1303 * for %cpu resource only after ucred racct containers have been