From: Mike Yuan Date: Mon, 24 Mar 2025 18:46:46 +0000 (+0100) Subject: core/cgroup: drop extraneous CGRuntime check in unit_get_memory_available() X-Git-Tag: v258-rc1~906^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fc4663b379d14a821932cf684bad1cc2a31fee3c;p=thirdparty%2Fsystemd.git core/cgroup: drop extraneous CGRuntime check in unit_get_memory_available() Currently, for units whose CGRuntime is not allocated just yet, e.g. inactive ones, MemoryAvailable fails to account for their MemoryMax/High settings. Let's remove the CGRuntime check hence. The call to unit_get_memory_accounting() would certainly fail, but it doesn't matter, since 'current' is initially set to 0 anyways. --- diff --git a/src/core/cgroup.c b/src/core/cgroup.c index fb913f7c90e..f608c422f4b 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -4501,10 +4501,6 @@ int unit_get_memory_available(Unit *u, uint64_t *ret) { if (!unit_context) return -ENODATA; - CGroupRuntime *crt = unit_get_cgroup_runtime(u); - if (!crt || !crt->cgroup_path) - continue; - (void) unit_get_memory_accounting(u, CGROUP_MEMORY_CURRENT, ¤t); /* in case of error, previous current propagates as lower bound */