]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
limits-util: drop cgroup v1 support from physical_memory()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 29 Aug 2025 22:16:09 +0000 (07:16 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 17 Nov 2025 12:30:29 +0000 (21:30 +0900)
src/basic/limits-util.c

index 0b5dff39469d630a0abff7b756e4a5c2d78eec6b..d48d67dbf77852d1af244eb8d5f674629d6541b1 100644 (file)
@@ -36,32 +36,19 @@ uint64_t physical_memory(void) {
                 return mem;
         }
 
-        r = cg_all_unified();
+        r = cg_get_attribute(root, "memory.max", &value);
+        if (r == -ENOENT) /* Field does not exist on the system's top-level cgroup, hence don't
+                           * complain. (Note that it might exist on our own root though, if we live
+                           * in a cgroup namespace, hence check anyway instead of not even
+                           * trying.) */
+                return mem;
         if (r < 0) {
-                log_debug_errno(r, "Failed to determine root unified mode, ignoring cgroup memory limit: %m");
+                log_debug_errno(r, "Failed to read memory.max cgroup attribute, ignoring cgroup memory limit: %m");
                 return mem;
         }
-        if (r > 0) {
-                r = cg_get_attribute(root, "memory.max", &value);
-                if (r == -ENOENT) /* Field does not exist on the system's top-level cgroup, hence don't
-                                   * complain. (Note that it might exist on our own root though, if we live
-                                   * in a cgroup namespace, hence check anyway instead of not even
-                                   * trying.) */
-                        return mem;
-                if (r < 0) {
-                        log_debug_errno(r, "Failed to read memory.max cgroup attribute, ignoring cgroup memory limit: %m");
-                        return mem;
-                }
-
-                if (streq(value, "max"))
-                        return mem;
-        } else {
-                r = cg_get_attribute(root, "memory.limit_in_bytes", &value);
-                if (r < 0) {
-                        log_debug_errno(r, "Failed to read memory.limit_in_bytes cgroup attribute, ignoring cgroup memory limit: %m");
-                        return mem;
-                }
-        }
+
+        if (streq(value, "max"))
+                return mem;
 
         r = safe_atou64(value, &lim);
         if (r < 0) {