From: Lennart Poettering Date: Fri, 6 Oct 2023 16:13:16 +0000 (+0200) Subject: cgroup: rename TasksMax structure to CGroupTasksMax X-Git-Tag: v255-rc1~298^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=94f0b13b1623c083ece9c0381bd1e65500dc1363;p=thirdparty%2Fsystemd.git cgroup: rename TasksMax structure to CGroupTasksMax Almost all our enums/structs/funcs carry the CGroup prefix if they are defined in cgroup.h, TasksMax so far does not, even though it is exclusively used in cgroup context. Change that. --- diff --git a/src/core/cgroup.c b/src/core/cgroup.c index 29905b08ad4..56c90f0460c 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -52,7 +52,7 @@ * out specific attributes from us. */ #define LOG_LEVEL_CGROUP_WRITE(r) (IN_SET(abs(r), ENOENT, EROFS, EACCES, EPERM) ? LOG_DEBUG : LOG_WARNING) -uint64_t tasks_max_resolve(const TasksMax *tasks_max) { +uint64_t cgroup_tasks_max_resolve(const CGroupTasksMax *tasks_max) { if (tasks_max->scale == 0) return tasks_max->value; @@ -171,7 +171,7 @@ void cgroup_context_init(CGroupContext *c) { .blockio_weight = CGROUP_BLKIO_WEIGHT_INVALID, .startup_blockio_weight = CGROUP_BLKIO_WEIGHT_INVALID, - .tasks_max = TASKS_MAX_UNSET, + .tasks_max = CGROUP_TASKS_MAX_UNSET, .moom_swap = MANAGED_OOM_AUTO, .moom_mem_pressure = MANAGED_OOM_AUTO, @@ -561,7 +561,7 @@ void cgroup_context_dump(Unit *u, FILE* f, const char *prefix) { prefix, c->memory_zswap_max, format_cgroup_memory_limit_comparison(cdj, sizeof(cdj), u, "MemoryZSwapMax"), prefix, c->startup_memory_zswap_max, format_cgroup_memory_limit_comparison(cdk, sizeof(cdk), u, "StartupMemoryZSwapMax"), prefix, c->memory_limit, - prefix, tasks_max_resolve(&c->tasks_max), + prefix, cgroup_tasks_max_resolve(&c->tasks_max), prefix, cgroup_device_policy_to_string(c->device_policy), prefix, strempty(disable_controllers_str), prefix, delegate_str, @@ -1816,9 +1816,9 @@ static void cgroup_context_apply( * which is desirable so that there's an official way to release control of the sysctl from * systemd: set the limit to unbounded and reload. */ - if (tasks_max_isset(&c->tasks_max)) { + if (cgroup_tasks_max_isset(&c->tasks_max)) { u->manager->sysctl_pid_max_changed = true; - r = procfs_tasks_set_limit(tasks_max_resolve(&c->tasks_max)); + r = procfs_tasks_set_limit(cgroup_tasks_max_resolve(&c->tasks_max)); } else if (u->manager->sysctl_pid_max_changed) r = procfs_tasks_set_limit(TASKS_MAX); else @@ -1831,10 +1831,10 @@ static void cgroup_context_apply( /* The attribute itself is not available on the host root cgroup, and in the container case we want to * leave it for the container manager. */ if (!is_local_root) { - if (tasks_max_isset(&c->tasks_max)) { + if (cgroup_tasks_max_isset(&c->tasks_max)) { char buf[DECIMAL_STR_MAX(uint64_t) + 1]; - xsprintf(buf, "%" PRIu64 "\n", tasks_max_resolve(&c->tasks_max)); + xsprintf(buf, "%" PRIu64 "\n", cgroup_tasks_max_resolve(&c->tasks_max)); (void) set_attribute_and_warn(u, "pids", "pids.max", buf); } else (void) set_attribute_and_warn(u, "pids", "pids.max", "max\n"); @@ -1952,7 +1952,7 @@ static CGroupMask unit_get_cgroup_mask(Unit *u) { mask |= CGROUP_MASK_DEVICES | CGROUP_MASK_BPF_DEVICES; if (c->tasks_accounting || - tasks_max_isset(&c->tasks_max)) + cgroup_tasks_max_isset(&c->tasks_max)) mask |= CGROUP_MASK_PIDS; return CGROUP_MASK_EXTEND_JOINED(mask); diff --git a/src/core/cgroup.h b/src/core/cgroup.h index 05dfd482774..0d113a3de9b 100644 --- a/src/core/cgroup.h +++ b/src/core/cgroup.h @@ -11,20 +11,20 @@ #include "pidref.h" #include "time-util.h" -typedef struct TasksMax { +typedef struct CGroupTasksMax { /* If scale == 0, just use value; otherwise, value / scale. * See tasks_max_resolve(). */ uint64_t value; uint64_t scale; -} TasksMax; +} CGroupTasksMax; -#define TASKS_MAX_UNSET ((TasksMax) { .value = UINT64_MAX, .scale = 0 }) +#define CGROUP_TASKS_MAX_UNSET ((CGroupTasksMax) { .value = UINT64_MAX, .scale = 0 }) -static inline bool tasks_max_isset(const TasksMax *tasks_max) { +static inline bool cgroup_tasks_max_isset(const CGroupTasksMax *tasks_max) { return tasks_max->value != UINT64_MAX || tasks_max->scale != 0; } -uint64_t tasks_max_resolve(const TasksMax *tasks_max); +uint64_t cgroup_tasks_max_resolve(const CGroupTasksMax *tasks_max); typedef struct CGroupContext CGroupContext; typedef struct CGroupDeviceAllow CGroupDeviceAllow; @@ -212,7 +212,7 @@ struct CGroupContext { LIST_HEAD(CGroupSocketBindItem, socket_bind_deny); /* Common */ - TasksMax tasks_max; + CGroupTasksMax tasks_max; /* Settings for systemd-oomd */ ManagedOOMMode moom_swap; diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c index 5dd34d1c20e..32f93b8e8d8 100644 --- a/src/core/dbus-cgroup.c +++ b/src/core/dbus-cgroup.c @@ -27,7 +27,7 @@ #include "percent-util.h" #include "socket-util.h" -BUS_DEFINE_PROPERTY_GET(bus_property_get_tasks_max, "t", TasksMax, tasks_max_resolve); +BUS_DEFINE_PROPERTY_GET(bus_property_get_tasks_max, "t", CGroupTasksMax, cgroup_tasks_max_resolve); BUS_DEFINE_PROPERTY_GET_ENUM(bus_property_get_cgroup_pressure_watch, cgroup_pressure_watch, CGroupPressureWatch); static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_cgroup_device_policy, cgroup_device_policy, CGroupDevicePolicy); @@ -1025,7 +1025,7 @@ static int bus_cgroup_set_cpu_weight( static int bus_cgroup_set_tasks_max( Unit *u, const char *name, - TasksMax *p, + CGroupTasksMax *p, sd_bus_message *message, UnitWriteFlags flags, sd_bus_error *error) { @@ -1044,7 +1044,7 @@ static int bus_cgroup_set_tasks_max( "Value specified in %s is out of range", name); if (!UNIT_WRITE_FLAGS_NOOP(flags)) { - *p = (TasksMax) { .value = v, .scale = 0 }; /* When .scale==0, .value is the absolute value */ + *p = (CGroupTasksMax) { .value = v, .scale = 0 }; /* When .scale==0, .value is the absolute value */ unit_invalidate_cgroup(u, CGROUP_MASK_PIDS); if (v == CGROUP_LIMIT_MAX) @@ -1061,7 +1061,7 @@ static int bus_cgroup_set_tasks_max( static int bus_cgroup_set_tasks_max_scale( Unit *u, const char *name, - TasksMax *p, + CGroupTasksMax *p, sd_bus_message *message, UnitWriteFlags flags, sd_bus_error *error) { @@ -1080,7 +1080,7 @@ static int bus_cgroup_set_tasks_max_scale( "Value specified in %s is out of range", name); if (!UNIT_WRITE_FLAGS_NOOP(flags)) { - *p = (TasksMax) { v, UINT32_MAX }; /* .scale is not 0, so this is interpreted as v/UINT32_MAX. */ + *p = (CGroupTasksMax) { v, UINT32_MAX }; /* .scale is not 0, so this is interpreted as v/UINT32_MAX. */ unit_invalidate_cgroup(u, CGROUP_MASK_PIDS); uint32_t scaled = DIV_ROUND_UP((uint64_t) v * 100U, (uint64_t) UINT32_MAX); diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 935a4ef35da..1d230080bc8 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -3917,23 +3917,23 @@ int config_parse_tasks_max( void *userdata) { const Unit *u = userdata; - TasksMax *tasks_max = data; + CGroupTasksMax *tasks_max = data; uint64_t v; int r; if (isempty(rvalue)) { - *tasks_max = u ? u->manager->defaults.tasks_max : TASKS_MAX_UNSET; + *tasks_max = u ? u->manager->defaults.tasks_max : CGROUP_TASKS_MAX_UNSET; return 0; } if (streq(rvalue, "infinity")) { - *tasks_max = TASKS_MAX_UNSET; + *tasks_max = CGROUP_TASKS_MAX_UNSET; return 0; } r = parse_permyriad(rvalue); if (r >= 0) - *tasks_max = (TasksMax) { r, 10000U }; /* r‱ */ + *tasks_max = (CGroupTasksMax) { r, 10000U }; /* r‱ */ else { r = safe_atou64(rvalue, &v); if (r < 0) { @@ -3946,7 +3946,7 @@ int config_parse_tasks_max( return 0; } - *tasks_max = (TasksMax) { v }; + *tasks_max = (CGroupTasksMax) { v }; } return 0; diff --git a/src/core/manager.c b/src/core/manager.c index 07a95fe752d..3068f633d75 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -112,7 +112,7 @@ /* How many units and jobs to process of the bus queue before returning to the event loop. */ #define MANAGER_BUS_MESSAGE_BUDGET 100U -#define DEFAULT_TASKS_MAX ((TasksMax) { 15U, 100U }) /* 15% */ +#define DEFAULT_TASKS_MAX ((CGroupTasksMax) { 15U, 100U }) /* 15% */ static int manager_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t revents, void *userdata); static int manager_dispatch_cgroups_agent_fd(sd_event_source *source, int fd, uint32_t revents, void *userdata); diff --git a/src/core/manager.h b/src/core/manager.h index 05697ce4e84..4fa54bb3c1a 100644 --- a/src/core/manager.h +++ b/src/core/manager.h @@ -167,7 +167,7 @@ typedef struct UnitDefaults { bool tasks_accounting; bool ip_accounting; - TasksMax tasks_max; + CGroupTasksMax tasks_max; usec_t timer_accuracy_usec; OOMPolicy oom_policy; diff --git a/src/test/test-cgroup-mask.c b/src/test/test-cgroup-mask.c index 9ab253a65cc..9d7c29f348f 100644 --- a/src/test/test-cgroup-mask.c +++ b/src/test/test-cgroup-mask.c @@ -58,7 +58,7 @@ TEST_RET(cgroup_mask, .sd_booted = true) { m->defaults.blockio_accounting = m->defaults.io_accounting = m->defaults.tasks_accounting = false; - m->defaults.tasks_max = TASKS_MAX_UNSET; + m->defaults.tasks_max = CGROUP_TASKS_MAX_UNSET; assert_se(manager_startup(m, NULL, NULL, NULL) >= 0);