]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/systemd.resource-control.xml
util: remove ring.[ch] + pty.[ch] and tests
[thirdparty/systemd.git] / man / systemd.resource-control.xml
CommitLineData
3802a3d3 1<?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
d868475a 2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
12b42c76 3"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
d868475a
ZJS
4
5<!--
b975b0d5 6 This file is part of systemd.
d868475a 7
b975b0d5 8 Copyright 2013 Zbigniew Jędrzejewski-Szmek
d868475a 9
b975b0d5
ZJS
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
d868475a 14
b975b0d5
ZJS
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
d868475a 19
b975b0d5
ZJS
20 You should have received a copy of the GNU Lesser General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
d868475a
ZJS
22-->
23
3fde5f30 24<refentry id="systemd.resource-control">
d868475a 25 <refentryinfo>
3fde5f30 26 <title>systemd.resource-control</title>
d868475a
ZJS
27 <productname>systemd</productname>
28
29 <authorgroup>
30 <author>
31 <contrib>Developer</contrib>
32 <firstname>Lennart</firstname>
33 <surname>Poettering</surname>
34 <email>lennart@poettering.net</email>
35 </author>
36 </authorgroup>
37 </refentryinfo>
38
39 <refmeta>
3fde5f30 40 <refentrytitle>systemd.resource-control</refentrytitle>
d868475a
ZJS
41 <manvolnum>5</manvolnum>
42 </refmeta>
43
44 <refnamediv>
3fde5f30
LP
45 <refname>systemd.resource-control</refname>
46 <refpurpose>Resource control unit settings</refpurpose>
d868475a
ZJS
47 </refnamediv>
48
49 <refsynopsisdiv>
50 <para>
51 <filename><replaceable>slice</replaceable>.slice</filename>,
52 <filename><replaceable>scope</replaceable>.scope</filename>,
53 <filename><replaceable>service</replaceable>.service</filename>,
54 <filename><replaceable>socket</replaceable>.socket</filename>,
55 <filename><replaceable>mount</replaceable>.mount</filename>,
56 <filename><replaceable>swap</replaceable>.swap</filename>
57 </para>
58 </refsynopsisdiv>
59
60 <refsect1>
61 <title>Description</title>
62
63 <para>Unit configuration files for services, slices, scopes,
64 sockets, mount points, and swap devices share a subset of
3fde5f30 65 configuration options for resource control of spawned
72f4d966 66 processes. Internally, this relies on the Control Groups
9b0374e9 67 kernel concept for organizing processes in a hierarchical tree of
3fde5f30 68 named groups for the purpose of resource management.</para>
9365b048 69
d868475a
ZJS
70 <para>This man page lists the configuration options shared by
71 those six unit types. See
72 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
73 for the common options of all unit configuration files, and
74 <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
75 <citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
76 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
77 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
78 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
79 and
80 <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>
81 for more information on the specific unit configuration files. The
3fde5f30 82 resource control configuration options are configured in the
d868475a
ZJS
83 [Slice], [Scope], [Service], [Socket], [Mount], or [Swap]
84 sections, depending on the unit type.</para>
ea021cc3
LP
85
86 <para>See the <ulink
87 url="http://www.freedesktop.org/wiki/Software/systemd/ControlGroupInterface/">New
72f4d966 88 Control Group Interfaces</ulink> for an introduction on how to make
ea021cc3 89 use of resource control APIs from programs.</para>
d868475a
ZJS
90 </refsect1>
91
92 <refsect1>
93 <title>Options</title>
94
95 <para>Units of the types listed above can have settings
3fde5f30 96 for resource control configuration:</para>
d868475a
ZJS
97
98 <variablelist class='unit-directives'>
d868475a
ZJS
99
100 <varlistentry>
61ad59b1 101 <term><varname>CPUAccounting=</varname></term>
d868475a
ZJS
102
103 <listitem>
61ad59b1
LP
104 <para>Turn on CPU usage accounting for this unit. Takes a
105 boolean argument. Note that turning on CPU accounting for
03a7b521 106 one unit will also implicitly turn it on for all units
085afe36
LP
107 contained in the same slice and for all its parent slices
108 and the units contained therein. The system default for this
03a7b521 109 setting may be controlled with
085afe36
LP
110 <varname>DefaultCPUAccounting=</varname> in
111 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
d868475a
ZJS
112 </listitem>
113 </varlistentry>
114
d868475a
ZJS
115 <varlistentry>
116 <term><varname>CPUShares=<replaceable>weight</replaceable></varname></term>
db785129 117 <term><varname>StartupCPUShares=<replaceable>weight</replaceable></varname></term>
d868475a
ZJS
118
119 <listitem>
b2f8b02e 120 <para>Assign the specified CPU time share weight to the
b9acccb3
ZJS
121 processes executed. Those options take an integer value and
122 control the <literal>cpu.shares</literal> control group
123 attribute, which defaults to 1024. For details about this
124 control group attribute, see <ulink
db785129 125 url="https://www.kernel.org/doc/Documentation/scheduler/sched-design-CFS.txt">sched-design-CFS.txt</ulink>.
b9acccb3
ZJS
126 The available CPU time is split up among all units within
127 one slice relative to their CPU time share weight.</para>
b2f8b02e 128
db785129
LP
129 <para>While <varname>StartupCPUShares=</varname> only
130 applies to the startup phase of the system,
b9acccb3
ZJS
131 <varname>CPUShares=</varname> applies to normal runtime of
132 the system, and if the former is not set also to the startup
133 phase. Using <varname>StartupCPUShares=</varname> allows
9b0374e9 134 prioritizing specific services at boot-up differently than
b9acccb3
ZJS
135 during normal runtime.</para>
136
03a7b521 137 <para>These options imply
b9acccb3 138 <literal>CPUAccounting=true</literal>.</para>
b2f8b02e
LP
139 </listitem>
140 </varlistentry>
141
142 <varlistentry>
143 <term><varname>CPUQuota=</varname></term>
144
145 <listitem>
146 <para>Assign the specified CPU time quota to the processes
9a054909
LP
147 executed. Takes a percentage value, suffixed with "%". The
148 percentage specifies how much CPU time the unit shall get at
149 maximum, relative to the total CPU time available on one
9b0374e9 150 CPU. Use values &gt; 100% for allotting CPU time on more than
9a054909 151 one CPU. This controls the
b2f8b02e
LP
152 <literal>cpu.cfs_quota_us</literal> control group
153 attribute. For details about this control group attribute,
154 see <ulink
155 url="https://www.kernel.org/doc/Documentation/scheduler/sched-design-CFS.txt">sched-design-CFS.txt</ulink>.</para>
156
80d3d25d 157 <para>Example: <varname>CPUQuota=20%</varname> ensures that
b2f8b02e
LP
158 the executed processes will never get more than 20% CPU time
159 on one CPU.</para>
160
161 <para>Implies <literal>CPUAccounting=true</literal>.</para>
162 </listitem>
163 </varlistentry>
164
61ad59b1
LP
165 <varlistentry>
166 <term><varname>MemoryAccounting=</varname></term>
167
168 <listitem>
169 <para>Turn on process and kernel memory accounting for this
170 unit. Takes a boolean argument. Note that turning on memory
03a7b521
LP
171 accounting for one unit will also implicitly turn it on for
172 all units contained in the same slice and for all its parent
173 slices and the units contained therein. The system default
174 for this setting may be controlled with
085afe36
LP
175 <varname>DefaultMemoryAccounting=</varname> in
176 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
61ad59b1
LP
177 </listitem>
178 </varlistentry>
179
d868475a
ZJS
180 <varlistentry>
181 <term><varname>MemoryLimit=<replaceable>bytes</replaceable></varname></term>
d868475a
ZJS
182
183 <listitem>
ddca82ac
LP
184 <para>Specify the limit on maximum memory usage of the
185 executed processes. The limit specifies how much process and
186 kernel memory can be used by tasks in this unit. Takes a
d868475a 187 memory size in bytes. If the value is suffixed with K, M, G
6a75304e 188 or T, the specified memory size is parsed as Kilobytes,
d868475a 189 Megabytes, Gigabytes, or Terabytes (with the base 1024),
03a7b521
LP
190 respectively. If assigned the special value
191 <literal>infinity</literal> no memory limit is applied. This
192 controls the <literal>memory.limit_in_bytes</literal>
193 control group attribute. For details about this control
194 group attribute, see <ulink
6ed80a4e 195 url="https://www.kernel.org/doc/Documentation/cgroups/memory.txt">memory.txt</ulink>.</para>
d868475a
ZJS
196
197 <para>Implies <literal>MemoryAccounting=true</literal>.</para>
198 </listitem>
199 </varlistentry>
200
03a7b521
LP
201 <varlistentry>
202 <term><varname>TasksAccounting=</varname></term>
203
204 <listitem>
205 <para>Turn on task accounting for this unit. Takes a
206 boolean argument. If enabled, the system manager will keep
207 track of the number of tasks in the unit. The number of
208 tasks accounted this way includes both kernel threads and
209 userspace processes, with each thread counting
210 individually. Note that turning on tasks accounting for one
211 unit will also implicitly turn it on for all units contained
212 in the same slice and for all its parent slices and the
213 units contained therein. The system default for this setting
214 may be controlled with
215 <varname>DefaultTasksAccounting=</varname> in
216 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
217 </listitem>
218 </varlistentry>
219
220 <varlistentry>
221 <term><varname>TasksMax=<replaceable>N</replaceable></varname></term>
222
223 <listitem>
224 <para>Specify the maximum number of tasks that may be
225 created in the unit. This ensures that the number of tasks
226 accounted for the unit (see above) stays below a specific
227 limit. If assigned the special value
228 <literal>infinity</literal> no tasks limit is applied. This
229 controls the <literal>pids.max</literal> control group
230 attribute. For details about this control group attribute,
231 see <ulink
232 url="https://www.kernel.org/doc/Documentation/cgroups/pids.txt">pids.txt</ulink>.</para>
233
234 <para>Implies <literal>TasksAccounting=true</literal>.</para>
235 </listitem>
236 </varlistentry>
237
61ad59b1
LP
238 <varlistentry>
239 <term><varname>BlockIOAccounting=</varname></term>
240
241 <listitem>
242 <para>Turn on Block IO accounting for this unit. Takes a
243 boolean argument. Note that turning on block IO accounting
03a7b521 244 for one unit will also implicitly turn it on for all units
085afe36
LP
245 contained in the same slice and all for its parent slices
246 and the units contained therein. The system default for this
03a7b521 247 setting may be controlled with
085afe36
LP
248 <varname>DefaultBlockIOAccounting=</varname> in
249 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
61ad59b1
LP
250 </listitem>
251 </varlistentry>
252
d868475a
ZJS
253 <varlistentry>
254 <term><varname>BlockIOWeight=<replaceable>weight</replaceable></varname></term>
db785129 255 <term><varname>StartupBlockIOWeight=<replaceable>weight</replaceable></varname></term>
d868475a 256
db785129
LP
257 <listitem><para>Set the default overall block IO weight for
258 the executed processes. Takes a single weight value (between
259 10 and 1000) to set the default block IO weight. This controls
260 the <literal>blkio.weight</literal> control group attribute,
261 which defaults to 1000. For details about this control group
262 attribute, see <ulink
263 url="https://www.kernel.org/doc/Documentation/cgroups/blkio-controller.txt">blkio-controller.txt</ulink>.
264 The available IO bandwidth is split up among all units within
265 one slice relative to their block IO weight.</para>
266
267 <para>While <varname>StartupBlockIOWeight=</varname> only
268 applies to the startup phase of the system,
269 <varname>BlockIOWeight=</varname> applies to the later runtime
270 of the system, and if the former is not set also to the
9b0374e9 271 startup phase. This allows prioritizing specific services at
db785129 272 boot-up differently than during runtime.</para>
61ad59b1
LP
273
274 <para>Implies
275 <literal>BlockIOAccounting=true</literal>.</para>
276 </listitem>
d868475a
ZJS
277 </varlistentry>
278
279 <varlistentry>
280 <term><varname>BlockIODeviceWeight=<replaceable>device</replaceable> <replaceable>weight</replaceable></varname></term>
281
282 <listitem>
283 <para>Set the per-device overall block IO weight for the
284 executed processes. Takes a space-separated pair of a file
285 path and a weight value to specify the device specific
286 weight value, between 10 and 1000. (Example: "/dev/sda
287 500"). The file path may be specified as path to a block
72f4d966 288 device node or as any other file, in which case the backing
d868475a
ZJS
289 block device of the file system of the file is
290 determined. This controls the
291 <literal>blkio.weight_device</literal> control group
292 attribute, which defaults to 1000. Use this option multiple
293 times to set weights for multiple devices. For details about
6a75304e 294 this control group attribute, see <ulink
6ed80a4e 295 url="https://www.kernel.org/doc/Documentation/cgroups/blkio-controller.txt">blkio-controller.txt</ulink>.</para>
61ad59b1
LP
296
297 <para>Implies
298 <literal>BlockIOAccounting=true</literal>.</para>
d868475a
ZJS
299 </listitem>
300 </varlistentry>
301
302 <varlistentry>
303 <term><varname>BlockIOReadBandwidth=<replaceable>device</replaceable> <replaceable>bytes</replaceable></varname></term>
304 <term><varname>BlockIOWriteBandwidth=<replaceable>device</replaceable> <replaceable>bytes</replaceable></varname></term>
305
306 <listitem>
307 <para>Set the per-device overall block IO bandwidth limit
308 for the executed processes. Takes a space-separated pair of
309 a file path and a bandwidth value (in bytes per second) to
310 specify the device specific bandwidth. The file path may be
311 a path to a block device node, or as any other file in which
312 case the backing block device of the file system of the file
6a75304e 313 is used. If the bandwidth is suffixed with K, M, G, or T,
d868475a 314 the specified bandwidth is parsed as Kilobytes, Megabytes,
5556b5fe
LP
315 Gigabytes, or Terabytes, respectively, to the base of
316 1000. (Example:
d868475a
ZJS
317 "/dev/disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0 5M"). This
318 controls the <literal>blkio.read_bps_device</literal> and
319 <literal>blkio.write_bps_device</literal> control group
320 attributes. Use this option multiple times to set bandwidth
321 limits for multiple devices. For details about these control
5556b5fe
LP
322 group attributes, see <ulink
323 url="https://www.kernel.org/doc/Documentation/cgroups/blkio-controller.txt">blkio-controller.txt</ulink>.
d868475a 324 </para>
61ad59b1
LP
325
326 <para>Implies
327 <literal>BlockIOAccounting=true</literal>.</para>
d868475a
ZJS
328 </listitem>
329 </varlistentry>
330
331 <varlistentry>
332 <term><varname>DeviceAllow=</varname></term>
333
334 <listitem>
335 <para>Control access to specific device nodes by the
336 executed processes. Takes two space-separated strings: a
90060676
LP
337 device node specifier followed by a combination of
338 <constant>r</constant>, <constant>w</constant>,
339 <constant>m</constant> to control
d868475a 340 <emphasis>r</emphasis>eading, <emphasis>w</emphasis>riting,
90060676 341 or creation of the specific device node(s) by the unit
d868475a
ZJS
342 (<emphasis>m</emphasis>knod), respectively. This controls
343 the <literal>devices.allow</literal> and
344 <literal>devices.deny</literal> control group
90060676
LP
345 attributes. For details about these control group
346 attributes, see <ulink
6ed80a4e 347 url="https://www.kernel.org/doc/Documentation/cgroups/devices.txt">devices.txt</ulink>.</para>
90060676
LP
348
349 <para>The device node specifier is either a path to a device
350 node in the file system, starting with
351 <filename>/dev/</filename>, or a string starting with either
352 <literal>char-</literal> or <literal>block-</literal>
353 followed by a device group name, as listed in
354 <filename>/proc/devices</filename>. The latter is useful to
355 whitelist all current and future devices belonging to a
e41969e3
LP
356 specific device group at once. The device group is matched
357 according to file name globbing rules, you may hence use the
358 <literal>*</literal> and <literal>?</literal>
359 wildcards. Examples: <filename>/dev/sda5</filename> is a
360 path to a device node, referring to an ATA or SCSI block
90060676
LP
361 device. <literal>char-pts</literal> and
362 <literal>char-alsa</literal> are specifiers for all pseudo
e41969e3
LP
363 TTYs and all ALSA sound devices,
364 respectively. <literal>char-cpu/*</literal> is a specifier
365 matching all CPU related device groups.</para>
d868475a
ZJS
366 </listitem>
367 </varlistentry>
368
369 <varlistentry>
370 <term><varname>DevicePolicy=auto|closed|strict</varname></term>
371
372 <listitem>
373 <para>
374 Control the policy for allowing device access:
375 </para>
376 <variablelist>
377 <varlistentry>
378 <term><option>strict</option></term>
379 <listitem>
380 <para>means to only allow types of access that are
381 explicitly specified.</para>
382 </listitem>
383 </varlistentry>
384
385 <varlistentry>
386 <term><option>closed</option></term>
387 <listitem>
6a75304e 388 <para>in addition, allows access to standard pseudo
d868475a
ZJS
389 devices including
390 <filename>/dev/null</filename>,
391 <filename>/dev/zero</filename>,
392 <filename>/dev/full</filename>,
393 <filename>/dev/random</filename>, and
394 <filename>/dev/urandom</filename>.
395 </para>
396 </listitem>
397 </varlistentry>
398
399 <varlistentry>
400 <term><option>auto</option></term>
401 <listitem>
402 <para>
6a75304e 403 in addition, allows access to all devices if no
d868475a
ZJS
404 explicit <varname>DeviceAllow=</varname> is present.
405 This is the default.
406 </para>
407 </listitem>
408 </varlistentry>
409 </variablelist>
410 </listitem>
411 </varlistentry>
61ad59b1
LP
412
413 <varlistentry>
414 <term><varname>Slice=</varname></term>
415
416 <listitem>
417 <para>The name of the slice unit to place the unit
418 in. Defaults to <filename>system.slice</filename> for all
dc7adf20
LP
419 non-instantiated units of all unit types (except for slice
420 units themselves see below). Instance units are by default
421 placed in a subslice of <filename>system.slice</filename>
422 that is named after the template name.</para>
423
424 <para>This option may be used to arrange systemd units in a
425 hierarchy of slices each of which might have resource
426 settings applied.</para>
61ad59b1 427
fbce1139 428 <para>For units of type slice, the only accepted value for
61ad59b1 429 this setting is the parent slice. Since the name of a slice
fbce1139 430 unit implies the parent slice, it is hence redundant to ever
61ad59b1
LP
431 set this parameter directly for slice units.</para>
432 </listitem>
433 </varlistentry>
434
a931ad47
LP
435 <varlistentry>
436 <term><varname>Delegate=</varname></term>
437
438 <listitem>
439 <para>Turns on delegation of further resource control
9b0374e9 440 partitioning to processes of the unit. For unprivileged
a931ad47
LP
441 services (i.e. those using the <varname>User=</varname>
442 setting) this allows processes to create a subhierarchy
9b0374e9 443 beneath its control group path. For privileged services and
a931ad47
LP
444 scopes this ensures the processes will have all control
445 group controllers enabled.</para>
446 </listitem>
447 </varlistentry>
448
d868475a
ZJS
449 </variablelist>
450 </refsect1>
451
452 <refsect1>
453 <title>See Also</title>
454 <para>
455 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
456 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
457 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
458 <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
459 <citerefentry><refentrytitle>systemd.scope</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
460 <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
461 <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
462 <citerefentry><refentrytitle>systemd.swap</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
463 <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
61ad59b1 464 <citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
d868475a 465 The documentation for control groups and specific controllers in the Linux kernel:
6ed80a4e
JSJ
466 <ulink url="https://www.kernel.org/doc/Documentation/cgroups/cgroups.txt">cgroups.txt</ulink>,
467 <ulink url="https://www.kernel.org/doc/Documentation/cgroups/cpuacct.txt">cpuacct.txt</ulink>,
468 <ulink url="https://www.kernel.org/doc/Documentation/cgroups/memory.txt">memory.txt</ulink>,
469 <ulink url="https://www.kernel.org/doc/Documentation/cgroups/blkio-controller.txt">blkio-controller.txt</ulink>.
d868475a
ZJS
470 </para>
471 </refsect1>
472</refentry>