]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
oomd: refuse to start if cgroup memory controller is not available
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 11 Sep 2021 11:34:53 +0000 (20:34 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 12 Sep 2021 01:28:24 +0000 (10:28 +0900)
src/oom/oomd.c

index 8d4014ee0633d73a69ce3e394870b2b79fbd8ade..5b50833df79bcc241611e288e0ad3113f16d4ecd 100644 (file)
@@ -120,6 +120,7 @@ static int run(int argc, char *argv[]) {
         _cleanup_(manager_freep) Manager *m = NULL;
         _cleanup_free_ char *swap = NULL;
         unsigned long long s = 0;
+        CGroupMask mask;
         int r;
 
         log_setup();
@@ -153,6 +154,13 @@ static int run(int argc, char *argv[]) {
         if (r == 0)
                 return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "Requires the unified cgroups hierarchy");
 
+        r = cg_mask_supported(&mask);
+        if (r < 0)
+                return log_error_errno(r, "Failed to get supported cgroup controllers: %m");
+
+        if (!FLAGS_SET(mask, CGROUP_MASK_MEMORY))
+                return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "Requires the cgroup memory controller.");
+
         assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0);
 
         if (arg_mem_pressure_usec > 0 && arg_mem_pressure_usec < 1 * USEC_PER_SEC)