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,
99 static int racct_set_locked(struct proc *p, int resource, uint64_t amount,
327 * Update resource usage in dest. in racct_add_racct()
331 ("%s: resource %d propagation meltdown: dest < 0", in racct_add_racct()
334 ("%s: resource %d propagation meltdown: src < 0", in racct_add_racct()
349 * Update resource usage in dest. in racct_sub_racct()
354 ("%s: resource %d propagation meltdown: dest < 0", in racct_sub_racct()
357 ("%s: resource %d propagation meltdown: src < 0", in racct_sub_racct()
360 ("%s: resource %d propagation meltdown: src > dest", in racct_sub_racct()
408 "%ju allocated for resource %d\n", in racct_destroy_locked()
428 * Increase consumption of 'resource' by 'amount' for 'racct',
433 racct_adjust_resource(struct racct *racct, int resource, in racct_adjust_resource() argument
441 racct->r_resources[resource] += amount; in racct_adjust_resource()
442 if (racct->r_resources[resource] < 0) { in racct_adjust_resource()
443 KASSERT(RACCT_IS_SLOPPY(resource) || RACCT_IS_DECAYING(resource), in racct_adjust_resource()
444 ("%s: resource %d usage < 0", __func__, resource)); in racct_adjust_resource()
445 racct->r_resources[resource] = 0; in racct_adjust_resource()
450 racct_add_locked(struct proc *p, int resource, uint64_t amount, int force) in racct_add_locked() argument
464 error = rctl_enforce(p, resource, amount); in racct_add_locked()
465 if (error && !force && RACCT_IS_DENIABLE(resource)) { in racct_add_locked()
466 SDT_PROBE3(racct, , rusage, add__failure, p, resource, amount); in racct_add_locked()
470 racct_adjust_resource(p->p_racct, resource, amount); in racct_add_locked()
471 racct_add_cred_locked(p->p_ucred, resource, amount); in racct_add_locked()
477 * Increase allocation of 'resource' by 'amount' for process 'p'.
481 racct_add(struct proc *p, int resource, uint64_t amount) in racct_add() argument
488 SDT_PROBE3(racct, , rusage, add, p, resource, amount); in racct_add()
491 error = racct_add_locked(p, resource, amount, 0); in racct_add()
497 * Increase allocation of 'resource' by 'amount' for process 'p'.
501 racct_add_force(struct proc *p, int resource, uint64_t amount) in racct_add_force() argument
507 SDT_PROBE3(racct, , rusage, add__force, p, resource, amount); in racct_add_force()
510 racct_add_locked(p, resource, amount, 1); in racct_add_force()
515 racct_add_cred_locked(struct ucred *cred, int resource, uint64_t amount) in racct_add_cred_locked() argument
521 racct_adjust_resource(cred->cr_ruidinfo->ui_racct, resource, amount); in racct_add_cred_locked()
523 racct_adjust_resource(pr->pr_prison_racct->prr_racct, resource, in racct_add_cred_locked()
525 racct_adjust_resource(cred->cr_loginclass->lc_racct, resource, amount); in racct_add_cred_locked()
529 * Increase allocation of 'resource' by 'amount' for credential 'cred'.
533 racct_add_cred(struct ucred *cred, int resource, uint64_t amount) in racct_add_cred() argument
539 SDT_PROBE3(racct, , rusage, add__cred, cred, resource, amount); in racct_add_cred()
542 racct_add_cred_locked(cred, resource, amount); in racct_add_cred()
547 * Account for disk IO resource consumption. Checks for limits,
605 racct_set_locked(struct proc *p, int resource, uint64_t amount, int force) in racct_set_locked() argument
619 old_amount = p->p_racct->r_resources[resource]; in racct_set_locked()
626 KASSERT(diff_proc >= 0 || RACCT_CAN_DROP(resource), in racct_set_locked()
627 ("%s: usage of non-droppable resource %d dropping", __func__, in racct_set_locked()
628 resource)); in racct_set_locked()
632 error = rctl_enforce(p, resource, diff_proc); in racct_set_locked()
633 if (error && !force && RACCT_IS_DENIABLE(resource)) { in racct_set_locked()
634 SDT_PROBE3(racct, , rusage, set__failure, p, resource, in racct_set_locked()
640 racct_adjust_resource(p->p_racct, resource, diff_proc); in racct_set_locked()
642 racct_add_cred_locked(p->p_ucred, resource, diff_cred); in racct_set_locked()
644 racct_sub_cred_locked(p->p_ucred, resource, -diff_cred); in racct_set_locked()
650 * Set allocation of 'resource' to 'amount' for process 'p'.
657 racct_set_unlocked(struct proc *p, int resource, uint64_t amount) in racct_set_unlocked() argument
663 error = racct_set(p, resource, amount); in racct_set_unlocked()
669 racct_set(struct proc *p, int resource, uint64_t amount) in racct_set() argument
676 SDT_PROBE3(racct, , rusage, set__force, p, resource, amount); in racct_set()
679 error = racct_set_locked(p, resource, amount, 0); in racct_set()
685 racct_set_force(struct proc *p, int resource, uint64_t amount) in racct_set_force() argument
691 SDT_PROBE3(racct, , rusage, set, p, resource, amount); in racct_set_force()
694 racct_set_locked(p, resource, amount, 1); in racct_set_force()
699 * Returns amount of 'resource' the process 'p' can keep allocated.
700 * Allocating more than that would be denied, unless the resource
701 * is marked undeniable. Amount of already allocated resource does
705 racct_get_limit(struct proc *p, int resource) in racct_get_limit() argument
714 available = rctl_get_limit(p, resource); in racct_get_limit()
725 * Returns amount of 'resource' the process 'p' can keep allocated.
726 * Allocating more than that would be denied, unless the resource
727 * is marked undeniable. Amount of already allocated resource does
731 racct_get_available(struct proc *p, int resource) in racct_get_available() argument
740 available = rctl_get_available(p, resource); in racct_get_available()
751 * Returns amount of the %cpu resource that process 'p' can add to its %cpu
775 * Decrease allocation of 'resource' by 'amount' for process 'p'.
778 racct_sub(struct proc *p, int resource, uint64_t amount) in racct_sub() argument
784 SDT_PROBE3(racct, , rusage, sub, p, resource, amount); in racct_sub()
790 KASSERT(RACCT_CAN_DROP(resource), in racct_sub()
791 ("%s: called for non-droppable resource %d", __func__, resource)); in racct_sub()
794 KASSERT(amount <= p->p_racct->r_resources[resource], in racct_sub()
795 ("%s: freeing %ju of resource %d, which is more " in racct_sub()
796 "than allocated %jd for %s (pid %d)", __func__, amount, resource, in racct_sub()
797 (intmax_t)p->p_racct->r_resources[resource], p->p_comm, p->p_pid)); in racct_sub()
799 racct_adjust_resource(p->p_racct, resource, -amount); in racct_sub()
800 racct_sub_cred_locked(p->p_ucred, resource, amount); in racct_sub()
805 racct_sub_cred_locked(struct ucred *cred, int resource, uint64_t amount) in racct_sub_cred_locked() argument
811 racct_adjust_resource(cred->cr_ruidinfo->ui_racct, resource, -amount); in racct_sub_cred_locked()
813 racct_adjust_resource(pr->pr_prison_racct->prr_racct, resource, in racct_sub_cred_locked()
815 racct_adjust_resource(cred->cr_loginclass->lc_racct, resource, -amount); in racct_sub_cred_locked()
819 * Decrease allocation of 'resource' by 'amount' for credential 'cred'.
822 racct_sub_cred(struct ucred *cred, int resource, uint64_t amount) in racct_sub_cred() argument
828 SDT_PROBE3(racct, , rusage, sub__cred, cred, resource, amount); in racct_sub_cred()
831 KASSERT(RACCT_CAN_DROP(resource), in racct_sub_cred()
832 ("%s: called for resource %d which can not drop", __func__, in racct_sub_cred()
833 resource)); in racct_sub_cred()
837 racct_sub_cred_locked(cred, resource, amount); in racct_sub_cred()
842 * Inherit resource usage information from the parent process.
870 * Inherit resource usage. in racct_proc_fork()
952 * Called after credentials change, to move resource utilisation
1282 * for %cpu resource only after ucred racct containers have been in racctd()