]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/systemd.resource-control.xml
mkosi: Fix particle profile
[thirdparty/systemd.git] / man / systemd.resource-control.xml
1 <?xml version='1.0'?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1+ -->
5
6 <refentry id="systemd.resource-control">
7 <refentryinfo>
8 <title>systemd.resource-control</title>
9 <productname>systemd</productname>
10 </refentryinfo>
11
12 <refmeta>
13 <refentrytitle>systemd.resource-control</refentrytitle>
14 <manvolnum>5</manvolnum>
15 </refmeta>
16
17 <refnamediv>
18 <refname>systemd.resource-control</refname>
19 <refpurpose>Resource control unit settings</refpurpose>
20 </refnamediv>
21
22 <refsynopsisdiv>
23 <para>
24 <filename><replaceable>slice</replaceable>.slice</filename>,
25 <filename><replaceable>scope</replaceable>.scope</filename>,
26 <filename><replaceable>service</replaceable>.service</filename>,
27 <filename><replaceable>socket</replaceable>.socket</filename>,
28 <filename><replaceable>mount</replaceable>.mount</filename>,
29 <filename><replaceable>swap</replaceable>.swap</filename>
30 </para>
31 </refsynopsisdiv>
32
33 <refsect1>
34 <title>Description</title>
35
36 <para>Unit configuration files for services, slices, scopes, sockets, mount points, and swap devices share a subset
37 of configuration options for resource control of spawned processes. Internally, this relies on the Linux Control
38 Groups (cgroups) kernel concept for organizing processes in a hierarchical tree of named groups for the purpose of
39 resource management.</para>
40
41 <para>This man page lists the configuration options shared by
42 those six unit types. See
43 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
44 for the common options of all unit configuration files, and
45 <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
46 <citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
47 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
48 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
49 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
50 and
51 <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>
52 for more information on the specific unit configuration files. The
53 resource control configuration options are configured in the
54 [Slice], [Scope], [Service], [Socket], [Mount], or [Swap]
55 sections, depending on the unit type.</para>
56
57 <para>In addition, options which control resources available to programs
58 <emphasis>executed</emphasis> by systemd are listed in
59 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
60 Those options complement options listed here.</para>
61
62 <para>See the <ulink
63 url="https://www.freedesktop.org/wiki/Software/systemd/ControlGroupInterface/">New
64 Control Group Interfaces</ulink> for an introduction on how to make
65 use of resource control APIs from programs.</para>
66 </refsect1>
67
68 <refsect1>
69 <title>Implicit Dependencies</title>
70
71 <para>The following dependencies are implicitly added:</para>
72
73 <itemizedlist>
74 <listitem><para>Units with the <varname>Slice=</varname> setting set automatically acquire
75 <varname>Requires=</varname> and <varname>After=</varname> dependencies on the specified
76 slice unit.</para></listitem>
77 </itemizedlist>
78 </refsect1>
79
80 <!-- We don't have any default dependency here. -->
81
82 <refsect1>
83 <title>Unified and Legacy Control Group Hierarchies</title>
84
85 <para>The unified control group hierarchy is the new version of kernel control group interface, see <ulink
86 url="https://www.kernel.org/doc/Documentation/cgroup-v2.txt">cgroup-v2.txt</ulink>. Depending on the resource type,
87 there are differences in resource control capabilities. Also, because of interface changes, some resource types
88 have separate set of options on the unified hierarchy.</para>
89
90 <para>
91 <variablelist>
92
93 <varlistentry>
94 <term><option>CPU</option></term>
95 <listitem>
96 <para><varname>CPUWeight=</varname> and <varname>StartupCPUWeight=</varname> replace
97 <varname>CPUShares=</varname> and <varname>StartupCPUShares=</varname>, respectively.</para>
98
99 <para>The <literal>cpuacct</literal> controller does not exist separately on the unified hierarchy.</para>
100 </listitem>
101 </varlistentry>
102
103 <varlistentry>
104 <term><option>Memory</option></term>
105 <listitem>
106 <para><varname>MemoryMax=</varname> replaces <varname>MemoryLimit=</varname>. <varname>MemoryLow=</varname>
107 and <varname>MemoryHigh=</varname> are effective only on unified hierarchy.</para>
108 </listitem>
109 </varlistentry>
110
111 <varlistentry>
112 <term><option>IO</option></term>
113 <listitem>
114 <para><varname>IO</varname> prefixed settings are a superset of and replace <varname>BlockIO</varname>
115 prefixed ones. On unified hierarchy, IO resource control also applies to buffered writes.</para>
116 </listitem>
117 </varlistentry>
118
119 </variablelist>
120 </para>
121
122 <para>To ease the transition, there is best-effort translation between the two versions of settings. For each
123 controller, if any of the settings for the unified hierarchy are present, all settings for the legacy hierarchy are
124 ignored. If the resulting settings are for the other type of hierarchy, the configurations are translated before
125 application.</para>
126
127 <para>Legacy control group hierarchy (see <ulink
128 url="https://www.kernel.org/doc/Documentation/cgroup-v1/cgroups.txt">cgroups.txt</ulink>), also called cgroup-v1,
129 doesn't allow safe delegation of controllers to unprivileged processes. If the system uses the legacy control group
130 hierarchy, resource control is disabled for systemd user instance, see
131 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
132 </para>
133 </refsect1>
134
135 <refsect1>
136 <title>Options</title>
137
138 <para>Units of the types listed above can have settings
139 for resource control configuration:</para>
140
141 <variablelist class='unit-directives'>
142
143 <varlistentry>
144 <term><varname>CPUAccounting=</varname></term>
145
146 <listitem>
147 <para>Turn on CPU usage accounting for this unit. Takes a
148 boolean argument. Note that turning on CPU accounting for
149 one unit will also implicitly turn it on for all units
150 contained in the same slice and for all its parent slices
151 and the units contained therein. The system default for this
152 setting may be controlled with
153 <varname>DefaultCPUAccounting=</varname> in
154 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
155 </listitem>
156 </varlistentry>
157
158 <varlistentry>
159 <term><varname>CPUWeight=<replaceable>weight</replaceable></varname></term>
160 <term><varname>StartupCPUWeight=<replaceable>weight</replaceable></varname></term>
161
162 <listitem>
163 <para>Assign the specified CPU time weight to the processes executed, if the unified control group hierarchy
164 is used on the system. These options take an integer value and control the <literal>cpu.weight</literal>
165 control group attribute. The allowed range is 1 to 10000. Defaults to 100. For details about this control
166 group attribute, see <ulink
167 url="https://www.kernel.org/doc/Documentation/cgroup-v2.txt">cgroup-v2.txt</ulink> and <ulink
168 url="https://www.kernel.org/doc/Documentation/scheduler/sched-design-CFS.txt">sched-design-CFS.txt</ulink>.
169 The available CPU time is split up among all units within one slice relative to their CPU time weight.</para>
170
171 <para>While <varname>StartupCPUWeight=</varname> only applies to the startup phase of the system,
172 <varname>CPUWeight=</varname> applies to normal runtime of the system, and if the former is not set also to
173 the startup phase. Using <varname>StartupCPUWeight=</varname> allows prioritizing specific services at
174 boot-up differently than during normal runtime.</para>
175
176 <para>These settings replace <varname>CPUShares=</varname> and <varname>StartupCPUShares=</varname>.</para>
177 </listitem>
178 </varlistentry>
179
180 <varlistentry>
181 <term><varname>CPUQuota=</varname></term>
182
183 <listitem>
184 <para>Assign the specified CPU time quota to the processes executed. Takes a percentage value, suffixed with
185 "%". The percentage specifies how much CPU time the unit shall get at maximum, relative to the total CPU time
186 available on one CPU. Use values &gt; 100% for allotting CPU time on more than one CPU. This controls the
187 <literal>cpu.max</literal> attribute on the unified control group hierarchy and
188 <literal>cpu.cfs_quota_us</literal> on legacy. For details about these control group attributes, see <ulink
189 url="https://www.kernel.org/doc/Documentation/cgroup-v2.txt">cgroup-v2.txt</ulink> and <ulink
190 url="https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt">sched-bwc.txt</ulink>.</para>
191
192 <para>Example: <varname>CPUQuota=20%</varname> ensures that the executed processes will never get more than
193 20% CPU time on one CPU.</para>
194
195 </listitem>
196 </varlistentry>
197
198 <varlistentry>
199 <term><varname>CPUQuotaPeriodSec=</varname></term>
200
201 <listitem>
202 <para>Assign the duration over which the CPU time quota specified by <varname>CPUQuota=</varname> is measured.
203 Takes a time duration value in seconds, with an optional suffix such as "ms" for milliseconds (or "s" for seconds.)
204 The default setting is 100ms. The period is clamped to the range supported by the kernel, which is [1ms, 1000ms].
205 Additionally, the period is adjusted up so that the quota interval is also at least 1ms.
206 Setting <varname>CPUQuotaPeriodSec=</varname> to an empty value resets it to the default.</para>
207
208 <para>This controls the second field of <literal>cpu.max</literal> attribute on the unified control group hierarchy
209 and <literal>cpu.cfs_period_us</literal> on legacy. For details about these control group attributes, see
210 <ulink url="https://www.kernel.org/doc/Documentation/cgroup-v2.txt">cgroup-v2.txt</ulink> and
211 <ulink url="https://www.kernel.org/doc/Documentation/scheduler/sched-design-CFS.txt">sched-design-CFS.txt</ulink>.</para>
212
213 <para>Example: <varname>CPUQuotaPeriodSec=10ms</varname> to request that the CPU quota is measured in periods of 10ms.</para>
214 </listitem>
215 </varlistentry>
216
217 <varlistentry>
218 <term><varname>MemoryAccounting=</varname></term>
219
220 <listitem>
221 <para>Turn on process and kernel memory accounting for this
222 unit. Takes a boolean argument. Note that turning on memory
223 accounting for one unit will also implicitly turn it on for
224 all units contained in the same slice and for all its parent
225 slices and the units contained therein. The system default
226 for this setting may be controlled with
227 <varname>DefaultMemoryAccounting=</varname> in
228 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
229 </listitem>
230 </varlistentry>
231
232 <varlistentry>
233 <term><varname>MemoryMin=<replaceable>bytes</replaceable></varname></term>
234
235 <listitem>
236 <para>Specify the memory usage protection of the executed processes in this unit. If the memory usages of
237 this unit and all its ancestors are below their minimum boundaries, this unit's memory won't be reclaimed.</para>
238
239 <para>Takes a memory size in bytes. If the value is suffixed with K, M, G or T, the specified memory size is
240 parsed as Kilobytes, Megabytes, Gigabytes, or Terabytes (with the base 1024), respectively. Alternatively, a
241 percentage value may be specified, which is taken relative to the installed physical memory on the
242 system. This controls the <literal>memory.min</literal> control group attribute. For details about this
243 control group attribute, see <ulink
244 url="https://www.kernel.org/doc/Documentation/cgroup-v2.txt">cgroup-v2.txt</ulink>.</para>
245
246 <para>This setting is supported only if the unified control group hierarchy is used and disables
247 <varname>MemoryLimit=</varname>.</para>
248 </listitem>
249 </varlistentry>
250
251 <varlistentry>
252 <term><varname>MemoryLow=<replaceable>bytes</replaceable></varname></term>
253
254 <listitem>
255 <para>Specify the best-effort memory usage protection of the executed processes in this unit. If the memory
256 usages of this unit and all its ancestors are below their low boundaries, this unit's memory won't be
257 reclaimed as long as memory can be reclaimed from unprotected units.</para>
258
259 <para>Takes a memory size in bytes. If the value is suffixed with K, M, G or T, the specified memory size is
260 parsed as Kilobytes, Megabytes, Gigabytes, or Terabytes (with the base 1024), respectively. Alternatively, a
261 percentage value may be specified, which is taken relative to the installed physical memory on the
262 system. This controls the <literal>memory.low</literal> control group attribute. For details about this
263 control group attribute, see <ulink
264 url="https://www.kernel.org/doc/Documentation/cgroup-v2.txt">cgroup-v2.txt</ulink>.</para>
265
266 <para>This setting is supported only if the unified control group hierarchy is used and disables
267 <varname>MemoryLimit=</varname>.</para>
268
269 <para>Units may can have their children use a default <literal>memory.low</literal> value by specifying
270 <varname>DefaultMemoryLow=</varname>, which has the same usage as <varname>MemoryLow=</varname>. This setting
271 does not affect <literal>memory.low</literal> in the unit itself.</para>
272 </listitem>
273 </varlistentry>
274
275 <varlistentry>
276 <term><varname>MemoryHigh=<replaceable>bytes</replaceable></varname></term>
277
278 <listitem>
279 <para>Specify the high limit on memory usage of the executed processes in this unit. Memory usage may go
280 above the limit if unavoidable, but the processes are heavily slowed down and memory is taken away
281 aggressively in such cases. This is the main mechanism to control memory usage of a unit.</para>
282
283 <para>Takes a memory size in bytes. If the value is suffixed with K, M, G or T, the specified memory size is
284 parsed as Kilobytes, Megabytes, Gigabytes, or Terabytes (with the base 1024), respectively. Alternatively, a
285 percentage value may be specified, which is taken relative to the installed physical memory on the
286 system. If assigned the
287 special value <literal>infinity</literal>, no memory limit is applied. This controls the
288 <literal>memory.high</literal> control group attribute. For details about this control group attribute, see
289 <ulink url="https://www.kernel.org/doc/Documentation/cgroup-v2.txt">cgroup-v2.txt</ulink>.</para>
290
291 <para>This setting is supported only if the unified control group hierarchy is used and disables
292 <varname>MemoryLimit=</varname>.</para>
293 </listitem>
294 </varlistentry>
295
296 <varlistentry>
297 <term><varname>MemoryMax=<replaceable>bytes</replaceable></varname></term>
298
299 <listitem>
300 <para>Specify the absolute limit on memory usage of the executed processes in this unit. If memory usage
301 cannot be contained under the limit, out-of-memory killer is invoked inside the unit. It is recommended to
302 use <varname>MemoryHigh=</varname> as the main control mechanism and use <varname>MemoryMax=</varname> as the
303 last line of defense.</para>
304
305 <para>Takes a memory size in bytes. If the value is suffixed with K, M, G or T, the specified memory size is
306 parsed as Kilobytes, Megabytes, Gigabytes, or Terabytes (with the base 1024), respectively. Alternatively, a
307 percentage value may be specified, which is taken relative to the installed physical memory on the system. If
308 assigned the special value <literal>infinity</literal>, no memory limit is applied. This controls the
309 <literal>memory.max</literal> control group attribute. For details about this control group attribute, see
310 <ulink url="https://www.kernel.org/doc/Documentation/cgroup-v2.txt">cgroup-v2.txt</ulink>.</para>
311
312 <para>This setting replaces <varname>MemoryLimit=</varname>.</para>
313 </listitem>
314 </varlistentry>
315
316 <varlistentry>
317 <term><varname>MemorySwapMax=<replaceable>bytes</replaceable></varname></term>
318
319 <listitem>
320 <para>Specify the absolute limit on swap usage of the executed processes in this unit.</para>
321
322 <para>Takes a swap size in bytes. If the value is suffixed with K, M, G or T, the specified swap size is
323 parsed as Kilobytes, Megabytes, Gigabytes, or Terabytes (with the base 1024), respectively. If assigned the
324 special value <literal>infinity</literal>, no swap limit is applied. This controls the
325 <literal>memory.swap.max</literal> control group attribute. For details about this control group attribute,
326 see <ulink url="https://www.kernel.org/doc/Documentation/cgroup-v2.txt">cgroup-v2.txt</ulink>.</para>
327
328 <para>This setting is supported only if the unified control group hierarchy is used and disables
329 <varname>MemoryLimit=</varname>.</para>
330 </listitem>
331 </varlistentry>
332
333 <varlistentry>
334 <term><varname>TasksAccounting=</varname></term>
335
336 <listitem>
337 <para>Turn on task accounting for this unit. Takes a
338 boolean argument. If enabled, the system manager will keep
339 track of the number of tasks in the unit. The number of
340 tasks accounted this way includes both kernel threads and
341 userspace processes, with each thread counting
342 individually. Note that turning on tasks accounting for one
343 unit will also implicitly turn it on for all units contained
344 in the same slice and for all its parent slices and the
345 units contained therein. The system default for this setting
346 may be controlled with
347 <varname>DefaultTasksAccounting=</varname> in
348 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
349 </listitem>
350 </varlistentry>
351
352 <varlistentry>
353 <term><varname>TasksMax=<replaceable>N</replaceable></varname></term>
354
355 <listitem>
356 <para>Specify the maximum number of tasks that may be created in the unit. This ensures that the number of
357 tasks accounted for the unit (see above) stays below a specific limit. This either takes an absolute number
358 of tasks or a percentage value that is taken relative to the configured maximum number of tasks on the
359 system. If assigned the special value <literal>infinity</literal>, no tasks limit is applied. This controls
360 the <literal>pids.max</literal> control group attribute. For details about this control group attribute, see
361 <ulink url="https://www.kernel.org/doc/Documentation/cgroup-v1/pids.txt">pids.txt</ulink>.</para>
362
363 <para>The
364 system default for this setting may be controlled with
365 <varname>DefaultTasksMax=</varname> in
366 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
367 </listitem>
368 </varlistentry>
369
370 <varlistentry>
371 <term><varname>IOAccounting=</varname></term>
372
373 <listitem>
374 <para>Turn on Block I/O accounting for this unit, if the unified control group hierarchy is used on the
375 system. Takes a boolean argument. Note that turning on block I/O accounting for one unit will also implicitly
376 turn it on for all units contained in the same slice and all for its parent slices and the units contained
377 therein. The system default for this setting may be controlled with <varname>DefaultIOAccounting=</varname>
378 in
379 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
380
381 <para>This setting replaces <varname>BlockIOAccounting=</varname> and disables settings prefixed with
382 <varname>BlockIO</varname> or <varname>StartupBlockIO</varname>.</para>
383 </listitem>
384 </varlistentry>
385
386 <varlistentry>
387 <term><varname>IOWeight=<replaceable>weight</replaceable></varname></term>
388 <term><varname>StartupIOWeight=<replaceable>weight</replaceable></varname></term>
389
390 <listitem>
391 <para>Set the default overall block I/O weight for the executed processes, if the unified control group
392 hierarchy is used on the system. Takes a single weight value (between 1 and 10000) to set the default block
393 I/O weight. This controls the <literal>io.weight</literal> control group attribute, which defaults to
394 100. For details about this control group attribute, see <ulink
395 url="https://www.kernel.org/doc/Documentation/cgroup-v2.txt">cgroup-v2.txt</ulink>. The available I/O
396 bandwidth is split up among all units within one slice relative to their block I/O weight.</para>
397
398 <para>While <varname>StartupIOWeight=</varname> only applies
399 to the startup phase of the system,
400 <varname>IOWeight=</varname> applies to the later runtime of
401 the system, and if the former is not set also to the startup
402 phase. This allows prioritizing specific services at boot-up
403 differently than during runtime.</para>
404
405 <para>These settings replace <varname>BlockIOWeight=</varname> and <varname>StartupBlockIOWeight=</varname>
406 and disable settings prefixed with <varname>BlockIO</varname> or <varname>StartupBlockIO</varname>.</para>
407 </listitem>
408 </varlistentry>
409
410 <varlistentry>
411 <term><varname>IODeviceWeight=<replaceable>device</replaceable> <replaceable>weight</replaceable></varname></term>
412
413 <listitem>
414 <para>Set the per-device overall block I/O weight for the executed processes, if the unified control group
415 hierarchy is used on the system. Takes a space-separated pair of a file path and a weight value to specify
416 the device specific weight value, between 1 and 10000. (Example: <literal>/dev/sda 1000</literal>). The file
417 path may be specified as path to a block device node or as any other file, in which case the backing block
418 device of the file system of the file is determined. This controls the <literal>io.weight</literal> control
419 group attribute, which defaults to 100. Use this option multiple times to set weights for multiple devices.
420 For details about this control group attribute, see <ulink
421 url="https://www.kernel.org/doc/Documentation/cgroup-v2.txt">cgroup-v2.txt</ulink>.</para>
422
423 <para>This setting replaces <varname>BlockIODeviceWeight=</varname> and disables settings prefixed with
424 <varname>BlockIO</varname> or <varname>StartupBlockIO</varname>.</para>
425 </listitem>
426 </varlistentry>
427
428 <varlistentry>
429 <term><varname>IOReadBandwidthMax=<replaceable>device</replaceable> <replaceable>bytes</replaceable></varname></term>
430 <term><varname>IOWriteBandwidthMax=<replaceable>device</replaceable> <replaceable>bytes</replaceable></varname></term>
431
432 <listitem>
433 <para>Set the per-device overall block I/O bandwidth maximum limit for the executed processes, if the unified
434 control group hierarchy is used on the system. This limit is not work-conserving and the executed processes
435 are not allowed to use more even if the device has idle capacity. Takes a space-separated pair of a file
436 path and a bandwidth value (in bytes per second) to specify the device specific bandwidth. The file path may
437 be a path to a block device node, or as any other file in which case the backing block device of the file
438 system of the file is used. If the bandwidth is suffixed with K, M, G, or T, the specified bandwidth is
439 parsed as Kilobytes, Megabytes, Gigabytes, or Terabytes, respectively, to the base of 1000. (Example:
440 "/dev/disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0 5M"). This controls the <literal>io.max</literal> control
441 group attributes. Use this option multiple times to set bandwidth limits for multiple devices. For details
442 about this control group attribute, see <ulink
443 url="https://www.kernel.org/doc/Documentation/cgroup-v2.txt">cgroup-v2.txt</ulink>.
444 </para>
445
446 <para>These settings replace <varname>BlockIOReadBandwidth=</varname> and
447 <varname>BlockIOWriteBandwidth=</varname> and disable settings prefixed with <varname>BlockIO</varname> or
448 <varname>StartupBlockIO</varname>.</para>
449 </listitem>
450 </varlistentry>
451
452 <varlistentry>
453 <term><varname>IOReadIOPSMax=<replaceable>device</replaceable> <replaceable>IOPS</replaceable></varname></term>
454 <term><varname>IOWriteIOPSMax=<replaceable>device</replaceable> <replaceable>IOPS</replaceable></varname></term>
455
456 <listitem>
457 <para>Set the per-device overall block I/O IOs-Per-Second maximum limit for the executed processes, if the
458 unified control group hierarchy is used on the system. This limit is not work-conserving and the executed
459 processes are not allowed to use more even if the device has idle capacity. Takes a space-separated pair of
460 a file path and an IOPS value to specify the device specific IOPS. The file path may be a path to a block
461 device node, or as any other file in which case the backing block device of the file system of the file is
462 used. If the IOPS is suffixed with K, M, G, or T, the specified IOPS is parsed as KiloIOPS, MegaIOPS,
463 GigaIOPS, or TeraIOPS, respectively, to the base of 1000. (Example:
464 "/dev/disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0 1K"). This controls the <literal>io.max</literal> control
465 group attributes. Use this option multiple times to set IOPS limits for multiple devices. For details about
466 this control group attribute, see <ulink
467 url="https://www.kernel.org/doc/Documentation/cgroup-v2.txt">cgroup-v2.txt</ulink>.
468 </para>
469
470 <para>These settings are supported only if the unified control group hierarchy is used and disable settings
471 prefixed with <varname>BlockIO</varname> or <varname>StartupBlockIO</varname>.</para>
472 </listitem>
473 </varlistentry>
474
475 <varlistentry>
476 <term><varname>IODeviceLatencyTargetSec=<replaceable>device</replaceable> <replaceable>target</replaceable></varname></term>
477
478 <listitem>
479 <para>Set the per-device average target I/O latency for the executed processes, if the unified control group
480 hierarchy is used on the system. Takes a file path and a timespan separated by a space to specify
481 the device specific latency target. (Example: "/dev/sda 25ms"). The file path may be specified
482 as path to a block device node or as any other file, in which case the backing block device of the file
483 system of the file is determined. This controls the <literal>io.latency</literal> control group
484 attribute. Use this option multiple times to set latency target for multiple devices. For details about this
485 control group attribute, see <ulink
486 url="https://www.kernel.org/doc/Documentation/cgroup-v2.txt">cgroup-v2.txt</ulink>.</para>
487
488 <para>Implies <literal>IOAccounting=yes</literal>.</para>
489
490 <para>These settings are supported only if the unified control group hierarchy is used.</para>
491 </listitem>
492 </varlistentry>
493
494 <varlistentry>
495 <term><varname>IPAccounting=</varname></term>
496
497 <listitem>
498 <para>Takes a boolean argument. If true, turns on IPv4 and IPv6 network traffic accounting for packets sent
499 or received by the unit. When this option is turned on, all IPv4 and IPv6 sockets created by any process of
500 the unit are accounted for.</para>
501
502 <para>When this option is used in socket units, it applies to all IPv4 and IPv6 sockets
503 associated with it (including both listening and connection sockets where this applies). Note that for
504 socket-activated services, this configuration setting and the accounting data of the service unit and the
505 socket unit are kept separate, and displayed separately. No propagation of the setting and the collected
506 statistics is done, in either direction. Moreover, any traffic sent or received on any of the socket unit's
507 sockets is accounted to the socket unit — and never to the service unit it might have activated, even if the
508 socket is used by it.</para>
509
510 <para>The system default for this setting may be controlled with <varname>DefaultIPAccounting=</varname> in
511 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
512 </listitem>
513 </varlistentry>
514
515 <varlistentry>
516 <term><varname>IPAddressAllow=<replaceable>ADDRESS[/PREFIXLENGTH]…</replaceable></varname></term>
517 <term><varname>IPAddressDeny=<replaceable>ADDRESS[/PREFIXLENGTH]…</replaceable></varname></term>
518
519 <listitem>
520 <para>Turn on address range network traffic filtering for IP packets sent and received over
521 <constant>AF_INET</constant> and <constant>AF_INET6</constant> sockets. Both directives take a
522 space separated list of IPv4 or IPv6 addresses, each optionally suffixed with an address prefix
523 length in bits (separated by a <literal>/</literal> character). If the latter is omitted, the
524 address is considered a host address, i.e. the prefix covers the whole address (32 for IPv4, 128
525 for IPv6).</para>
526
527 <para>The access lists configured with this option are applied to all sockets created by processes
528 of this unit (or in the case of socket units, associated with it). The lists are implicitly
529 combined with any lists configured for any of the parent slice units this unit might be a member
530 of. By default all access lists are empty. Both ingress and egress traffic is filtered by these
531 settings. In case of ingress traffic the source IP address is checked against these access lists,
532 in case of egress traffic the destination IP address is checked. When configured the lists are
533 enforced as follows:</para>
534
535 <itemizedlist>
536 <listitem><para>Access will be granted in case an IP packet's destination/source address matches
537 any entry in the <varname>IPAddressAllow=</varname> setting.</para></listitem>
538
539 <listitem><para>Otherwise, access will be denied in case its destination/source address matches
540 any entry in the <varname>IPAddressDeny=</varname> setting.</para></listitem>
541
542 <listitem><para>Otherwise, access will be granted.</para></listitem>
543 </itemizedlist>
544
545 <para>In order to implement a whitelisting IP firewall, it is recommended to use a
546 <varname>IPAddressDeny=</varname><constant>any</constant> setting on an upper-level slice unit (such as the
547 root slice <filename>-.slice</filename> or the slice containing all system services
548 <filename>system.slice</filename> – see
549 <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
550 details on these slice units), plus individual per-service <varname>IPAddressAllow=</varname> lines
551 permitting network access to relevant services, and only them.</para>
552
553 <para>Note that for socket-activated services, the IP access list configured on the socket unit applies to
554 all sockets associated with it directly, but not to any sockets created by the ultimately activated services
555 for it. Conversely, the IP access list configured for the service is not applied to any sockets passed into
556 the service via socket activation. Thus, it is usually a good idea, to replicate the IP access lists on both
557 the socket and the service unit, however it often makes sense to maintain one list more open and the other
558 one more restricted, depending on the usecase.</para>
559
560 <para>If these settings are used multiple times in the same unit the specified lists are combined. If an
561 empty string is assigned to these settings the specific access list is reset and all previous settings undone.</para>
562
563 <para>In place of explicit IPv4 or IPv6 address and prefix length specifications a small set of symbolic
564 names may be used. The following names are defined:</para>
565
566 <table>
567 <title>Special address/network names</title>
568
569 <tgroup cols='3'>
570 <colspec colname='name'/>
571 <colspec colname='definition'/>
572 <colspec colname='meaning'/>
573
574 <thead>
575 <row>
576 <entry>Symbolic Name</entry>
577 <entry>Definition</entry>
578 <entry>Meaning</entry>
579 </row>
580 </thead>
581
582 <tbody>
583 <row>
584 <entry><constant>any</constant></entry>
585 <entry>0.0.0.0/0 ::/0</entry>
586 <entry>Any host</entry>
587 </row>
588
589 <row>
590 <entry><constant>localhost</constant></entry>
591 <entry>127.0.0.0/8 ::1/128</entry>
592 <entry>All addresses on the local loopback</entry>
593 </row>
594
595 <row>
596 <entry><constant>link-local</constant></entry>
597 <entry>169.254.0.0/16 fe80::/64</entry>
598 <entry>All link-local IP addresses</entry>
599 </row>
600
601 <row>
602 <entry><constant>multicast</constant></entry>
603 <entry>224.0.0.0/4 ff00::/8</entry>
604 <entry>All IP multicasting addresses</entry>
605 </row>
606 </tbody>
607 </tgroup>
608 </table>
609
610 <para>Note that these settings might not be supported on some systems (for example if eBPF control group
611 support is not enabled in the underlying kernel or container manager). These settings will have no effect in
612 that case. If compatibility with such systems is desired it is hence recommended to not exclusively rely on
613 them for IP security.</para>
614 </listitem>
615 </varlistentry>
616
617 <varlistentry>
618 <term><varname>DeviceAllow=</varname></term>
619
620 <listitem>
621 <para>Control access to specific device nodes by the
622 executed processes. Takes two space-separated strings: a
623 device node specifier followed by a combination of
624 <constant>r</constant>, <constant>w</constant>,
625 <constant>m</constant> to control
626 <emphasis>r</emphasis>eading, <emphasis>w</emphasis>riting,
627 or creation of the specific device node(s) by the unit
628 (<emphasis>m</emphasis>knod), respectively. This controls
629 the <literal>devices.allow</literal> and
630 <literal>devices.deny</literal> control group
631 attributes. For details about these control group
632 attributes, see <ulink
633 url="https://www.kernel.org/doc/Documentation/cgroup-v1/devices.txt">devices.txt</ulink>.</para>
634
635 <para>The device node specifier is either a path to a device
636 node in the file system, starting with
637 <filename>/dev/</filename>, or a string starting with either
638 <literal>char-</literal> or <literal>block-</literal>
639 followed by a device group name, as listed in
640 <filename>/proc/devices</filename>. The latter is useful to
641 whitelist all current and future devices belonging to a
642 specific device group at once. The device group is matched
643 according to filename globbing rules, you may hence use the
644 <literal>*</literal> and <literal>?</literal>
645 wildcards. Examples: <filename>/dev/sda5</filename> is a
646 path to a device node, referring to an ATA or SCSI block
647 device. <literal>char-pts</literal> and
648 <literal>char-alsa</literal> are specifiers for all pseudo
649 TTYs and all ALSA sound devices,
650 respectively. <literal>char-cpu/*</literal> is a specifier
651 matching all CPU related device groups.</para>
652 </listitem>
653 </varlistentry>
654
655 <varlistentry>
656 <term><varname>DevicePolicy=auto|closed|strict</varname></term>
657
658 <listitem>
659 <para>
660 Control the policy for allowing device access:
661 </para>
662 <variablelist>
663 <varlistentry>
664 <term><option>strict</option></term>
665 <listitem>
666 <para>means to only allow types of access that are
667 explicitly specified.</para>
668 </listitem>
669 </varlistentry>
670
671 <varlistentry>
672 <term><option>closed</option></term>
673 <listitem>
674 <para>in addition, allows access to standard pseudo
675 devices including
676 <filename>/dev/null</filename>,
677 <filename>/dev/zero</filename>,
678 <filename>/dev/full</filename>,
679 <filename>/dev/random</filename>, and
680 <filename>/dev/urandom</filename>.
681 </para>
682 </listitem>
683 </varlistentry>
684
685 <varlistentry>
686 <term><option>auto</option></term>
687 <listitem>
688 <para>
689 in addition, allows access to all devices if no
690 explicit <varname>DeviceAllow=</varname> is present.
691 This is the default.
692 </para>
693 </listitem>
694 </varlistentry>
695 </variablelist>
696 </listitem>
697 </varlistentry>
698
699 <varlistentry>
700 <term><varname>Slice=</varname></term>
701
702 <listitem>
703 <para>The name of the slice unit to place the unit
704 in. Defaults to <filename>system.slice</filename> for all
705 non-instantiated units of all unit types (except for slice
706 units themselves see below). Instance units are by default
707 placed in a subslice of <filename>system.slice</filename>
708 that is named after the template name.</para>
709
710 <para>This option may be used to arrange systemd units in a
711 hierarchy of slices each of which might have resource
712 settings applied.</para>
713
714 <para>For units of type slice, the only accepted value for
715 this setting is the parent slice. Since the name of a slice
716 unit implies the parent slice, it is hence redundant to ever
717 set this parameter directly for slice units.</para>
718
719 <para>Special care should be taken when relying on the default slice assignment in templated service units
720 that have <varname>DefaultDependencies=no</varname> set, see
721 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>, section
722 "Default Dependencies" for details.</para>
723
724 </listitem>
725 </varlistentry>
726
727 <varlistentry>
728 <term><varname>Delegate=</varname></term>
729
730 <listitem>
731 <para>Turns on delegation of further resource control partitioning to processes of the unit. Units where this
732 is enabled may create and manage their own private subhierarchy of control groups below the control group of
733 the unit itself. For unprivileged services (i.e. those using the <varname>User=</varname> setting) the unit's
734 control group will be made accessible to the relevant user. When enabled the service manager will refrain
735 from manipulating control groups or moving processes below the unit's control group, so that a clear concept
736 of ownership is established: the control group tree above the unit's control group (i.e. towards the root
737 control group) is owned and managed by the service manager of the host, while the control group tree below
738 the unit's control group is owned and managed by the unit itself. Takes either a boolean argument or a list
739 of control group controller names. If true, delegation is turned on, and all supported controllers are
740 enabled for the unit, making them available to the unit's processes for management. If false, delegation is
741 turned off entirely (and no additional controllers are enabled). If set to a list of controllers, delegation
742 is turned on, and the specified controllers are enabled for the unit. Note that additional controllers than
743 the ones specified might be made available as well, depending on configuration of the containing slice unit
744 or other units contained in it. Note that assigning the empty string will enable delegation, but reset the
745 list of controllers, all assignments prior to this will have no effect. Defaults to false.</para>
746
747 <para>Note that controller delegation to less privileged code is only safe on the unified control group
748 hierarchy. Accordingly, access to the specified controllers will not be granted to unprivileged services on
749 the legacy hierarchy, even when requested.</para>
750
751 <para>The following controller names may be specified: <option>cpu</option>, <option>cpuacct</option>,
752 <option>io</option>, <option>blkio</option>, <option>memory</option>, <option>devices</option>,
753 <option>pids</option>. Not all of these controllers are available on all kernels however, and some are
754 specific to the unified hierarchy while others are specific to the legacy hierarchy. Also note that the
755 kernel might support further controllers, which aren't covered here yet as delegation is either not supported
756 at all for them or not defined cleanly.</para>
757
758 <para>For further details on the delegation model consult <ulink
759 url="https://systemd.io/CGROUP_DELEGATION">Control Group APIs and Delegation</ulink>.</para>
760 </listitem>
761 </varlistentry>
762
763 <varlistentry>
764 <term><varname>DisableControllers=</varname></term>
765
766 <listitem>
767 <para>Disables controllers from being enabled for a unit's children. If a controller listed is already in use
768 in its subtree, the controller will be removed from the subtree. This can be used to avoid child units being
769 able to implicitly or explicitly enable a controller. Defaults to not disabling any controllers.</para>
770
771 <para>It may not be possible to successfully disable a controller if the unit or any child of the unit in
772 question delegates controllers to its children, as any delegated subtree of the cgroup hierarchy is unmanaged
773 by systemd.</para>
774
775 <para>Multiple controllers may be specified, separated by spaces. You may also pass
776 <varname>DisableControllers=</varname> multiple times, in which case each new instance adds another controller
777 to disable. Passing <varname>DisableControllers=</varname> by itself with no controller name present resets
778 the disabled controller list.</para>
779
780 <para>Valid controllers are <option>cpu</option>, <option>cpuacct</option>, <option>io</option>,
781 <option>blkio</option>, <option>memory</option>, <option>devices</option>, and <option>pids</option>.</para>
782 </listitem>
783 </varlistentry>
784 </variablelist>
785 </refsect1>
786
787 <refsect1>
788 <title>Deprecated Options</title>
789
790 <para>The following options are deprecated. Use the indicated superseding options instead:</para>
791
792 <variablelist class='unit-directives'>
793
794 <varlistentry>
795 <term><varname>CPUShares=<replaceable>weight</replaceable></varname></term>
796 <term><varname>StartupCPUShares=<replaceable>weight</replaceable></varname></term>
797
798 <listitem>
799 <para>Assign the specified CPU time share weight to the processes executed. These options take an integer
800 value and control the <literal>cpu.shares</literal> control group attribute. The allowed range is 2 to
801 262144. Defaults to 1024. For details about this control group attribute, see <ulink
802 url="https://www.kernel.org/doc/Documentation/scheduler/sched-design-CFS.txt">sched-design-CFS.txt</ulink>.
803 The available CPU time is split up among all units within one slice relative to their CPU time share
804 weight.</para>
805
806 <para>While <varname>StartupCPUShares=</varname> only applies to the startup phase of the system,
807 <varname>CPUShares=</varname> applies to normal runtime of the system, and if the former is not set also to
808 the startup phase. Using <varname>StartupCPUShares=</varname> allows prioritizing specific services at
809 boot-up differently than during normal runtime.</para>
810
811 <para>Implies <literal>CPUAccounting=yes</literal>.</para>
812
813 <para>These settings are deprecated. Use <varname>CPUWeight=</varname> and
814 <varname>StartupCPUWeight=</varname> instead.</para>
815 </listitem>
816 </varlistentry>
817
818 <varlistentry>
819 <term><varname>MemoryLimit=<replaceable>bytes</replaceable></varname></term>
820
821 <listitem>
822 <para>Specify the limit on maximum memory usage of the executed processes. The limit specifies how much
823 process and kernel memory can be used by tasks in this unit. Takes a memory size in bytes. If the value is
824 suffixed with K, M, G or T, the specified memory size is parsed as Kilobytes, Megabytes, Gigabytes, or
825 Terabytes (with the base 1024), respectively. Alternatively, a percentage value may be specified, which is
826 taken relative to the installed physical memory on the system. If assigned the special value
827 <literal>infinity</literal>, no memory limit is applied. This controls the
828 <literal>memory.limit_in_bytes</literal> control group attribute. For details about this control group
829 attribute, see <ulink
830 url="https://www.kernel.org/doc/Documentation/cgroup-v1/memory.txt">memory.txt</ulink>.</para>
831
832 <para>Implies <literal>MemoryAccounting=yes</literal>.</para>
833
834 <para>This setting is deprecated. Use <varname>MemoryMax=</varname> instead.</para>
835 </listitem>
836 </varlistentry>
837
838 <varlistentry>
839 <term><varname>BlockIOAccounting=</varname></term>
840
841 <listitem>
842 <para>Turn on Block I/O accounting for this unit, if the legacy control group hierarchy is used on the
843 system. Takes a boolean argument. Note that turning on block I/O accounting for one unit will also implicitly
844 turn it on for all units contained in the same slice and all for its parent slices and the units contained
845 therein. The system default for this setting may be controlled with
846 <varname>DefaultBlockIOAccounting=</varname> in
847 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
848
849 <para>This setting is deprecated. Use <varname>IOAccounting=</varname> instead.</para>
850 </listitem>
851 </varlistentry>
852
853 <varlistentry>
854 <term><varname>BlockIOWeight=<replaceable>weight</replaceable></varname></term>
855 <term><varname>StartupBlockIOWeight=<replaceable>weight</replaceable></varname></term>
856
857 <listitem><para>Set the default overall block I/O weight for the executed processes, if the legacy control
858 group hierarchy is used on the system. Takes a single weight value (between 10 and 1000) to set the default
859 block I/O weight. This controls the <literal>blkio.weight</literal> control group attribute, which defaults to
860 500. For details about this control group attribute, see <ulink
861 url="https://www.kernel.org/doc/Documentation/cgroup-v1/blkio-controller.txt">blkio-controller.txt</ulink>.
862 The available I/O bandwidth is split up among all units within one slice relative to their block I/O
863 weight.</para>
864
865 <para>While <varname>StartupBlockIOWeight=</varname> only
866 applies to the startup phase of the system,
867 <varname>BlockIOWeight=</varname> applies to the later runtime
868 of the system, and if the former is not set also to the
869 startup phase. This allows prioritizing specific services at
870 boot-up differently than during runtime.</para>
871
872 <para>Implies
873 <literal>BlockIOAccounting=yes</literal>.</para>
874
875 <para>These settings are deprecated. Use <varname>IOWeight=</varname> and <varname>StartupIOWeight=</varname>
876 instead.</para>
877
878 </listitem>
879 </varlistentry>
880
881 <varlistentry>
882 <term><varname>BlockIODeviceWeight=<replaceable>device</replaceable> <replaceable>weight</replaceable></varname></term>
883
884 <listitem>
885 <para>Set the per-device overall block I/O weight for the executed processes, if the legacy control group
886 hierarchy is used on the system. Takes a space-separated pair of a file path and a weight value to specify
887 the device specific weight value, between 10 and 1000. (Example: "/dev/sda 500"). The file path may be
888 specified as path to a block device node or as any other file, in which case the backing block device of the
889 file system of the file is determined. This controls the <literal>blkio.weight_device</literal> control group
890 attribute, which defaults to 1000. Use this option multiple times to set weights for multiple devices. For
891 details about this control group attribute, see <ulink
892 url="https://www.kernel.org/doc/Documentation/cgroup-v1/blkio-controller.txt">blkio-controller.txt</ulink>.</para>
893
894 <para>Implies
895 <literal>BlockIOAccounting=yes</literal>.</para>
896
897 <para>This setting is deprecated. Use <varname>IODeviceWeight=</varname> instead.</para>
898 </listitem>
899 </varlistentry>
900
901 <varlistentry>
902 <term><varname>BlockIOReadBandwidth=<replaceable>device</replaceable> <replaceable>bytes</replaceable></varname></term>
903 <term><varname>BlockIOWriteBandwidth=<replaceable>device</replaceable> <replaceable>bytes</replaceable></varname></term>
904
905 <listitem>
906 <para>Set the per-device overall block I/O bandwidth limit for the executed processes, if the legacy control
907 group hierarchy is used on the system. Takes a space-separated pair of a file path and a bandwidth value (in
908 bytes per second) to specify the device specific bandwidth. The file path may be a path to a block device
909 node, or as any other file in which case the backing block device of the file system of the file is used. If
910 the bandwidth is suffixed with K, M, G, or T, the specified bandwidth is parsed as Kilobytes, Megabytes,
911 Gigabytes, or Terabytes, respectively, to the base of 1000. (Example:
912 "/dev/disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0 5M"). This controls the
913 <literal>blkio.throttle.read_bps_device</literal> and <literal>blkio.throttle.write_bps_device</literal>
914 control group attributes. Use this option multiple times to set bandwidth limits for multiple devices. For
915 details about these control group attributes, see <ulink
916 url="https://www.kernel.org/doc/Documentation/cgroup-v1/blkio-controller.txt">blkio-controller.txt</ulink>.
917 </para>
918
919 <para>Implies
920 <literal>BlockIOAccounting=yes</literal>.</para>
921
922 <para>These settings are deprecated. Use <varname>IOReadBandwidthMax=</varname> and
923 <varname>IOWriteBandwidthMax=</varname> instead.</para>
924 </listitem>
925 </varlistentry>
926
927 </variablelist>
928 </refsect1>
929
930 <refsect1>
931 <title>See Also</title>
932 <para>
933 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
934 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
935 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
936 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
937 <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
938 <citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
939 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
940 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
941 <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
942 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
943 <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
944 <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
945 The documentation for control groups and specific controllers in the Linux kernel:
946 <ulink url="https://www.kernel.org/doc/Documentation/cgroup-v1/cgroups.txt">cgroups.txt</ulink>,
947 <ulink url="https://www.kernel.org/doc/Documentation/cgroup-v1/cpuacct.txt">cpuacct.txt</ulink>,
948 <ulink url="https://www.kernel.org/doc/Documentation/cgroup-v1/memory.txt">memory.txt</ulink>,
949 <ulink url="https://www.kernel.org/doc/Documentation/cgroup-v1/blkio-controller.txt">blkio-controller.txt</ulink>.
950 <ulink url="https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt">sched-bwc.txt</ulink>.
951 </para>
952 </refsect1>
953 </refentry>