Lines Matching full:resource

62 FEATURE(racct, "Resource Accounting");
75 "Resource Accounting");
95 static void racct_sub_cred_locked(struct ucred *cred, int resource,
97 static void racct_add_cred_locked(struct ucred *cred, int resource,
382 * Update resource usage in dest. in racct_add_racct()
386 ("%s: resource %d propagation meltdown: dest < 0", in racct_add_racct()
389 ("%s: resource %d propagation meltdown: src < 0", in racct_add_racct()
404 * Update resource usage in dest. in racct_sub_racct()
409 ("%s: resource %d propagation meltdown: dest < 0", in racct_sub_racct()
412 ("%s: resource %d propagation meltdown: src < 0", in racct_sub_racct()
415 ("%s: resource %d propagation meltdown: src > dest", in racct_sub_racct()
463 "%ju allocated for resource %d\n", in racct_destroy_locked()
483 * Increase consumption of 'resource' by 'amount' for 'racct',
488 racct_adjust_resource(struct racct *racct, int resource, in racct_adjust_resource() argument
496 racct->r_resources[resource] += amount; in racct_adjust_resource()
497 if (racct->r_resources[resource] < 0) { in racct_adjust_resource()
498 KASSERT(RACCT_IS_SLOPPY(resource) || RACCT_IS_DECAYING(resource), in racct_adjust_resource()
499 ("%s: resource %d usage < 0", __func__, resource)); in racct_adjust_resource()
500 racct->r_resources[resource] = 0; in racct_adjust_resource()
504 * There are some cases where the racct %cpu resource would grow in racct_adjust_resource()
508 * resource could grow too much. Also, the 4BSD scheduler sometimes in racct_adjust_resource()
512 if ((resource == RACCT_PCTCPU) && in racct_adjust_resource()
518 racct_add_locked(struct proc *p, int resource, uint64_t amount, int force) in racct_add_locked() argument
532 error = rctl_enforce(p, resource, amount); in racct_add_locked()
533 if (error && !force && RACCT_IS_DENIABLE(resource)) { in racct_add_locked()
534 SDT_PROBE3(racct, , rusage, add__failure, p, resource, amount); in racct_add_locked()
538 racct_adjust_resource(p->p_racct, resource, amount); in racct_add_locked()
539 racct_add_cred_locked(p->p_ucred, resource, amount); in racct_add_locked()
545 * Increase allocation of 'resource' by 'amount' for process 'p'.
549 racct_add(struct proc *p, int resource, uint64_t amount) in racct_add() argument
556 SDT_PROBE3(racct, , rusage, add, p, resource, amount); in racct_add()
559 error = racct_add_locked(p, resource, amount, 0); in racct_add()
565 * Increase allocation of 'resource' by 'amount' for process 'p'.
569 racct_add_force(struct proc *p, int resource, uint64_t amount) in racct_add_force() argument
575 SDT_PROBE3(racct, , rusage, add__force, p, resource, amount); in racct_add_force()
578 racct_add_locked(p, resource, amount, 1); in racct_add_force()
583 racct_add_cred_locked(struct ucred *cred, int resource, uint64_t amount) in racct_add_cred_locked() argument
589 racct_adjust_resource(cred->cr_ruidinfo->ui_racct, resource, amount); in racct_add_cred_locked()
591 racct_adjust_resource(pr->pr_prison_racct->prr_racct, resource, in racct_add_cred_locked()
593 racct_adjust_resource(cred->cr_loginclass->lc_racct, resource, amount); in racct_add_cred_locked()
597 * Increase allocation of 'resource' by 'amount' for credential 'cred'.
601 racct_add_cred(struct ucred *cred, int resource, uint64_t amount) in racct_add_cred() argument
607 SDT_PROBE3(racct, , rusage, add__cred, cred, resource, amount); in racct_add_cred()
610 racct_add_cred_locked(cred, resource, amount); in racct_add_cred()
615 * Account for disk IO resource consumption. Checks for limits,
639 racct_set_locked(struct proc *p, int resource, uint64_t amount, int force) in racct_set_locked() argument
653 old_amount = p->p_racct->r_resources[resource]; in racct_set_locked()
658 if (resource == RACCT_PCTCPU) { in racct_set_locked()
670 KASSERT(diff_proc >= 0 || RACCT_CAN_DROP(resource), in racct_set_locked()
671 ("%s: usage of non-droppable resource %d dropping", __func__, in racct_set_locked()
672 resource)); in racct_set_locked()
676 error = rctl_enforce(p, resource, diff_proc); in racct_set_locked()
677 if (error && !force && RACCT_IS_DENIABLE(resource)) { in racct_set_locked()
678 SDT_PROBE3(racct, , rusage, set__failure, p, resource, in racct_set_locked()
684 racct_adjust_resource(p->p_racct, resource, diff_proc); in racct_set_locked()
686 racct_add_cred_locked(p->p_ucred, resource, diff_cred); in racct_set_locked()
688 racct_sub_cred_locked(p->p_ucred, resource, -diff_cred); in racct_set_locked()
694 * Set allocation of 'resource' to 'amount' for process 'p'.
701 racct_set_unlocked(struct proc *p, int resource, uint64_t amount) in racct_set_unlocked() argument
707 error = racct_set(p, resource, amount); in racct_set_unlocked()
713 racct_set(struct proc *p, int resource, uint64_t amount) in racct_set() argument
720 SDT_PROBE3(racct, , rusage, set__force, p, resource, amount); in racct_set()
723 error = racct_set_locked(p, resource, amount, 0); in racct_set()
729 racct_set_force(struct proc *p, int resource, uint64_t amount) in racct_set_force() argument
735 SDT_PROBE3(racct, , rusage, set, p, resource, amount); in racct_set_force()
738 racct_set_locked(p, resource, amount, 1); in racct_set_force()
743 * Returns amount of 'resource' the process 'p' can keep allocated.
744 * Allocating more than that would be denied, unless the resource
745 * is marked undeniable. Amount of already allocated resource does
749 racct_get_limit(struct proc *p, int resource) in racct_get_limit() argument
758 available = rctl_get_limit(p, resource); in racct_get_limit()
769 * Returns amount of 'resource' the process 'p' can keep allocated.
770 * Allocating more than that would be denied, unless the resource
771 * is marked undeniable. Amount of already allocated resource does
775 racct_get_available(struct proc *p, int resource) in racct_get_available() argument
784 available = rctl_get_available(p, resource); in racct_get_available()
795 * Returns amount of the %cpu resource that process 'p' can add to its %cpu
819 * Decrease allocation of 'resource' by 'amount' for process 'p'.
822 racct_sub(struct proc *p, int resource, uint64_t amount) in racct_sub() argument
828 SDT_PROBE3(racct, , rusage, sub, p, resource, amount); in racct_sub()
834 KASSERT(RACCT_CAN_DROP(resource), in racct_sub()
835 ("%s: called for non-droppable resource %d", __func__, resource)); in racct_sub()
838 KASSERT(amount <= p->p_racct->r_resources[resource], in racct_sub()
839 ("%s: freeing %ju of resource %d, which is more " in racct_sub()
840 "than allocated %jd for %s (pid %d)", __func__, amount, resource, in racct_sub()
841 (intmax_t)p->p_racct->r_resources[resource], p->p_comm, p->p_pid)); in racct_sub()
843 racct_adjust_resource(p->p_racct, resource, -amount); in racct_sub()
844 racct_sub_cred_locked(p->p_ucred, resource, amount); in racct_sub()
849 racct_sub_cred_locked(struct ucred *cred, int resource, uint64_t amount) in racct_sub_cred_locked() argument
855 racct_adjust_resource(cred->cr_ruidinfo->ui_racct, resource, -amount); in racct_sub_cred_locked()
857 racct_adjust_resource(pr->pr_prison_racct->prr_racct, resource, in racct_sub_cred_locked()
859 racct_adjust_resource(cred->cr_loginclass->lc_racct, resource, -amount); in racct_sub_cred_locked()
863 * Decrease allocation of 'resource' by 'amount' for credential 'cred'.
866 racct_sub_cred(struct ucred *cred, int resource, uint64_t amount) in racct_sub_cred() argument
872 SDT_PROBE3(racct, , rusage, sub__cred, cred, resource, amount); in racct_sub_cred()
875 KASSERT(RACCT_CAN_DROP(resource), in racct_sub_cred()
876 ("%s: called for resource %d which can not drop", __func__, in racct_sub_cred()
877 resource)); in racct_sub_cred()
881 racct_sub_cred_locked(cred, resource, amount); in racct_sub_cred()
886 * Inherit resource usage information from the parent process.
916 * Inherit resource usage. in racct_proc_fork()
1019 * Called after credentials change, to move resource utilisation
1289 * for %cpu resource only after ucred racct containers have been in racctd()