From: Anita Zhang Date: Fri, 26 Mar 2021 08:19:10 +0000 (-0700) Subject: oomd: force DefaultMemoryPressureDurationSec= to be greater than or equal 1 sec X-Git-Tag: v249-rc1~478^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a858355e4a7168625ec1b9e5d17fdb6a11dfecb8;p=thirdparty%2Fsystemd.git oomd: force DefaultMemoryPressureDurationSec= to be greater than or equal 1 sec --- 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");