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