core: introduce support for cgroup freezer

With cgroup v2 the cgroup freezer is implemented as a cgroup
attribute called cgroup.freeze. cgroup can be frozen by writing "1"
to the file and kernel will send us a notification through
"cgroup.events" after the operation is finished and processes in the
cgroup entered quiescent state, i.e. they are not scheduled to
run. Writing "0" to the attribute file does the inverse and process
execution is resumed.

This commit exposes above low-level functionality through systemd's DBus
API. Each unit type must provide specialized implementation for these
methods, otherwise, we return an error. So far only service, scope, and
slice unit types provide the support. It is possible to check if a
given unit has the support using CanFreeze() DBus property.

Note that DBus API has a synchronous behavior and we dispatch the reply
to freeze/thaw requests only after the kernel has notified us that
requested operation was completed.
This commit is contained in:
Michal Sekletár
2020-04-30 19:02:51 +02:00
parent 25a1f04c68
commit d9e45bc3ab
19 changed files with 566 additions and 14 deletions
+24
View File
@@ -303,6 +303,30 @@ Sun 2017-02-26 20:57:49 EST 2h 3min left Sun 2017-02-26 11:56:36 EST 6h ago
generally redundant and reproducible on the next invocation of the unit).</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>freeze <replaceable>PATTERN</replaceable>…</command></term>
<listitem>
<para>Freeze one or more units specified on the
command line using cgroup freezer</para>
<para>Freezing the unit will cause all processes contained within the cgroup corresponding to the unit
to be suspended. Being suspended means that unit's processes won't be scheduled to run on CPU until thawed.
Note that this command is supported only on systems that use unified cgroup hierarchy. Unit is automatically
thawed just before we execute a job against the unit, e.g. before the unit is stopped.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>thaw <replaceable>PATTERN</replaceable>…</command></term>
<listitem>
<para>Thaw (unfreeze) one or more units specified on the
command line.</para>
<para>This is the inverse operation to the <command>freeze</command> command and resumes the execution of
processes in the unit's cgroup.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>is-active <replaceable>PATTERN</replaceable>…</command></term>