Skip to content

Commit 4e1dfa4

Browse files
cdownyuwata
authored andcommitted
cgroup: s/cgroups? ?v?([0-9])/cgroup v\1/gI
Nitpicky, but we've used a lot of random spacings and names in the past, but we're trying to be completely consistent on "cgroup vN" now. Generated by `fd -0 | xargs -0 -n1 sed -ri --follow-symlinks 's/cgroups? ?v?([0-9])/cgroup v\1/gI'`. I manually ignored places where it's not appropriate to replace (eg. "cgroup2" fstype and in src/shared/linux).
1 parent 788291d commit 4e1dfa4

File tree

11 files changed

+66
-66
lines changed

11 files changed

+66
-66
lines changed

NEWS

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ CHANGES WITH 240:
133133

134134
* The new "MemoryMin=" unit file property may now be used to set the
135135
memory usage protection limit of processes invoked by the unit. This
136-
controls the cgroupsv2 memory.min attribute. Similarly, the new
136+
controls the cgroup v2 memory.min attribute. Similarly, the new
137137
"IODeviceLatencyTargetSec=" property has been added, wrapping the new
138-
cgroupsv2 io.latency cgroup property for configuring per-service I/O
138+
cgroup v2 io.latency cgroup property for configuring per-service I/O
139139
latency.
140140

141-
* systemd now supports the cgroupsv2 devices BPF logic, as counterpart
142-
to the cgroupsv1 "devices" cgroup controller.
141+
* systemd now supports the cgroup v2 devices BPF logic, as counterpart
142+
to the cgroup v1 "devices" cgroup controller.
143143

144144
* systemd-escape now is able to combine --unescape with --template. It
145145
also learnt a new option --instance for extracting and unescaping the
@@ -355,7 +355,7 @@ CHANGES WITH 240:
355355

356356
* The JoinControllers= option in system.conf is no longer supported, as
357357
it didn't work correctly, is hard to support properly, is legacy (as
358-
the concept only exists on cgroupsv1) and apparently wasn't used.
358+
the concept only exists on cgroup v1) and apparently wasn't used.
359359

360360
* Journal messages that are generated whenever a unit enters the failed
361361
state are now tagged with a unique MESSAGE_ID. Similarly, messages
@@ -992,7 +992,7 @@ CHANGES WITH 238:
992992
instance to migrate processes if it itself gets the request to
993993
migrate processes and the kernel refuses this due to access
994994
restrictions. Thanks to this "systemd-run --scope --user …" works
995-
again in pure cgroups v2 environments when invoked from the user
995+
again in pure cgroup v2 environments when invoked from the user
996996
session scope.
997997

998998
* A new TemporaryFileSystem= setting can be used to mask out part of
@@ -2708,7 +2708,7 @@ CHANGES WITH 231:
27082708
desired options.
27092709

27102710
* systemd now supports the "memory" cgroup controller also on
2711-
cgroupsv2.
2711+
cgroup v2.
27122712

27132713
* The systemd-cgtop tool now optionally takes a control group path as
27142714
command line argument. If specified, the control group list shown is

TODO

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Features:
5858
* when a socket unit is spawned with an AF_UNIX path in /var/run, complain and
5959
patch it to use /run instead
6060

61-
* set memory.oom.group in cgroupsv2 for all leaf cgroups (kernel v4.19+)
61+
* set memory.oom.group in cgroup v2 for all leaf cgroups (kernel v4.19+)
6262

6363
* add a new syscall group "@esoteric" for more esoteric stuff such as bpf() and
6464
usefaultd() and make systemd-analyze check for it.

docs/CGROUP_DELEGATION.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ container managers.
1717

1818
Before you read on, please make sure you read the low-level [kernel
1919
documentation about
20-
cgroupsv2](https://www.kernel.org/doc/Documentation/cgroup-v2.txt). This
20+
cgroup v2](https://www.kernel.org/doc/Documentation/cgroup-v2.txt). This
2121
documentation then adds in the higher-level view from systemd.
2222

2323
This document augments the existing documentation we already have:
@@ -34,8 +34,8 @@ wiki documentation into this very document, too.)
3434
## Two Key Design Rules
3535

