HALF ECHO LEARN / REFERENCE COLLECTION
v262.2src/core/cgroup.c
Git blob: 543d1ac8e3c43a5af0861e2f1a038485663554eb
Lines 4001–4696 of 4,696
return true;
}
void unit_invalidate_cgroup_bpf_firewall(Unit *u) {
assert(u);
if (!unit_invalidate_cgroup(u, CGROUP_MASK_BPF_FIREWALL))
return;
/* If we are a slice unit, we also need to put compile a new BPF program for all our children, as the IP access
* list of our children includes our own. */
if (u->type == UNIT_SLICE) {
Unit *member;
UNIT_FOREACH_DEPENDENCY(member, u, UNIT_ATOM_SLICE_OF)
unit_invalidate_cgroup_bpf_firewall(member);
}
}
void unit_cgroup_catchup(Unit *u) {
assert(u);
if (!UNIT_HAS_CGROUP_CONTEXT(u))
return;
/* We dropped the inotify watch during reexec/reload, so we need to
* check these as they may have changed.
* Note that (currently) the kernel doesn't actually update cgroup
* file modification times, so we can't just serialize and then check
* the mtime for file(s) we are interested in. */
(void) unit_check_cgroup_events(u);
unit_add_to_cgroup_oom_queue(u);
}
bool unit_cgroup_delegate(Unit *u) {
CGroupContext *c;
assert(u);
if (!UNIT_VTABLE(u)->can_delegate)
return false;
c = unit_get_cgroup_context(u);
if (!c)
return false;
return c->delegate;
}
void unit_cgroup_disable_all_controllers(Unit *u) {
int r;
assert(u);
CGroupRuntime *crt = unit_get_cgroup_runtime(u);
if (!crt || !crt->cgroup_path)
return;
if (!unit_cgroup_delegate(u))
return;
/* For delegated units, the previous payload may have enabled controllers (e.g. "pids") in
* cgroup.subtree_control. These persist after the service stops and turn the cgroup into an
* "internal node", causing clone3(CLONE_INTO_CGROUP) to fail with EBUSY. Clear them now, right
* before the new start, so that resource control is preserved for lingering processes as long as
* possible. Ignore errors — if sub-cgroups still have live processes the write will fail, but so
* will the upcoming spawn. */
r = cg_enable(u->manager->cgroup_supported, /* mask= */ 0, crt->cgroup_path, &crt->cgroup_enabled_mask);
if (r < 0)
log_unit_debug_errno(u, r, "Failed to disable controllers on cgroup %s, ignoring: %m", empty_to_root(crt->cgroup_path));
}
void manager_invalidate_startup_units(Manager *m) {
Unit *u;
assert(m);
SET_FOREACH(u, m->startup_units)
unit_invalidate_cgroup(u, CGROUP_MASK_CPU|CGROUP_MASK_IO|CGROUP_MASK_CPUSET);
}
static int unit_cgroup_freezer_kernel_state(Unit *u, FreezerState *ret) {
_cleanup_free_ char *val = NULL;
FreezerState s;
int r;
assert(u);
assert(ret);
CGroupRuntime *crt = unit_get_cgroup_runtime(u);
if (!crt || !crt->cgroup_path)
return -EOWNERDEAD;
r = cg_get_keyed_attribute(
crt->cgroup_path,
"cgroup.events",
STRV_MAKE("frozen"),
&val);
if (r < 0)
return r;
if (streq(val, "0"))
s = FREEZER_RUNNING;
else if (streq(val, "1"))
s = FREEZER_FROZEN;
else {
log_unit_debug(u, "Unexpected cgroup frozen state: %s", val);
s = _FREEZER_STATE_INVALID;
}
*ret = s;
return 0;
}
int unit_cgroup_freezer_action(Unit *u, FreezerAction action) {
_cleanup_free_ char *path = NULL;
FreezerState current, next, objective;
bool action_in_progress = false;
int r;
assert(u);
assert(action >= 0);
assert(action < _FREEZER_ACTION_MAX);
unit_next_freezer_state(u, action, &next, &objective);
CGroupRuntime *crt = unit_get_cgroup_runtime(u);
if (!crt || !crt->cgroup_path)
/* No realized cgroup = nothing to freeze */
goto finish;
r = unit_cgroup_freezer_kernel_state(u, ¤t);
if (r < 0)
return r;
if (current == objective) {
if (objective == FREEZER_FROZEN)
goto finish;
/* Skip thaw only if no freeze operation was in flight */
if (IN_SET(u->freezer_state, FREEZER_RUNNING, FREEZER_THAWING))
goto finish;
} else
action_in_progress = true;
if (next == freezer_state_finish(next)) {
/* We're directly transitioning into a finished state, which in theory means that
* the cgroup's current state already matches the objective and thus we'd return 0.
* But, reality shows otherwise (such case would have been handled by current == objective
* branch above). This indicates that our freezer_state tracking has diverged
* from the real state of the cgroup, which can happen if someone meddles with the
* cgroup from underneath us. This really shouldn't happen during normal operation,
* though. So, let's warn about it and fix up the state to be valid */
log_unit_warning(u, "Unit wants to transition to %s freezer state but cgroup is unexpectedly %s, fixing up.",
freezer_state_to_string(next), freezer_state_to_string(current) ?: "(invalid)");
if (next == FREEZER_FROZEN)
next = FREEZER_FREEZING;
else if (next == FREEZER_FROZEN_BY_PARENT)
next = FREEZER_FREEZING_BY_PARENT;
else if (next == FREEZER_RUNNING)
next = FREEZER_THAWING;
else
assert_not_reached();
}
r = cg_get_path(crt->cgroup_path, "cgroup.freeze", &path);
if (r < 0)
return r;
r = write_string_file(path, one_zero(objective == FREEZER_FROZEN), WRITE_STRING_FILE_DISABLE_BUFFER);
if (r < 0)
return r;
finish:
if (action_in_progress)
unit_set_freezer_state(u, next);
else
unit_set_freezer_state(u, freezer_state_finish(next));
return action_in_progress;
}
int unit_get_cpuset(Unit *u, CPUSet *cpus, const char *name) {
_cleanup_free_ char *v = NULL;
int r;
assert(u);
assert(cpus);
CGroupRuntime *crt = unit_get_cgroup_runtime(u);
if (!crt || !crt->cgroup_path)
return -ENODATA;
if ((crt->cgroup_realized_mask & CGROUP_MASK_CPUSET) == 0)
return -ENODATA;
r = cg_get_attribute(crt->cgroup_path, name, &v);
if (r == -ENOENT)
return -ENODATA;
if (r < 0)
return r;
return parse_cpu_set(v, cpus);
}
CGroupRuntime* cgroup_runtime_new(void) {
_cleanup_(cgroup_runtime_freep) CGroupRuntime *crt = NULL;
crt = new(CGroupRuntime, 1);
if (!crt)
return NULL;
*crt = (CGroupRuntime) {
.cgroup_control_inotify_wd = -1,
.cgroup_memory_inotify_wd = -1,
.ip_accounting_ingress_map_fd = -EBADF,
.ip_accounting_egress_map_fd = -EBADF,
.ipv4_allow_map_fd = -EBADF,
.ipv6_allow_map_fd = -EBADF,
.ipv4_deny_map_fd = -EBADF,
.ipv6_deny_map_fd = -EBADF,
.initial_bind_network_interface_link_fd = -EBADF,
.cgroup_invalidated_mask = _CGROUP_MASK_ALL,
.deserialized_cgroup_realized = -1,
};
unit_reset_cpu_accounting(/* unit= */ NULL, crt);
unit_reset_io_accounting(/* unit= */ NULL, crt);
cgroup_runtime_reset_memory_accounting_last(crt);
assert_se(cgroup_runtime_reset_ip_accounting(crt) >= 0);
return TAKE_PTR(crt);
}
CGroupRuntime* cgroup_runtime_free(CGroupRuntime *crt) {
if (!crt)
return NULL;
fdset_free(crt->initial_socket_bind_link_fds);
#if BPF_FRAMEWORK
bpf_link_free(crt->ipv4_socket_bind_link);
bpf_link_free(crt->ipv6_socket_bind_link);
#endif
hashmap_free(crt->bpf_foreign_by_key);
bpf_program_free(crt->bpf_device_control_installed);
#if BPF_FRAMEWORK
bpf_link_free(crt->restrict_ifaces_ingress_bpf_link);
bpf_link_free(crt->restrict_ifaces_egress_bpf_link);
bpf_link_free(crt->bpf_bind_network_interface_link);
#endif
fdset_free(crt->initial_restrict_ifaces_link_fds);
safe_close(crt->initial_bind_network_interface_link_fd);
bpf_firewall_close(crt);
free(crt->cgroup_path);
return mfree(crt);
}
static const char* const ip_accounting_metric_field_table[_CGROUP_IP_ACCOUNTING_METRIC_MAX] = {
[CGROUP_IP_INGRESS_BYTES] = "ip-accounting-ingress-bytes",
[CGROUP_IP_INGRESS_PACKETS] = "ip-accounting-ingress-packets",
[CGROUP_IP_EGRESS_BYTES] = "ip-accounting-egress-bytes",
[CGROUP_IP_EGRESS_PACKETS] = "ip-accounting-egress-packets",
};
DEFINE_PRIVATE_STRING_TABLE_LOOKUP(ip_accounting_metric_field, CGroupIPAccountingMetric);
static const char* const io_accounting_metric_field_base_table[_CGROUP_IO_ACCOUNTING_METRIC_MAX] = {
[CGROUP_IO_READ_BYTES] = "io-accounting-read-bytes-base",
[CGROUP_IO_WRITE_BYTES] = "io-accounting-write-bytes-base",
[CGROUP_IO_READ_OPERATIONS] = "io-accounting-read-operations-base",
[CGROUP_IO_WRITE_OPERATIONS] = "io-accounting-write-operations-base",
};
DEFINE_PRIVATE_STRING_TABLE_LOOKUP(io_accounting_metric_field_base, CGroupIOAccountingMetric);
static const char* const io_accounting_metric_field_last_table[_CGROUP_IO_ACCOUNTING_METRIC_MAX] = {
[CGROUP_IO_READ_BYTES] = "io-accounting-read-bytes-last",
[CGROUP_IO_WRITE_BYTES] = "io-accounting-write-bytes-last",
[CGROUP_IO_READ_OPERATIONS] = "io-accounting-read-operations-last",
[CGROUP_IO_WRITE_OPERATIONS] = "io-accounting-write-operations-last",
};
DEFINE_PRIVATE_STRING_TABLE_LOOKUP(io_accounting_metric_field_last, CGroupIOAccountingMetric);
static const char* const memory_accounting_metric_field_last_table[_CGROUP_MEMORY_ACCOUNTING_METRIC_CACHED_LAST + 1] = {
[CGROUP_MEMORY_PEAK] = "memory-accounting-peak",
[CGROUP_MEMORY_SWAP_PEAK] = "memory-accounting-swap-peak",
};
DEFINE_PRIVATE_STRING_TABLE_LOOKUP(memory_accounting_metric_field_last, CGroupMemoryAccountingMetric);
static int serialize_cgroup_mask(FILE *f, const char *key, CGroupMask mask) {
_cleanup_free_ char *s = NULL;
int r;
assert(f);
assert(key);
if (mask == 0)
return 0;
r = cg_mask_to_string(mask, &s);
if (r < 0)
return log_error_errno(r, "Failed to format cgroup mask: %m");
return serialize_item(f, key, s);
}
int cgroup_runtime_serialize(Unit *u, FILE *f, FDSet *fds) {
int r;
assert(u);
assert(f);
assert(fds);
CGroupRuntime *crt = unit_get_cgroup_runtime(u);
if (!crt)
return 0;
if (crt->cgroup_path)
(void) serialize_item(f, "cgroup", crt->cgroup_path);
if (crt->cgroup_id != 0)
(void) serialize_item_format(f, "cgroup-id", "%" PRIu64, crt->cgroup_id);
(void) serialize_cgroup_mask(f, "cgroup-realized-mask", crt->cgroup_realized_mask);
(void) serialize_cgroup_mask(f, "cgroup-enabled-mask", crt->cgroup_enabled_mask);
(void) serialize_cgroup_mask(f, "cgroup-invalidated-mask", crt->cgroup_invalidated_mask);
(void) serialize_item_format(f, "cpu-usage-base", "%" PRIu64, crt->cpu_usage_base);
if (crt->cpu_usage_last != NSEC_INFINITY)
(void) serialize_item_format(f, "cpu-usage-last", "%" PRIu64, crt->cpu_usage_last);
if (crt->managed_oom_kill_last > 0)
(void) serialize_item_format(f, "managed-oom-kill-last", "%" PRIu64, crt->managed_oom_kill_last);
if (crt->oom_kill_last > 0)
(void) serialize_item_format(f, "oom-kill-last", "%" PRIu64, crt->oom_kill_last);
for (CGroupMemoryAccountingMetric metric = 0; metric <= _CGROUP_MEMORY_ACCOUNTING_METRIC_CACHED_LAST; metric++) {
uint64_t v;
r = unit_get_memory_accounting(u, metric, &v);
if (r >= 0)
(void) serialize_item_format(f, memory_accounting_metric_field_last_to_string(metric), "%" PRIu64, v);
}
for (CGroupIPAccountingMetric m = 0; m < _CGROUP_IP_ACCOUNTING_METRIC_MAX; m++) {
uint64_t v;
r = unit_get_ip_accounting(u, m, &v);
if (r >= 0)
(void) serialize_item_format(f, ip_accounting_metric_field_to_string(m), "%" PRIu64, v);
}
for (CGroupIOAccountingMetric im = 0; im < _CGROUP_IO_ACCOUNTING_METRIC_MAX; im++) {
(void) serialize_item_format(f, io_accounting_metric_field_base_to_string(im), "%" PRIu64, crt->io_accounting_base[im]);
if (crt->io_accounting_last[im] != UINT64_MAX)
(void) serialize_item_format(f, io_accounting_metric_field_last_to_string(im), "%" PRIu64, crt->io_accounting_last[im]);
}
(void) bpf_socket_bind_serialize(u, f, fds);
(void) bpf_program_serialize_attachment(f, fds, "ip-bpf-ingress-installed", crt->ip_bpf_ingress_installed);
(void) bpf_program_serialize_attachment(f, fds, "ip-bpf-egress-installed", crt->ip_bpf_egress_installed);
(void) bpf_program_serialize_attachment(f, fds, "bpf-device-control-installed", crt->bpf_device_control_installed);
(void) bpf_program_serialize_attachment_set(f, fds, "ip-bpf-custom-ingress-installed", crt->ip_bpf_custom_ingress_installed);
(void) bpf_program_serialize_attachment_set(f, fds, "ip-bpf-custom-egress-installed", crt->ip_bpf_custom_egress_installed);
(void) bpf_restrict_ifaces_serialize(u, f, fds);
(void) bpf_bind_network_interface_serialize(u, f, fds);
return 0;
}
#define MATCH_DESERIALIZE(u, key, l, v, parse_func, target) \
({ \
bool _deserialize_matched = streq(l, key); \
if (_deserialize_matched) { \
CGroupRuntime *crt = unit_setup_cgroup_runtime(u); \
if (!crt) \
log_oom_debug(); \
else { \
int _deserialize_r = parse_func(v); \
if (_deserialize_r < 0) \
log_unit_debug_errno(u, _deserialize_r, \
"Failed to parse \"%s=%s\", ignoring.", l, v); \
else \
crt->target = _deserialize_r; \
} \
} \
_deserialize_matched; \
})
#define MATCH_DESERIALIZE_IMMEDIATE(u, key, l, v, parse_func, target) \
({ \
bool _deserialize_matched = streq(l, key); \
if (_deserialize_matched) { \
CGroupRuntime *crt = unit_setup_cgroup_runtime(u); \
if (!crt) \
log_oom_debug(); \
else { \
int _deserialize_r = parse_func(v, &crt->target); \
if (_deserialize_r < 0) \
log_unit_debug_errno(u, _deserialize_r, \
"Failed to parse \"%s=%s\", ignoring", l, v); \
} \
} \
_deserialize_matched; \
})
#define MATCH_DESERIALIZE_METRIC(u, key, l, v, parse_func, target) \
({ \
bool _deserialize_matched = streq(l, key); \
if (_deserialize_matched) { \
CGroupRuntime *crt = unit_setup_cgroup_runtime(u); \
if (!crt) \
log_oom_debug(); \
else { \
int _deserialize_r = parse_func(v); \
if (_deserialize_r < 0) \
log_unit_debug_errno(u, _deserialize_r, \
"Failed to parse \"%s=%s\", ignoring.", l, v); \
else \
crt->target = _deserialize_r; \
} \
} \
_deserialize_matched; \
})
int cgroup_runtime_deserialize_one(Unit *u, const char *key, const char *value, FDSet *fds) {
int r;
assert(u);
assert(value);
if (!UNIT_HAS_CGROUP_CONTEXT(u))
return 0;
if (MATCH_DESERIALIZE_IMMEDIATE(u, "cpu-usage-base", key, value, safe_atou64, cpu_usage_base))
return 1;
if (MATCH_DESERIALIZE_IMMEDIATE(u, "cpu-usage-last", key, value, safe_atou64, cpu_usage_last))
return 1;
if (MATCH_DESERIALIZE_IMMEDIATE(u, "managed-oom-kill-last", key, value, safe_atou64, managed_oom_kill_last))
return 1;
if (MATCH_DESERIALIZE_IMMEDIATE(u, "oom-kill-last", key, value, safe_atou64, oom_kill_last))
return 1;
if (streq(key, "cgroup")) {
r = unit_set_cgroup_path(u, value);
if (r < 0)
log_unit_debug_errno(u, r, "Failed to set cgroup path %s, ignoring: %m", value);
return 1;
}
if (MATCH_DESERIALIZE_IMMEDIATE(u, "cgroup-id", key, value, safe_atou64, cgroup_id))
return 1;
if (MATCH_DESERIALIZE_IMMEDIATE(u, "cgroup-realized", key, value, parse_tristate, deserialized_cgroup_realized))
return 1;
if (MATCH_DESERIALIZE_IMMEDIATE(u, "cgroup-realized-mask", key, value, cg_mask_from_string, cgroup_realized_mask))
return 1;
if (MATCH_DESERIALIZE_IMMEDIATE(u, "cgroup-enabled-mask", key, value, cg_mask_from_string, cgroup_enabled_mask))
return 1;
if (MATCH_DESERIALIZE_IMMEDIATE(u, "cgroup-invalidated-mask", key, value, cg_mask_from_string, cgroup_invalidated_mask))
return 1;
if (STR_IN_SET(key,
"bpf-device-control-installed",
"ip-bpf-ingress-installed", "ip-bpf-egress-installed",
"ip-bpf-custom-ingress-installed", "ip-bpf-custom-egress-installed")) {
CGroupRuntime *crt = unit_setup_cgroup_runtime(u);
if (!crt)
log_oom_debug();
else {
if (streq(key, "bpf-device-control-installed"))
(void) bpf_program_deserialize_attachment(value, fds, &crt->bpf_device_control_installed);
if (streq(key, "ip-bpf-ingress-installed"))
(void) bpf_program_deserialize_attachment(value, fds, &crt->ip_bpf_ingress_installed);
if (streq(key, "ip-bpf-egress-installed"))
(void) bpf_program_deserialize_attachment(value, fds, &crt->ip_bpf_egress_installed);
if (streq(key, "ip-bpf-custom-ingress-installed"))
(void) bpf_program_deserialize_attachment_set(value, fds, &crt->ip_bpf_custom_ingress_installed);
if (streq(key, "ip-bpf-custom-egress-installed"))
(void) bpf_program_deserialize_attachment_set(value, fds, &crt->ip_bpf_custom_egress_installed);
}
return 1;
}
/* We keep the previous bpf link fds stashed until we reattach anew, to close the window where
* the cgroup restrictions would otherwise be lifted. */
if (STR_IN_SET(key, "ipv4-socket-bind-bpf-link-fd", "ipv6-socket-bind-bpf-link-fd")) {
_cleanup_close_ int fd = -EBADF;
fd = deserialize_fd(fds, value);
if (fd >= 0) {
r = bpf_socket_bind_add_initial_link_fd(u, fd);
if (r >= 0)
TAKE_FD(fd);
}
return 1;
}
if (streq(key, "restrict-ifaces-bpf-fd")) {
_cleanup_close_ int fd = -EBADF;
fd = deserialize_fd(fds, value);
if (fd >= 0) {
r = bpf_restrict_ifaces_add_initial_link_fd(u, fd);
if (r >= 0)
TAKE_FD(fd);
}
return 1;
}
if (streq(key, "bind-iface-bpf-fd")) {
_cleanup_close_ int fd = -EBADF;
fd = deserialize_fd(fds, value);
if (fd >= 0) {
CGroupRuntime *crt = unit_setup_cgroup_runtime(u);
if (!crt)
log_oom_debug();
else
close_and_replace(crt->initial_bind_network_interface_link_fd, fd);
}
return 1;
}
CGroupMemoryAccountingMetric mm = memory_accounting_metric_field_last_from_string(key);
if (mm >= 0) {
uint64_t c;
r = safe_atou64(value, &c);
if (r < 0)
log_unit_debug(u, "Failed to parse memory accounting last value %s, ignoring.", value);
else {
CGroupRuntime *crt = unit_setup_cgroup_runtime(u);
if (!crt)
log_oom_debug();
else
crt->memory_accounting_last[mm] = c;
}
return 1;
}
CGroupIPAccountingMetric ipm = ip_accounting_metric_field_from_string(key);
if (ipm >= 0) {
uint64_t c;
r = safe_atou64(value, &c);
if (r < 0)
log_unit_debug(u, "Failed to parse IP accounting value %s, ignoring.", value);
else {
CGroupRuntime *crt = unit_setup_cgroup_runtime(u);
if (!crt)
log_oom_debug();
else
crt->ip_accounting_extra[ipm] = c;
}
return 1;
}
CGroupIOAccountingMetric iom = io_accounting_metric_field_base_from_string(key);
if (iom >= 0) {
uint64_t c;
r = safe_atou64(value, &c);
if (r < 0)
log_unit_debug(u, "Failed to parse IO accounting base value %s, ignoring.", value);
else {
CGroupRuntime *crt = unit_setup_cgroup_runtime(u);
if (!crt)
log_oom_debug();
else
crt->io_accounting_base[iom] = c;
}
return 1;
}
iom = io_accounting_metric_field_last_from_string(key);
if (iom >= 0) {
uint64_t c;
r = safe_atou64(value, &c);
if (r < 0)
log_unit_debug(u, "Failed to parse IO accounting last value %s, ignoring.", value);
else {
CGroupRuntime *crt = unit_setup_cgroup_runtime(u);
if (!crt)
log_oom_debug();
else
crt->io_accounting_last[iom] = c;
}
return 1;
}
return 0;
}
static const char* const cgroup_device_policy_table[_CGROUP_DEVICE_POLICY_MAX] = {
[CGROUP_DEVICE_POLICY_AUTO] = "auto",
[CGROUP_DEVICE_POLICY_CLOSED] = "closed",
[CGROUP_DEVICE_POLICY_STRICT] = "strict",
};
DEFINE_STRING_TABLE_LOOKUP(cgroup_device_policy, CGroupDevicePolicy);
static const char* const cpuset_partition_table[_CPUSET_PARTITION_MAX] = {
[CPUSET_PARTITION_MEMBER] = "member",
[CPUSET_PARTITION_ROOT] = "root",
[CPUSET_PARTITION_ISOLATED] = "isolated",
};
DEFINE_STRING_TABLE_LOOKUP(cpuset_partition, CPUSetPartition);
static const char* const cgroup_pressure_watch_table[_CGROUP_PRESSURE_WATCH_MAX] = {
[CGROUP_PRESSURE_WATCH_NO] = "no",
[CGROUP_PRESSURE_WATCH_YES] = "yes",
[CGROUP_PRESSURE_WATCH_AUTO] = "auto",
[CGROUP_PRESSURE_WATCH_SKIP] = "skip",
};
DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(cgroup_pressure_watch, CGroupPressureWatch, CGROUP_PRESSURE_WATCH_YES);
static const char* const cgroup_ip_accounting_metric_table[_CGROUP_IP_ACCOUNTING_METRIC_MAX] = {
[CGROUP_IP_INGRESS_BYTES] = "IPIngressBytes",
[CGROUP_IP_EGRESS_BYTES] = "IPEgressBytes",
[CGROUP_IP_INGRESS_PACKETS] = "IPIngressPackets",
[CGROUP_IP_EGRESS_PACKETS] = "IPEgressPackets",
};
DEFINE_STRING_TABLE_LOOKUP(cgroup_ip_accounting_metric, CGroupIPAccountingMetric);
static const char* const cgroup_io_accounting_metric_table[_CGROUP_IO_ACCOUNTING_METRIC_MAX] = {
[CGROUP_IO_READ_BYTES] = "IOReadBytes",
[CGROUP_IO_WRITE_BYTES] = "IOWriteBytes",
[CGROUP_IO_READ_OPERATIONS] = "IOReadOperations",
[CGROUP_IO_WRITE_OPERATIONS] = "IOWriteOperations",
};
DEFINE_STRING_TABLE_LOOKUP(cgroup_io_accounting_metric, CGroupIOAccountingMetric);
static const char* const cgroup_memory_accounting_metric_table[_CGROUP_MEMORY_ACCOUNTING_METRIC_MAX] = {
[CGROUP_MEMORY_CURRENT] = "MemoryCurrent",
[CGROUP_MEMORY_PEAK] = "MemoryPeak",
[CGROUP_MEMORY_SWAP_CURRENT] = "MemorySwapCurrent",
[CGROUP_MEMORY_SWAP_PEAK] = "MemorySwapPeak",
[CGROUP_MEMORY_ZSWAP_CURRENT] = "MemoryZSwapCurrent",
};
DEFINE_STRING_TABLE_LOOKUP(cgroup_memory_accounting_metric, CGroupMemoryAccountingMetric);
static const char *const cgroup_effective_limit_type_table[_CGROUP_LIMIT_TYPE_MAX] = {
[CGROUP_LIMIT_MEMORY_MAX] = "EffectiveMemoryMax",
[CGROUP_LIMIT_MEMORY_HIGH] = "EffectiveMemoryHigh",
[CGROUP_LIMIT_TASKS_MAX] = "EffectiveTasksMax",
};
DEFINE_STRING_TABLE_LOOKUP(cgroup_effective_limit_type, CGroupLimitType);