]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
man: document systemd-oomd and related items
authorAnita Zhang <the.anitazha@gmail.com>
Wed, 9 Sep 2020 08:04:36 +0000 (01:04 -0700)
committerAnita Zhang <the.anitazha@gmail.com>
Fri, 9 Oct 2020 09:40:19 +0000 (02:40 -0700)
man/oomctl.xml [new file with mode: 0644]
man/oomd.conf.xml [new file with mode: 0644]
man/rules/meson.build
man/systemd-oomd.service.xml [new file with mode: 0644]
man/systemd.resource-control.xml

diff --git a/man/oomctl.xml b/man/oomctl.xml
new file mode 100644 (file)
index 0000000..10633b9
--- /dev/null
@@ -0,0 +1,86 @@
+<?xml version='1.0'?> <!--*-nxml-*-->
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+  "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
+<!-- SPDX-License-Identifier: LGPL-2.1+ -->
+
+<refentry id="oomctl" conditional='ENABLE_OOMD'
+  xmlns:xi="http://www.w3.org/2001/XInclude">
+
+  <refentryinfo>
+    <title>oomctl</title>
+    <productname>systemd</productname>
+  </refentryinfo>
+
+  <refmeta>
+    <refentrytitle>oomctl</refentrytitle>
+    <manvolnum>1</manvolnum>
+  </refmeta>
+
+  <refnamediv>
+    <refname>oomctl</refname>
+    <refpurpose>Analyze the state stored in <command>systemd-oomd</command></refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <cmdsynopsis>
+      <command>oomctl</command>
+      <arg choice="opt" rep="repeat">OPTIONS</arg>
+      <arg choice="req">COMMAND</arg>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+  <refsect1>
+    <title>Description</title>
+
+    <para><command>oomctl</command> may be used to get information about the various contexts read in by
+    the <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> userspace
+    out-of-memory (OOM) killer,
+    <citerefentry><refentrytitle>systemd-oomd</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para>
+
+  </refsect1>
+
+  <refsect1>
+    <title>Commands</title>
+
+    <para>The following commands are understood:</para>
+
+    <variablelist>
+      <varlistentry>
+        <term><command>dump</command></term>
+
+        <listitem><para>Show the current state of the cgroup(s) and system context(s) stored by
+        <command>systemd-oomd</command>.</para></listitem>
+      </varlistentry>
+
+    </variablelist>
+
+  </refsect1>
+
+  <refsect1>
+    <title>Options</title>
+
+    <para>The following options are understood:</para>
+
+    <variablelist>
+      <xi:include href="standard-options.xml" xpointer="help" />
+      <xi:include href="standard-options.xml" xpointer="version" />
+      <xi:include href="standard-options.xml" xpointer="no-pager" />
+    </variablelist>
+  </refsect1>
+
+  <refsect1>
+    <title>Exit status</title>
+
+    <para>On success, 0 is returned, a non-zero failure code otherwise.</para>
+  </refsect1>
+
+  <refsect1>
+    <title>See Also</title>
+    <para>
+      <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
+      <citerefentry><refentrytitle>systemd-oomd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
+      <citerefentry><refentrytitle>oomd.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
+    </para>
+  </refsect1>
+
+</refentry>
diff --git a/man/oomd.conf.xml b/man/oomd.conf.xml
new file mode 100644 (file)
index 0000000..e6be947
--- /dev/null
@@ -0,0 +1,88 @@
+<?xml version='1.0'?> <!--*-nxml-*-->
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+  "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
+<!-- SPDX-License-Identifier: LGPL-2.1+ -->
+
+<refentry id="oomd.conf" conditional='ENABLE_OOMD'
+    xmlns:xi="http://www.w3.org/2001/XInclude">
+  <refentryinfo>
+    <title>oomd.conf</title>
+    <productname>systemd</productname>
+  </refentryinfo>
+
+  <refmeta>
+    <refentrytitle>oomd.conf</refentrytitle>
+    <manvolnum>5</manvolnum>
+  </refmeta>
+
+  <refnamediv>
+    <refname>oomd.conf</refname>
+    <refname>oomd.conf.d</refname>
+    <refpurpose>Global <command>systemd-oomd</command> configuration files</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <para><filename>/etc/systemd/oomd.conf</filename></para>
+    <para><filename>/etc/systemd/oomd.conf.d/*.conf</filename></para>
+    <para><filename>/usr/lib/systemd/oomd.conf.d/*.conf</filename></para>
+  </refsynopsisdiv>
+
+  <refsect1>
+    <title>Description</title>
+
+    <para>These files configure the various parameters of the
+    <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> userspace
+    out-of-memory (OOM) killer,
+    <citerefentry><refentrytitle>systemd-oomd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
+    See <citerefentry><refentrytitle>systemd.syntax</refentrytitle><manvolnum>7</manvolnum></citerefentry>
+    for a general description of the syntax.</para>
+
+  </refsect1>
+
+  <xi:include href="standard-conf.xml" xpointer="main-conf" />
+
+  <refsect1>
+    <title>[OOM] Section Options</title>
+
+    <para>The following options are available in the [OOM] section:</para>
+
+    <variablelist class='config-directives'>
+      <varlistentry>
+        <term><varname>SwapUsedLimitPercent=</varname></term>
+
+        <listitem><para>Sets the limit for swap usage on the system before <command>systemd-oomd</command> will
+        take action. If the percentage of swap used on the system is more than what is defined here,
+        <command>systemd-oomd</command> will act on eligible descendant cgroups, starting from the ones with the
+        highest swap usage to the lowest swap usage. Which cgroups are monitored and what
+        action gets taken depends on what the unit has configured for <varname>ManagedOOMSwap=</varname>.
+        Takes a percentage value between 0% and 100%, inclusive. Defaults to 90%.</para></listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><varname>DefaultMemoryPressureLimitPercent=</varname></term>
+
+        <listitem><para>Sets the limit for memory pressure on the unit's cgroup before <command>systemd-oomd</command>
+        will take action. A unit can override this value with <varname>ManagedOOMMemoryPressureLimitPercent=</varname>.
+        The memory pressure for this property represents the fraction of time in a 10 second window in which all tasks
+        in the cgroup were delayed. For each monitored cgroup, if the memory pressure on that cgroup exceeds the
+        limit set for more than 30 seconds, <command>systemd-oomd</command> will act on eligible descendant cgroups,
+        starting from the ones with the most reclaim activity to the least reclaim activity. Which cgroups are
+        monitored and what action gets taken depends on what the unit has configured for
+        <varname>ManagedOOMMemoryPressure=</varname>. Takes a percentage value between 0% and 100%, inclusive.
+        Defaults to 60%.</para></listitem>
+      </varlistentry>
+
+    </variablelist>
+  </refsect1>
+
+  <refsect1>
+      <title>See Also</title>
+      <para>
+        <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
+        <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
+        <citerefentry><refentrytitle>systemd-oomd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
+        <citerefentry><refentrytitle>oomctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
+      </para>
+  </refsect1>
+
+</refentry>
index 00cd57420e806afe29dccb2b0715508d193f6667..806561a4125ee066203adb67aa5f4a2585816af5 100644 (file)
@@ -45,6 +45,8 @@ manpages = [
  ['nss-mymachines', '8', ['libnss_mymachines.so.2'], 'ENABLE_NSS_MYMACHINES'],
  ['nss-resolve', '8', ['libnss_resolve.so.2'], 'ENABLE_NSS_RESOLVE'],
  ['nss-systemd', '8', ['libnss_systemd.so.2'], 'ENABLE_NSS_SYSTEMD'],
+ ['oomctl', '1', [], 'ENABLE_OOMD'],
+ ['oomd.conf', '5', ['oomd.conf.d'], 'ENABLE_OOMD'],
  ['org.freedesktop.LogControl1', '5', [], ''],
  ['org.freedesktop.home1', '5', [], 'ENABLE_HOMED'],
  ['org.freedesktop.hostname1', '5', [], 'ENABLE_HOSTNAMED'],
@@ -907,6 +909,7 @@ manpages = [
  ['systemd-networkd.service', '8', ['systemd-networkd'], 'ENABLE_NETWORKD'],
  ['systemd-notify', '1', [], ''],
  ['systemd-nspawn', '1', [], ''],
+ ['systemd-oomd.service', '8', ['systemd-oomd'], 'ENABLE_OOMD'],
  ['systemd-path', '1', [], ''],
  ['systemd-portabled.service', '8', ['systemd-portabled'], 'ENABLE_PORTABLED'],
  ['systemd-pstore.service', '8', ['systemd-pstore'], 'ENABLE_PSTORE'],
diff --git a/man/systemd-oomd.service.xml b/man/systemd-oomd.service.xml
new file mode 100644 (file)
index 0000000..9d72373
--- /dev/null
@@ -0,0 +1,98 @@
+<?xml version='1.0'?>
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+  "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
+<!-- SPDX-License-Identifier: LGPL-2.1+ -->
+
+<refentry id="systemd-oomd.service" conditional='ENABLE_OOMD'>
+
+  <refentryinfo>
+    <title>systemd-oomd.service</title>
+    <productname>systemd</productname>
+  </refentryinfo>
+
+  <refmeta>
+    <refentrytitle>systemd-oomd.service</refentrytitle>
+    <manvolnum>8</manvolnum>
+  </refmeta>
+
+  <refnamediv>
+    <refname>systemd-oomd.service</refname>
+    <refname>systemd-oomd</refname>
+    <refpurpose>A userspace out-of-memory (OOM) killer</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <para><filename>systemd-oomd.service</filename></para>
+    <para><filename>/usr/lib/systemd/systemd-oomd</filename></para>
+  </refsynopsisdiv>
+
+  <refsect1>
+    <title>Description</title>
+
+    <para><command>systemd-oomd</command> is a system service that uses cgroups-v2 and pressure stall information (PSI)
+    to monitor and take action on processes before an OOM occurs in kernel space.</para>
+
+    <para>You can enable monitoring and actions on units by setting <varname>ManagedOOMSwap=</varname> and/or
+    <varname>ManagedOOMMemoryPressure=</varname> to the appropriate value. <command>systemd-oomd</command> will
+    periodically poll enabled units' cgroup data to detect when corrective action needs to occur. When an action needs
+    to happen, it will only be performed on the descendant cgroups of the enabled units. More precisely, only cgroups with
+    <filename>memory.oom.group</filename> set to <constant>1</constant> and leaf cgroup nodes are eligible candidates.
+    Action will be taken recursively on all of the processes under the chosen candidate.</para>
+
+    <para>See
+    <citerefentry><refentrytitle>oomd.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
+    for more information about the configuration of this service.</para>
+  </refsect1>
+
+  <refsect1>
+    <title>Setup Information</title>
+
+    <para>The system must be running systemd with a full unified cgroup hierarchy for the expected cgroups-v2 features.
+    Furthermore, resource accounting must be turned on for all units monitored by <command>systemd-oomd</command>.
+    The easiest way to turn on resource accounting is by ensuring the values for <varname>DefaultCPUAccounting</varname>,
+    <varname>DefaultIOAccounting</varname>, <varname>DefaultMemoryAccounting</varname>, and
+    <varname>DefaultTasksAccounting</varname> are set to <constant>true</constant> in
+    <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
+
+    <para>You will need a kernel compiled with PSI support. This is available in Linux 4.20 and above.</para>
+
+    <para>The system must also have swap enabled for <command>systemd-oomd</command> to function correctly. With swap
+    enabled, the system spends enough time swapping pages to let <command>systemd-oomd</command> react.
+    Without swap, the system enters a livelocked state much more quickly and may prevent <command>systemd-oomd</command>
+    from responding in a reasonable amount of time. See
+    <ulink url="https://chrisdown.name/2018/01/02/in-defence-of-swap.html">"In defence of swap: common misconceptions"</ulink>
+    for more details on swap.</para>
+
+    <para>Be aware that if you intend to enable monitoring and actions on <filename>user.slice</filename>,
+    <filename>user-$UID.slice</filename>, or their ancestor cgroups, it is highly recommended that your programs be
+    managed by the systemd user manager to prevent running too many processes under the same session scope (and thus
+    avoid a situation where memory intensive tasks trigger <command>systemd-oomd</command> to kill everything under the
+    cgroup). If you're using a desktop environment like GNOME, it already spawns many session components with the
+    systemd user manager.</para>
+  </refsect1>
+
+  <refsect1>
+    <title>Usage Recommendations</title>
+
+    <para><varname>ManagedOOMSwap=</varname> works with the system-wide swap values, so setting it on the root slice
+    <filename>-.slice</filename>, and allowing all descendant cgroups to be eligible candidates may make the most
+    sense.</para>
+
+    <para><varname>ManagedOOMMemoryPressure=</varname> tends to work better on the cgroups below the root slice
+    <filename>-.slice</filename>. For units which tend to have processes that are less latency sensitive (e.g.
+    <filename>system.slice</filename>), a higher limit like the default of 60% may be acceptable, as those processes
+    can usually ride out slowdowns caused by lack of memory without serious consequences. However, something like
+    <filename>user@$UID.service</filename> may prefer a much lower value like 40%.</para>
+  </refsect1>
+
+  <refsect1>
+    <title>See Also</title>
+    <para>
+      <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
+      <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
+      <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
+      <citerefentry><refentrytitle>oomd.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
+      <citerefentry><refentrytitle>oomctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
+    </para>
+  </refsect1>
+</refentry>
index d72f9048e7c00ab3d8f72d07c4ae7132d433ca74..b40fa86145451a23a85a968edd54d7f9b7e733f1 100644 (file)
@@ -869,6 +869,49 @@ DeviceAllow=/dev/loop-control
           <xi:include href="supported-controllers.xml"  xpointer="controllers-text" />
         </listitem>
       </varlistentry>
+
+      <varlistentry>
+        <term><varname>ManagedOOMSwap=auto|kill</varname></term>
+        <term><varname>ManagedOOMMemoryPressure=auto|kill</varname></term>
+
+        <listitem>
+          <para>Specifies how
+          <citerefentry><refentrytitle>systemd-oomd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
+          will act on this unit's cgroups. Defaults to <option>auto</option>.</para>
+
+          <para>When set to <option>kill</option>, <command>systemd-oomd</command> will actively monitor this unit's
+          cgroup metrics to decide whether it needs to act. If the cgroup passes the limits set by
+          <citerefentry><refentrytitle>oomd.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry> or its
+          overrides, <command>systemd-oomd</command> will send a <constant>SIGKILL</constant> to all of the processes
+          under the chosen candidate cgroup. Note that only descendant cgroups can be eligible candidates for killing;
+          the unit that set its property to <option>kill</option> is not a candidate (unless one of its ancestors set
+          their property to <option>kill</option>). You can find more details on candidates and kill behavior at
+          <citerefentry><refentrytitle>systemd-oomd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
+          and <citerefentry><refentrytitle>oomd.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>. Setting
+          either of these properties to <option>kill</option> will also automatically acquire
+          <varname>After=</varname> and <varname>Wants=</varname> dependencies on
+          <filename>systemd-oomd.service</filename> unless <varname>DefaultDependencies=no</varname>.
+        </para>
+
+          <para>When set to <option>auto</option>, <command>systemd-oomd</command> will not actively use this cgroup's
+          data for monitoring and detection. However, if an ancestor cgroup has one of these properties set to
+          <option>kill</option>, a unit with <option>auto</option> can still be an eligible candidate for
+          <command>systemd-oomd</command> to act on.</para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term><varname>ManagedOOMMemoryPressureLimitPercent=</varname></term>
+
+        <listitem>
+          <para>Overrides the default memory pressure limit set by
+          <citerefentry><refentrytitle>oomd.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry> for this unit
+          (cgroup). Takes a percentage value between 0% and 100%, inclusive. This property is ignored unless
+          <varname>ManagedOOMMemoryPressure=</varname><option>kill</option>. Defaults to 0%, which means use the
+          default set by <citerefentry><refentrytitle>oomd.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
+          </para>
+        </listitem>
+      </varlistentry>
     </variablelist>
   </refsect1>
 
@@ -1030,6 +1073,7 @@ DeviceAllow=/dev/loop-control
       <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
       <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
       <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
+      <citerefentry><refentrytitle>systemd-oomd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
       The documentation for control groups and specific controllers in the Linux kernel:
       <ulink url="https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html">Control Groups v2</ulink>.
     </para>