3636
Much of the philosophy behind these concepts is based on a couple of basic
37-
design ideas of cgroupsv2 (which we however try to adapt as far as we can to
38-
cgroupsv1 too). Specifically two cgroupsv2 rules are the most relevant:
37+
design ideas of cgroup v2 (which we however try to adapt as far as we can to
38+
cgroup v1 too). Specifically two cgroup v2 rules are the most relevant:
3939

4040
1. The **no-processes-in-inner-nodes** rule: this means that it's not permitted
4141
to have processes directly attached to a cgroup that also has child cgroups and
@@ -58,45 +58,45 @@ your container manager creates and manages cgroups in the system's root cgroup
5858
you violate rule #2, as the root cgroup is managed by systemd and hence off
5959
limits to everybody else.
6060

61-
Note that rule #1 is generally enforced by the kernel if cgroupsv2 is used: as
61+
Note that rule #1 is generally enforced by the kernel if cgroup v2 is used: as
6262
soon as you add a process to a cgroup it is ensured the rule is not
63-
violated. On cgroupsv1 this rule didn't exist, and hence isn't enforced, even
63+
violated. On cgroup v1 this rule didn't exist, and hence isn't enforced, even
6464
though it's a good thing to follow it then too. Rule #2 is not enforced on
65-
either cgroupsv1 nor cgroupsv2 (this is UNIX after all, in the general case
65+
either cgroup v1 nor cgroup v2 (this is UNIX after all, in the general case
6666
root can do anything, modulo SELinux and friends), but if you ignore it you'll
6767
be in constant pain as various pieces of software will fight over cgroup
6868
ownership.
6969

70-
Note that cgroupsv1 is currently the most deployed implementation, even though
70+
Note that cgroup v1 is currently the most deployed implementation, even though
7171
it's semantically broken in many ways, and in many cases doesn't actually do
72-
what people think it does. cgroupsv2 is where things are going, and most new
73-
kernel features in this area are only added to cgroupsv2, and not cgroupsv1
74-
anymore. For example cgroupsv2 provides proper cgroup-empty notifications, has
72+
what people think it does. cgroup v2 is where things are going, and most new
73+
kernel features in this area are only added to cgroup v2, and not cgroup v1
74+
anymore. For example cgroup v2 provides proper cgroup-empty notifications, has
7575
support for all kinds of per-cgroup BPF magic, supports secure delegation of
7676
cgroup trees to less privileged processes and so on, which all are not
77-
available on cgroupsv1.
77+
available on cgroup v1.
7878

7979
## Three Different Tree Setups 🌳
8080

8181
systemd supports three different modes how cgroups are set up. Specifically:
8282

83-
1. **Unified** — this is the simplest mode, and exposes a pure cgroupsv2
83+
1. **Unified** — this is the simplest mode, and exposes a pure cgroup v2
8484
logic. In this mode `/sys/fs/cgroup` is the only mounted cgroup API file system
8585
and all available controllers are exclusively exposed through it.
8686

87-
2. **Legacy** — this is the traditional cgroupsv1 mode. In this mode the
87+
2. **Legacy** — this is the traditional cgroup v1 mode. In this mode the
8888
various controllers each get their own cgroup file system mounted to
8989
`/sys/fs/cgroup/<controller>/`. On top of that systemd manages its own cgroup
9090
hierarchy for managing purposes as `/sys/fs/cgroup/systemd/`.
9191

9292
3. **Hybrid** — this is a hybrid between the unified and legacy mode. It's set
9393
up mostly like legacy, except that there's also an additional hierarchy
94-
`/sys/fs/cgroup/unified/` that contains the cgroupsv2 hierarchy. (Note that in
94+
`/sys/fs/cgroup/unified/` that contains the cgroup v2 hierarchy. (Note that in
9595
this mode the unified hierarchy won't have controllers attached, the
9696
controllers are all mounted as separate hierarchies as in legacy mode,
97-
i.e. `/sys/fs/cgroup/unified/` is purely and exclusively about core cgroupsv2
97+
i.e. `/sys/fs/cgroup/unified/` is purely and exclusively about core cgroup v2
9898
functionality and not about resource management.) In this mode compatibility
99-
with cgroupsv1 is retained while some cgroupsv2 features are available
99+
with cgroup v1 is retained while some cgroup v2 features are available
100100
too. This mode is a stopgap. Don't bother with this too much unless you have
101101
too much free time.
102102

@@ -116,7 +116,7 @@ to talk of one specific cgroup and actually mean the same cgroup in all
116116
available controller hierarchies. E.g. if we talk about the cgroup `/foo/bar/`
117117
then we actually mean `/sys/fs/cgroup/cpu/foo/bar/` as well as
118118
`/sys/fs/cgroup/memory/foo/bar/`, `/sys/fs/cgroup/pids/foo/bar/`, and so on.
119-
Note that in cgroupsv2 the controller hierarchies aren't orthogonal, hence
119+
Note that in cgroup v2 the controller hierarchies aren't orthogonal, hence
120120
thinking about them as orthogonal won't help you in the long run anyway.
121121

122122
If you wonder how to detect which of these three modes is currently used, use
@@ -168,7 +168,7 @@ cgroup `/foo.slice/foo-bar.slice/foo-bar-baz.slice/quux.service/`.
168168
By default systemd sets up four slice units:
169169

170170
1. `-.slice` is the root slice. i.e. the parent of everything else. On the host
171-
system it maps directly to the top-level directory of cgroupsv2.
171+
system it maps directly to the top-level directory of cgroup v2.
172172

173173
2. `system.slice` is where system services are by default placed, unless
174174
configured otherwise.
@@ -187,8 +187,8 @@ above are just the defaults.
187187

188188
Container managers and suchlike often want to control cgroups directly using
189189
the raw kernel APIs. That's entirely fine and supported, as long as proper
190-
*delegation* is followed. Delegation is a concept we inherited from cgroupsv2,
191-
but we expose it on cgroupsv1 too. Delegation means that some parts of the
190+
*delegation* is followed. Delegation is a concept we inherited from cgroup v2,
191+
but we expose it on cgroup v1 too. Delegation means that some parts of the
192192
cgroup tree may be managed by different managers than others. As long as it is
193193
clear which manager manages which part of the tree each one can do within its
194194
sub-graph of the tree whatever it wants.
@@ -217,7 +217,7 @@ guarantees:
217217
hierarchy (in unified and hybrid mode) as well as on systemd's own private
218218
hierarchy (in legacy and hybrid mode). It won't pass ownership of the legacy
219219
controller hierarchies. Delegation to less privileges processes is not safe
220-
in cgroupsv1 (as a limitation of the kernel), hence systemd won't facilitate
220+
in cgroup v1 (as a limitation of the kernel), hence systemd won't facilitate
221221
access to it.
222222

223223
3. Any BPF IP filter programs systemd installs will be installed with
@@ -322,19 +322,19 @@ to work on that, and widen your horizon a bit. You are welcome.
322322
systemd supports a number of controllers (but not all). Specifically, supported
323323
are:
324324

325-
* on cgroupsv1: `cpu`, `cpuacct`, `blkio`, `memory`, `devices`, `pids`
326-
* on cgroupsv2: `cpu`, `io`, `memory`, `pids`
325+
* on cgroup v1: `cpu`, `cpuacct`, `blkio`, `memory`, `devices`, `pids`
326+
* on cgroup v2: `cpu`, `io`, `memory`, `pids`
327327

328-
It is our intention to natively support all cgroupsv2 controllers as they are
329-
added to the kernel. However, regarding cgroupsv1: at this point we will not
328+
It is our intention to natively support all cgroup v2 controllers as they are
329+
added to the kernel. However, regarding cgroup v1: at this point we will not
330330
add support for any other controllers anymore. This means systemd currently
331-
does not and will never manage the following controllers on cgroupsv1:
331+
does not and will never manage the following controllers on cgroup v1:
332332
`freezer`, `cpuset`, `net_cls`, `perf_event`, `net_prio`, `hugetlb`. Why not?
333333
Depending on the case, either their API semantics or implementations aren't
334-
really usable, or it's very clear they have no future on cgroupsv2, and we
334+
really usable, or it's very clear they have no future on cgroup v2, and we
335335
won't add new code for stuff that clearly has no future.
336336

337-
Effectively this means that all those mentioned cgroupsv1 controllers are up
337+
Effectively this means that all those mentioned cgroup v1 controllers are up
338338
for grabs: systemd won't manage them, and hence won't delegate them to your
339339
code (however, systemd will still mount their hierarchies, simply because it
340340
mounts all controller hierarchies it finds available in the kernel). If you
@@ -355,9 +355,9 @@ cgroups in them — from previous runs, and be extra careful with them as they
355355
might still carry settings that might not be valid anymore.
356356

357357
Note a particular asymmetry here: if your systemd version doesn't support a
358-
specific controller on cgroupsv1 you can still make use of it for delegation,
358+
specific controller on cgroup v1 you can still make use of it for delegation,
359359
by directly fiddling with its hierarchy and replicating the cgroup tree there
360-
as necessary (as suggested above). However, on cgroupsv2 this is different:
360+
as necessary (as suggested above). However, on cgroup v2 this is different:
361361
separately mounted hierarchies are not available, and delegation has always to
362362
happen through systemd itself. This means: when you update your kernel and it
363363
adds a new, so far unseen controller, and you want to use it for delegation,
@@ -417,7 +417,7 @@ unified you (of course, I guess) need to provide only `/sys/fs/cgroup/` itself.
417417
arbitrary naming, you might need to escape some of the names (for example,
418418
you really don't want to create a cgroup named `tasks`, just because the
419419
user created a container by that name, because `tasks` after all is a magic
420-
attribute in cgroupsv1, and your `mkdir()` will hence fail with `EEXIST`. In
420+
attribute in cgroup v1, and your `mkdir()` will hence fail with `EEXIST`. In
421421
systemd we do escaping by prefixing names that might collide with a kernel
422422
attribute name with an underscore. You might want to do the same, but this
423423
is really up to you how you do it. Just do it, and be careful.
@@ -462,9 +462,9 @@ unified you (of course, I guess) need to provide only `/sys/fs/cgroup/` itself.
462462
to get the cgroup for a unit. The method `GetUnitByControlGroup()` may be
463463
used to get the unit for a cgroup.)
464464

465-
6. ⚡ Think twice before delegating cgroupsv1 controllers to less privileged
465+
6. ⚡ Think twice before delegating cgroup v1 controllers to less privileged
466466
containers. It's not safe, you basically allow your containers to freeze the
467-
system with that and worse. Delegation is a strongpoint of cgroupsv2 though,
467+
system with that and worse. Delegation is a strongpoint of cgroup v2 though,
468468
and there it's safe to treat delegation boundaries as privilege boundaries.
469469

470470
And that's it for now. If you have further questions, refer to the systemd

src/basic/cgroup-util.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -872,15 +872,15 @@ int cg_set_access(
872872
bool fatal;
873873
};
874874

875-
/* cgroupsv1, aka legacy/non-unified */
875+
/* cgroup v1, aka legacy/non-unified */
876876
static const struct Attribute legacy_attributes[] = {
877877
{ "cgroup.procs", true },
878878
{ "tasks", false },
879879
{ "cgroup.clone_children", false },
880880
{},
881881
};
882882

883-
/* cgroupsv2, aka unified */
883+
/* cgroup v2, aka unified */
884884
static const struct Attribute unified_attributes[] = {
885885
{ "cgroup.procs", true },
886886
{ "cgroup.subtree_control", true },
@@ -2039,7 +2039,7 @@ int cg_get_keyed_attribute(
20392039
char **v;
20402040
int r;
20412041

2042-
/* Reads one or more fields of a cgroupsv2 keyed attribute file. The 'keys' parameter should be an strv with
2042+
/* Reads one or more fields of a cgroup v2 keyed attribute file. The 'keys' parameter should be an strv with
20432043
* all keys to retrieve. The 'ret_values' parameter should be passed as string size with the same number of
20442044
* entries as 'keys'. On success each entry will be set to the value of the matching key.
20452045
*
@@ -2491,7 +2491,7 @@ int cg_kernel_controllers(Set **ret) {
24912491

24922492
static thread_local CGroupUnified unified_cache = CGROUP_UNIFIED_UNKNOWN;
24932493

2494-
/* The hybrid mode was initially implemented in v232 and simply mounted cgroup v2 on /sys/fs/cgroup/systemd. This
2494+
/* The hybrid mode was initially implemented in v232 and simply mounted cgroup2 on /sys/fs/cgroup/systemd. This
24952495
* unfortunately broke other tools (such as docker) which expected the v1 "name=systemd" hierarchy on
24962496
* /sys/fs/cgroup/systemd. From v233 and on, the hybrid mode mountnbs v2 on /sys/fs/cgroup/unified and maintains
24972497
* "name=systemd" hierarchy on /sys/fs/cgroup/systemd for compatibility with other tools.
@@ -2739,13 +2739,13 @@ bool cg_is_legacy_wanted(void) {
27392739
if (wanted >= 0)
27402740
return wanted;
27412741

2742-
/* Check if we have cgroups2 already mounted. */
2742+
/* Check if we have cgroup v2 already mounted. */
27432743
if (cg_unified_flush() >= 0 &&
27442744
unified_cache == CGROUP_UNIFIED_ALL)
27452745
return (wanted = false);
27462746

27472747
/* Otherwise, assume that at least partial legacy is wanted,
2748-
* since cgroups2 should already be mounted at this point. */
2748+
* since cgroup v2 should already be mounted at this point. */
27492749
return (wanted = true);
27502750
}
27512751

src/basic/cgroup-util.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ typedef enum CGroupMask {
4848
CGROUP_MASK_BPF_FIREWALL = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BPF_FIREWALL),
4949
CGROUP_MASK_BPF_DEVICES = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BPF_DEVICES),
5050

51-
/* All real cgroupv1 controllers */
51+
/* All real cgroup v1 controllers */
5252
CGROUP_MASK_V1 = CGROUP_MASK_CPU|CGROUP_MASK_CPUACCT|CGROUP_MASK_BLKIO|CGROUP_MASK_MEMORY|CGROUP_MASK_DEVICES|CGROUP_MASK_PIDS,
5353

54-
/* All real cgroupv2 controllers */
54+
/* All real cgroup v2 controllers */
5555
CGROUP_MASK_V2 = CGROUP_MASK_CPU|CGROUP_MASK_IO|CGROUP_MASK_MEMORY|CGROUP_MASK_PIDS,
5656

57-
/* All cgroupv2 BPF pseudo-controllers */
57+
/* All cgroup v2 BPF pseudo-controllers */
5858
CGROUP_MASK_BPF = CGROUP_MASK_BPF_FIREWALL|CGROUP_MASK_BPF_DEVICES,
5959

6060
_CGROUP_MASK_ALL = CGROUP_CONTROLLER_TO_MASK(_CGROUP_CONTROLLER_MAX) - 1

src/cgtop/cgtop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static const char *maybe_format_bytes(char *buf, size_t l, bool is_valid, uint64
104104

105105
static bool is_root_cgroup(const char *path) {
106106

107-
/* Returns true if the specified path belongs to the root cgroup. The root cgroup is special on cgroupsv2 as it
107+
/* Returns true if the specified path belongs to the root cgroup. The root cgroup is special on cgroup v2 as it
108108
* carries only very few attributes in order not to export multiple truth about system state as most
109109
* information is available elsewhere in /proc anyway. We need to be able to deal with that, and need to get
110110
* our data from different sources in that case.

0 commit comments

Comments
 (0)