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).
This commit is contained in:
@@ -872,7 +872,7 @@ int cg_set_access(
|
||||
bool fatal;
|
||||
};
|
||||
|
||||
/* cgroupsv1, aka legacy/non-unified */
|
||||
/* cgroup v1, aka legacy/non-unified */
|
||||
static const struct Attribute legacy_attributes[] = {
|
||||
{ "cgroup.procs", true },
|
||||
{ "tasks", false },
|
||||
@@ -880,7 +880,7 @@ int cg_set_access(
|
||||
{},
|
||||
};
|
||||
|
||||
/* cgroupsv2, aka unified */
|
||||
/* cgroup v2, aka unified */
|
||||
static const struct Attribute unified_attributes[] = {
|
||||
{ "cgroup.procs", true },
|
||||
{ "cgroup.subtree_control", true },
|
||||
@@ -2039,7 +2039,7 @@ int cg_get_keyed_attribute(
|
||||
char **v;
|
||||
int r;
|
||||
|
||||
/* Reads one or more fields of a cgroupsv2 keyed attribute file. The 'keys' parameter should be an strv with
|
||||
/* Reads one or more fields of a cgroup v2 keyed attribute file. The 'keys' parameter should be an strv with
|
||||
* all keys to retrieve. The 'ret_values' parameter should be passed as string size with the same number of
|
||||
* entries as 'keys'. On success each entry will be set to the value of the matching key.
|
||||
*
|
||||
@@ -2491,7 +2491,7 @@ int cg_kernel_controllers(Set **ret) {
|
||||
|
||||
static thread_local CGroupUnified unified_cache = CGROUP_UNIFIED_UNKNOWN;
|
||||
|
||||
/* The hybrid mode was initially implemented in v232 and simply mounted cgroup v2 on /sys/fs/cgroup/systemd. This
|
||||
/* The hybrid mode was initially implemented in v232 and simply mounted cgroup2 on /sys/fs/cgroup/systemd. This
|
||||
* unfortunately broke other tools (such as docker) which expected the v1 "name=systemd" hierarchy on
|
||||
* /sys/fs/cgroup/systemd. From v233 and on, the hybrid mode mountnbs v2 on /sys/fs/cgroup/unified and maintains
|
||||
* "name=systemd" hierarchy on /sys/fs/cgroup/systemd for compatibility with other tools.
|
||||
@@ -2739,13 +2739,13 @@ bool cg_is_legacy_wanted(void) {
|
||||
if (wanted >= 0)
|
||||
return wanted;
|
||||
|
||||
/* Check if we have cgroups2 already mounted. */
|
||||
/* Check if we have cgroup v2 already mounted. */
|
||||
if (cg_unified_flush() >= 0 &&
|
||||
unified_cache == CGROUP_UNIFIED_ALL)
|
||||
return (wanted = false);
|
||||
|
||||
/* Otherwise, assume that at least partial legacy is wanted,
|
||||
* since cgroups2 should already be mounted at this point. */
|
||||
* since cgroup v2 should already be mounted at this point. */
|
||||
return (wanted = true);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,13 +48,13 @@ typedef enum CGroupMask {
|
||||
CGROUP_MASK_BPF_FIREWALL = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BPF_FIREWALL),
|
||||
CGROUP_MASK_BPF_DEVICES = CGROUP_CONTROLLER_TO_MASK(CGROUP_CONTROLLER_BPF_DEVICES),
|
||||
|
||||
/* All real cgroupv1 controllers */
|
||||
/* All real cgroup v1 controllers */
|
||||
CGROUP_MASK_V1 = CGROUP_MASK_CPU|CGROUP_MASK_CPUACCT|CGROUP_MASK_BLKIO|CGROUP_MASK_MEMORY|CGROUP_MASK_DEVICES|CGROUP_MASK_PIDS,
|
||||
|
||||
/* All real cgroupv2 controllers */
|
||||
/* All real cgroup v2 controllers */
|
||||
CGROUP_MASK_V2 = CGROUP_MASK_CPU|CGROUP_MASK_IO|CGROUP_MASK_MEMORY|CGROUP_MASK_PIDS,
|
||||
|
||||
/* All cgroupv2 BPF pseudo-controllers */
|
||||
/* All cgroup v2 BPF pseudo-controllers */
|
||||
CGROUP_MASK_BPF = CGROUP_MASK_BPF_FIREWALL|CGROUP_MASK_BPF_DEVICES,
|
||||
|
||||
_CGROUP_MASK_ALL = CGROUP_CONTROLLER_TO_MASK(_CGROUP_CONTROLLER_MAX) - 1
|
||||
|
||||
+1
-1
@@ -104,7 +104,7 @@ static const char *maybe_format_bytes(char *buf, size_t l, bool is_valid, uint64
|
||||
|
||||
static bool is_root_cgroup(const char *path) {
|
||||
|
||||
/* Returns true if the specified path belongs to the root cgroup. The root cgroup is special on cgroupsv2 as it
|
||||
/* Returns true if the specified path belongs to the root cgroup. The root cgroup is special on cgroup v2 as it
|
||||
* carries only very few attributes in order not to export multiple truth about system state as most
|
||||
* information is available elsewhere in /proc anyway. We need to be able to deal with that, and need to get
|
||||
* our data from different sources in that case.
|
||||
|
||||
+9
-9
@@ -881,7 +881,7 @@ static void cgroup_context_apply(
|
||||
/* In fully unified mode these attributes don't exist on the host cgroup root. On legacy the weights exist, but
|
||||
* setting the weight makes very little sense on the host root cgroup, as there are no other cgroups at this
|
||||
* level. The quota exists there too, but any attempt to write to it is refused with EINVAL. Inside of
|
||||
* containers we want to leave control of these to the container manager (and if cgroupsv2 delegation is used
|
||||
* containers we want to leave control of these to the container manager (and if cgroup v2 delegation is used
|
||||
* we couldn't even write to them if we wanted to). */
|
||||
if ((apply_mask & CGROUP_MASK_CPU) && !is_local_root) {
|
||||
|
||||
@@ -925,7 +925,7 @@ static void cgroup_context_apply(
|
||||
}
|
||||
}
|
||||
|
||||
/* The 'io' controller attributes are not exported on the host's root cgroup (being a pure cgroupsv2
|
||||
/* The 'io' controller attributes are not exported on the host's root cgroup (being a pure cgroup v2
|
||||
* controller), and in case of containers we want to leave control of these attributes to the container manager
|
||||
* (and we couldn't access that stuff anyway, even if we tried if proper delegation is used). */
|
||||
if ((apply_mask & CGROUP_MASK_IO) && !is_local_root) {
|
||||
@@ -1067,7 +1067,7 @@ static void cgroup_context_apply(
|
||||
|
||||
/* In unified mode 'memory' attributes do not exist on the root cgroup. In legacy mode 'memory.limit_in_bytes'
|
||||
* exists on the root cgroup, but any writes to it are refused with EINVAL. And if we run in a container we
|
||||
* want to leave control to the container manager (and if proper cgroupsv2 delegation is used we couldn't even
|
||||
* want to leave control to the container manager (and if proper cgroup v2 delegation is used we couldn't even
|
||||
* write to this if we wanted to.) */
|
||||
if ((apply_mask & CGROUP_MASK_MEMORY) && !is_local_root) {
|
||||
|
||||
@@ -1109,7 +1109,7 @@ static void cgroup_context_apply(
|
||||
}
|
||||
}
|
||||
|
||||
/* On cgroupsv2 we can apply BPF everywhere. On cgroupsv1 we apply it everywhere except for the root of
|
||||
/* On cgroup v2 we can apply BPF everywhere. On cgroup v1 we apply it everywhere except for the root of
|
||||
* containers, where we leave this to the manager */
|
||||
if ((apply_mask & (CGROUP_MASK_DEVICES | CGROUP_MASK_BPF_DEVICES)) &&
|
||||
(is_host_root || cg_all_unified() > 0 || !is_local_root)) {
|
||||
@@ -1841,14 +1841,14 @@ static bool unit_has_mask_realized(
|
||||
/* Returns true if this unit is fully realized. We check four things:
|
||||
*
|
||||
* 1. Whether the cgroup was created at all
|
||||
* 2. Whether the cgroup was created in all the hierarchies we need it to be created in (in case of cgroupsv1)
|
||||
* 3. Whether the cgroup has all the right controllers enabled (in case of cgroupsv2)
|
||||
* 2. Whether the cgroup was created in all the hierarchies we need it to be created in (in case of cgroup v1)
|
||||
* 3. Whether the cgroup has all the right controllers enabled (in case of cgroup v2)
|
||||
* 4. Whether the invalidation mask is currently zero
|
||||
*
|
||||
* If you wonder why we mask the target realization and enable mask with CGROUP_MASK_V1/CGROUP_MASK_V2: note
|
||||
* that there are three sets of bitmasks: CGROUP_MASK_V1 (for real cgroupv1 controllers), CGROUP_MASK_V2 (for
|
||||
* real cgroupv2 controllers) and CGROUP_MASK_BPF (for BPF-based pseudo-controllers). Now, cgroup_realized_mask
|
||||
* is only matters for cgroupsv1 controllers, and cgroup_enabled_mask only used for cgroupsv2, and if they
|
||||
* that there are three sets of bitmasks: CGROUP_MASK_V1 (for real cgroup v1 controllers), CGROUP_MASK_V2 (for
|
||||
* real cgroup v2 controllers) and CGROUP_MASK_BPF (for BPF-based pseudo-controllers). Now, cgroup_realized_mask
|
||||
* is only matters for cgroup v1 controllers, and cgroup_enabled_mask only used for cgroup v2, and if they
|
||||
* differ in the others, we don't really care. (After all, the cgroup_enabled_mask tracks with controllers are
|
||||
* enabled through cgroup.subtree_control, and since the BPF pseudo-controllers don't show up there, they
|
||||
* simply don't matter. */
|
||||
|
||||
+2
-2
@@ -3137,9 +3137,9 @@ static int exec_child(
|
||||
}
|
||||
}
|
||||
|
||||
/* If delegation is enabled we'll pass ownership of the cgroup to the user of the new process. On cgroupsv1
|
||||
/* If delegation is enabled we'll pass ownership of the cgroup to the user of the new process. On cgroup v1
|
||||
* this is only about systemd's own hierarchy, i.e. not the controller hierarchies, simply because that's not
|
||||
* safe. On cgroupsv2 there's only one hierarchy anyway, and delegation is safe there, hence in that case only
|
||||
* safe. On cgroup v2 there's only one hierarchy anyway, and delegation is safe there, hence in that case only
|
||||
* touch a single hierarchy too. */
|
||||
if (params->cgroup_path && context->user && (params->flags & EXEC_CGROUP_DELEGATE)) {
|
||||
r = cg_set_access(SYSTEMD_CGROUP_CONTROLLER, params->cgroup_path, uid, gid);
|
||||
|
||||
+2
-2
@@ -248,8 +248,8 @@ typedef struct Unit {
|
||||
|
||||
/* Counterparts in the cgroup filesystem */
|
||||
char *cgroup_path;
|
||||
CGroupMask cgroup_realized_mask; /* In which hierarchies does this unit's cgroup exist? (only relevant on cgroupsv1) */
|
||||
CGroupMask cgroup_enabled_mask; /* Which controllers are enabled (or more correctly: enabled for the children) for this unit's cgroup? (only relevant on cgroupsv2) */
|
||||
CGroupMask cgroup_realized_mask; /* In which hierarchies does this unit's cgroup exist? (only relevant on cgroup v1) */
|
||||
CGroupMask cgroup_enabled_mask; /* Which controllers are enabled (or more correctly: enabled for the children) for this unit's cgroup? (only relevant on cgroup v2) */
|
||||
CGroupMask cgroup_invalidated_mask; /* A mask specifiying controllers which shall be considered invalidated, and require re-realization */
|
||||
CGroupMask cgroup_members_mask; /* A cache for the controllers required by all children of this cgroup (only relevant for slice units) */
|
||||
int cgroup_inotify_wd;
|
||||
|
||||
@@ -257,7 +257,7 @@ static int client_context_read_cgroup(Server *s, ClientContext *c, const char *u
|
||||
|
||||
/* We use the unit ID passed in as fallback if we have nothing cached yet and cg_pid_get_path_shifted()
|
||||
* failed or process is running in a root cgroup. Zombie processes are automatically migrated to root cgroup
|
||||
* on cgroupsv1 and we want to be able to map log messages from them too. */
|
||||
* on cgroup v1 and we want to be able to map log messages from them too. */
|
||||
if (unit_id && !c->unit) {
|
||||
c->unit = strdup(unit_id);
|
||||
if (c->unit)
|
||||
|
||||
Reference in New Issue
Block a user