bool has_weight = cgroup_context_has_cpu_weight(c);
bool has_shares = cgroup_context_has_cpu_shares(c);
- if (cg_all_unified() > 0) {
+ if (cg_unified() > 0) {
uint64_t weight;
if (has_weight)
}
if ((mask & CGROUP_MASK_MEMORY) && !is_root) {
- if (cg_all_unified() > 0) {
+ if (cg_unified() > 0) {
uint64_t max = c->memory_max;
if (cgroup_context_has_unified_memory_config(c))
if ((mask & CGROUP_MASK_PIDS) && !is_root) {
- if (c->tasks_max != (uint64_t) -1) {
+ if (c->tasks_max != CGROUP_LIMIT_MAX) {
char buf[DECIMAL_STR_MAX(uint64_t) + 2];
sprintf(buf, "%" PRIu64 "\n", c->tasks_max);
e = unit_get_exec_context(u);
if (!e ||
exec_context_maintains_privileges(e) ||
- cg_all_unified() > 0)
+ cg_unified() > 0)
return _CGROUP_MASK_ALL;
}
return 0;
/* Only applies to the unified hierarchy */
- r = cg_all_unified();
+ r = cg_unified();
if (r < 0)
return log_unit_error_errno(u, r, "Failed detect whether the unified hierarchy is used: %m");
if (r == 0)
if (!u->cgroup_path)
return;
- (void) unit_get_cpu_usage(u, NULL); /* Cache the last CPU usage value before we destroy the cgroup */
-
is_root_slice = unit_has_name(u, SPECIAL_ROOT_SLICE);
r = cg_trim_everywhere(u->manager->cgroup_supported, u->cgroup_path, !is_root_slice);
if (!u->cgroup_path)
return -ENOENT;
- if (cg_all_unified() > 0) /* On unified we can use proper notifications */
+ if (cg_unified() > 0) /* On unified we can use proper notifications */
return 0;
return unit_watch_pids_in_path(u, u->cgroup_path);
if (r < 0)
return log_error_errno(r, "Cannot find cgroup mount point: %m");
- unified = cg_all_unified();
+ unified = cg_unified();
if (unified < 0)
return log_error_errno(r, "Couldn't determine if we are running in the unified hierarchy: %m");
if (unified > 0)
if ((u->cgroup_realized_mask & CGROUP_MASK_MEMORY) == 0)
return -ENODATA;
- if (cg_all_unified() <= 0)
+ if (cg_unified() <= 0)
r = cg_get_attribute("memory", u->cgroup_path, "memory.usage_in_bytes", &v);
else
r = cg_get_attribute("memory", u->cgroup_path, "memory.current", &v);
if (!u->cgroup_path)
return -ENODATA;
- if (cg_all_unified() > 0) {
+ if (cg_unified() > 0) {
const char *keys[] = { "usage_usec", NULL };
_cleanup_free_ char *val = NULL;
uint64_t us;
nsec_t ns;
int r;
- assert(u);
-
- /* Retrieve the current CPU usage counter. This will subtract the CPU counter taken when the unit was
- * started. If the cgroup has been removed already, returns the last cached value. To cache the value, simply
- * call this function with a NULL return value. */
-
r = unit_get_cpu_usage_raw(u, &ns);
- if (r == -ENODATA && u->cpu_usage_last != NSEC_INFINITY) {
- /* If we can't get the CPU usage anymore (because the cgroup was already removed, for example), use our
- * cached value. */
-
- if (ret)
- *ret = u->cpu_usage_last;
- return 0;
- }
if (r < 0)
return r;
else
ns = 0;
- u->cpu_usage_last = ns;
- if (ret)
- *ret = ns;
-
+ *ret = ns;
return 0;
}
assert(u);
- u->cpu_usage_last = NSEC_INFINITY;
-
r = unit_get_cpu_usage_raw(u, &ns);
if (r < 0) {
u->cpu_usage_base = 0;