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