mirror of
https://github.com/systemd/systemd
synced 2024-10-01 13:55:20 +00:00
core/cgroup: actually make use of the cached accounting values
If cgroup is already gone, i.e. CGRuntime.cgroup_path is NULL, do not return -ENODATA prematurely, but check for cached values first. For #33149
This commit is contained in:
parent
d3d035395e
commit
3849d1f56b
|
@ -4645,11 +4645,11 @@ int unit_get_cpu_usage(Unit *u, nsec_t *ret) {
|
|||
* 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. */
|
||||
|
||||
CGroupRuntime *crt = unit_get_cgroup_runtime(u);
|
||||
if (!crt || !crt->cgroup_path)
|
||||
if (!UNIT_CGROUP_BOOL(u, cpu_accounting))
|
||||
return -ENODATA;
|
||||
|
||||
if (!UNIT_CGROUP_BOOL(u, cpu_accounting))
|
||||
CGroupRuntime *crt = unit_get_cgroup_runtime(u);
|
||||
if (!crt)
|
||||
return -ENODATA;
|
||||
|
||||
r = unit_get_cpu_usage_raw(u, crt, &ns);
|
||||
|
@ -4693,7 +4693,7 @@ int unit_get_ip_accounting(
|
|||
return -ENODATA;
|
||||
|
||||
CGroupRuntime *crt = unit_get_cgroup_runtime(u);
|
||||
if (!crt || !crt->cgroup_path)
|
||||
if (!crt)
|
||||
return -ENODATA;
|
||||
|
||||
fd = IN_SET(metric, CGROUP_IP_INGRESS_BYTES, CGROUP_IP_INGRESS_PACKETS) ?
|
||||
|
@ -4873,7 +4873,7 @@ int unit_get_io_accounting(
|
|||
return -ENODATA;
|
||||
|
||||
CGroupRuntime *crt = unit_get_cgroup_runtime(u);
|
||||
if (!crt || !crt->cgroup_path)
|
||||
if (!crt)
|
||||
return -ENODATA;
|
||||
|
||||
if (allow_cache && crt->io_accounting_last[metric] != UINT64_MAX)
|
||||
|
|
Loading…
Reference in a new issue