From a858355e4a7168625ec1b9e5d17fdb6a11dfecb8 Mon Sep 17 00:00:00 2001 From: Anita Zhang Date: Fri, 26 Mar 2021 01:19:10 -0700 Subject: [PATCH] oomd: force DefaultMemoryPressureDurationSec= to be greater than or equal 1 sec --- man/oomd.conf.xml | 2 +- src/oom/oomd.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/man/oomd.conf.xml b/man/oomd.conf.xml index 6156c98fbd9..0ae7e109b1c 100644 --- a/man/oomd.conf.xml +++ b/man/oomd.conf.xml @@ -81,7 +81,7 @@ Sets the amount of time a unit's control group needs to have exceeded memory pressure limits before systemd-oomd will take action. Memory pressure limits are defined by DefaultMemoryPressureLimit= and ManagedOOMMemoryPressureLimit=. - Defaults to 30 seconds when this property is unset or set to 0. + Must be set to 0, or at least 1 second. Defaults to 30 seconds when unset or 0. diff --git a/src/oom/oomd.c b/src/oom/oomd.c index 6e2a5889d1e..deb7b094d50 100644 --- a/src/oom/oomd.c +++ b/src/oom/oomd.c @@ -155,6 +155,9 @@ static int run(int argc, char *argv[]) { 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) + log_error_errno(SYNTHETIC_ERRNO(EINVAL), "DefaultMemoryPressureDurationSec= must be 0 or at least 1s"); + r = manager_new(&m); if (r < 0) return log_error_errno(r, "Failed to create manager: %m"); -- 2.47.3