]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mempress: change default PSI window duration to 2s
authorLennart Poettering <lennart@poettering.net>
Thu, 9 Mar 2023 11:34:23 +0000 (12:34 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 9 Mar 2023 21:31:20 +0000 (22:31 +0100)
This changes the PSI window duration we default to for watching memory
pressure events from 1s to 2s. This is because apparently the kernel
will soon disallow window durations other than 2s for unprivileged
processes.

Hence, we'll bump the threshold from 100m to 200ms, and the window from
1s to 2s.

man/systemd-system.conf.xml
man/systemd.resource-control.xml
src/basic/psi-util.h
src/libsystemd/sd-event/sd-event.c
test/units/testsuite-79.sh

index 829b4be0ed532b421105b66db5f899e52653806d..554d0fbd451629e26e524bb8fcf4031cfa3ffd63 100644 (file)
         <varname>MemoryPressureWatch=</varname> and <varname>MemoryPressureThresholdSec=</varname>
         settings. See
         <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>
-        for details. Defaults to <literal>auto</literal> and <literal>100ms</literal>, respectively. This
+        for details. Defaults to <literal>auto</literal> and <literal>200ms</literal>, respectively. This
         also sets the memory pressure monitoring threshold for the service manager itself.</para></listitem>
       </varlistentry>
     </variablelist>
index d18fd9a94cd52fe00d93a84c7ea245d4038c5b4e..21e434216539eb3b7d00ea742ab441e5e2ae74fb 100644 (file)
@@ -1332,10 +1332,10 @@ DeviceAllow=/dev/loop-control
 
         <listitem><para>Sets the memory pressure threshold time for memory pressure monitor as configured via
         <varname>MemoryPressureWatch=</varname>. Specifies the maximum allocation latency before a memory
-        pressure event is signalled to the service, per 1s window. If not specified defaults to the
+        pressure event is signalled to the service, per 2s window. If not specified defaults to the
         <varname>DefaultMemoryPressureThresholdSec=</varname> setting in
         <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
-        (which in turn defaults to 100ms). The specified value expects a time unit such as
+        (which in turn defaults to 200ms). The specified value expects a time unit such as
         <literal>ms</literal> or <literal>µs</literal>, see
         <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
         details on the permitted syntax.</para></listitem>
index 558a130996b1b79b4a5f1b095744ee8d19714c21..bf8f4fe51c2b7f8726d13eee74c03674ad80cce6 100644 (file)
@@ -31,5 +31,5 @@ int is_pressure_supported(void);
 
 /* Default parameters for memory pressure watch logic in sd-event and PID 1 */
 #define MEMORY_PRESSURE_DEFAULT_TYPE "some"
-#define MEMORY_PRESSURE_DEFAULT_THRESHOLD_USEC (100 * USEC_PER_MSEC)
-#define MEMORY_PRESSURE_DEFAULT_WINDOW_USEC USEC_PER_SEC
+#define MEMORY_PRESSURE_DEFAULT_THRESHOLD_USEC (200 * USEC_PER_MSEC)
+#define MEMORY_PRESSURE_DEFAULT_WINDOW_USEC (2 * USEC_PER_SEC)
index 413ac16aa29b9e822a529b2c5259895bfc928b4f..f11f35ef6e858677447a4382586b0b0da9a164de 100644 (file)
@@ -2005,7 +2005,9 @@ _public_ int sd_event_add_memory_pressure(
                  *     some 100000 1000000
                  *     full 100000 1000000
                  *
-                 * We'll default to the middle level that both agree on */
+                 * We'll default to the middle level that both agree on. Except we do it on a 2s window
+                 * (i.e. 200ms per 2s, rather than 100ms per 1s), because that's the window duration the
+                 * kernel will allow us to do unprivileged, also in the future. */
                 if (asprintf((char**) &write_buffer,
                              "%s " USEC_FMT " " USEC_FMT,
                              MEMORY_PRESSURE_DEFAULT_TYPE,
index b11923bc07df57376acdffe656f35118c61dfefa..cced3205c590ea53882a05da9519279edfa4db65 100755 (executable)
@@ -43,7 +43,7 @@ test -w "$MEMORY_PRESSURE_WATCH"
 
 ls -al "$MEMORY_PRESSURE_WATCH"
 
-EXPECTED="$(echo -n -e "some 123000 1000000\x00" | base64)"
+EXPECTED="$(echo -n -e "some 123000 2000000\x00" | base64)"
 
 test "$EXPECTED" = "$MEMORY_PRESSURE_WRITE"