]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/cgroup: drop extraneous CGRuntime check in unit_get_memory_available()
authorMike Yuan <me@yhndnzj.com>
Mon, 24 Mar 2025 18:46:46 +0000 (19:46 +0100)
committerMike Yuan <me@yhndnzj.com>
Fri, 4 Apr 2025 13:34:52 +0000 (15:34 +0200)
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.

src/core/cgroup.c

index fb913f7c90e551f45f6770e606912d2ba2ea121e..f608c422f4b5b594c10b3d128824edf613388cd5 100644 (file)
@@ -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, &current);
                 /* in case of error, previous current propagates as lower bound */