c->startup_memory_low_set;
}
-static int set_attribute_and_warn(Unit *u, const char *controller, const char *attribute, const char *value) {
+static int set_attribute_and_warn(Unit *u, const char *attribute, const char *value) {
int r;
assert(u);
+ assert(attribute);
+ assert(value);
CGroupRuntime *crt = unit_get_cgroup_runtime(u);
if (!crt || !crt->cgroup_path)
return -EOWNERDEAD;
- r = cg_set_attribute(controller, crt->cgroup_path, attribute, value);
+ r = cg_set_attribute(SYSTEMD_CGROUP_CONTROLLER, crt->cgroup_path, attribute, value);
if (r < 0)
log_unit_full_errno(u, LOG_LEVEL_CGROUP_WRITE(r), r, "Failed to set '%s' attribute on '%s' to '%.*s': %m",
- strna(attribute), empty_to_root(crt->cgroup_path), (int) strcspn(value, NEWLINE), value);
+ attribute, empty_to_root(crt->cgroup_path), (int) strcspn(value, NEWLINE), value);
return r;
}
if (weight == CGROUP_WEIGHT_IDLE)
return;
xsprintf(buf, "%" PRIu64 "\n", weight);
- (void) set_attribute_and_warn(u, "cpu", "cpu.weight", buf);
+ (void) set_attribute_and_warn(u, "cpu.weight", buf);
}
static void cgroup_apply_cpu_idle(Unit *u, uint64_t weight) {
MAX(quota * period / USEC_PER_SEC, USEC_PER_MSEC), period);
else
xsprintf(buf, "max " USEC_FMT "\n", period);
- (void) set_attribute_and_warn(u, "cpu", "cpu.max", buf);
+ (void) set_attribute_and_warn(u, "cpu.max", buf);
}
static void cgroup_apply_cpuset(Unit *u, const CPUSet *cpus, const char *name) {
return;
}
- (void) set_attribute_and_warn(u, "cpuset", name, buf);
+ (void) set_attribute_and_warn(u, name, buf);
}
static bool cgroup_context_has_io_config(CGroupContext *c) {
return CGROUP_WEIGHT_DEFAULT;
}
-static int set_bfq_weight(Unit *u, const char *controller, dev_t dev, uint64_t io_weight) {
+static int set_bfq_weight(Unit *u, dev_t dev, uint64_t io_weight) {
char buf[DECIMAL_STR_MAX(dev_t)*2+2+DECIMAL_STR_MAX(uint64_t)+STRLEN("\n")];
- const char *p;
uint64_t bfq_weight;
int r;
/* FIXME: drop this function when distro kernels properly support BFQ through "io.weight"
* See also: https://github.com/systemd/systemd/pull/13335 and
* https://github.com/torvalds/linux/commit/65752aef0a407e1ef17ec78a7fc31ba4e0b360f9. */
- p = strjoina(controller, ".bfq.weight");
/* Adjust to kernel range is 1..1000, the default is 100. */
bfq_weight = BFQ_WEIGHT(io_weight);
else
xsprintf(buf, "%" PRIu64 "\n", bfq_weight);
- r = cg_set_attribute(controller, crt->cgroup_path, p, buf);
+ r = cg_set_attribute(SYSTEMD_CGROUP_CONTROLLER, crt->cgroup_path, "io.bfq.weight", buf);
if (r >= 0 && io_weight != bfq_weight)
- log_unit_debug(u, "%s=%" PRIu64 " scaled to %s=%" PRIu64,
+ log_unit_debug(u, "%s=%" PRIu64 " scaled to io.bfq.weight=%" PRIu64,
major(dev) > 0 ? "IODeviceWeight" : "IOWeight",
- io_weight, p, bfq_weight);
+ io_weight, bfq_weight);
return r;
}
if (lookup_block_device(dev_path, &dev) < 0)
return;
- r1 = set_bfq_weight(u, "io", dev, io_weight);
+ r1 = set_bfq_weight(u, dev, io_weight);
xsprintf(buf, DEVNUM_FORMAT_STR " %" PRIu64 "\n", DEVNUM_FORMAT_VAL(dev), io_weight);
r2 = cg_set_attribute("io", crt->cgroup_path, "io.weight", buf);
else
xsprintf(buf, DEVNUM_FORMAT_STR " target=max\n", DEVNUM_FORMAT_VAL(dev));
- (void) set_attribute_and_warn(u, "io", "io.latency", buf);
+ (void) set_attribute_and_warn(u, "io.latency", buf);
}
static void cgroup_apply_io_device_limit(Unit *u, const char *dev_path, uint64_t *limits) {
xsprintf(buf, DEVNUM_FORMAT_STR " rbps=%s wbps=%s riops=%s wiops=%s\n", DEVNUM_FORMAT_VAL(dev),
limit_bufs[CGROUP_IO_RBPS_MAX], limit_bufs[CGROUP_IO_WBPS_MAX],
limit_bufs[CGROUP_IO_RIOPS_MAX], limit_bufs[CGROUP_IO_WIOPS_MAX]);
- (void) set_attribute_and_warn(u, "io", "io.max", buf);
+ (void) set_attribute_and_warn(u, "io.max", buf);
}
static bool unit_has_memory_config(Unit *u) {
if (v != CGROUP_LIMIT_MAX)
xsprintf(buf, "%" PRIu64 "\n", v);
- (void) set_attribute_and_warn(u, "memory", file, buf);
+ (void) set_attribute_and_warn(u, file, buf);
}
static void cgroup_apply_firewall(Unit *u) {
assert(u);
- (void) set_bfq_weight(u, "io", makedev(0, 0), weight);
+ (void) set_bfq_weight(u, makedev(0, 0), weight);
xsprintf(buf, "default %" PRIu64 "\n", weight);
- (void) set_attribute_and_warn(u, "io", "io.weight", buf);
+ (void) set_attribute_and_warn(u, "io.weight", buf);
}
static void cgroup_apply_bpf_foreign_program(Unit *u) {
cgroup_apply_memory_limit(u, "memory.swap.max", swap_max);
cgroup_apply_memory_limit(u, "memory.zswap.max", zswap_max);
- (void) set_attribute_and_warn(u, "memory", "memory.oom.group", one_zero(c->memory_oom_group));
- (void) set_attribute_and_warn(u, "memory", "memory.zswap.writeback", one_zero(c->memory_zswap_writeback));
+ (void) set_attribute_and_warn(u, "memory.oom.group", one_zero(c->memory_oom_group));
+ (void) set_attribute_and_warn(u, "memory.zswap.writeback", one_zero(c->memory_zswap_writeback));
}
if (apply_mask & CGROUP_MASK_PIDS) {
char buf[DECIMAL_STR_MAX(uint64_t) + 1];
xsprintf(buf, "%" PRIu64 "\n", cgroup_tasks_max_resolve(&c->tasks_max));
- (void) set_attribute_and_warn(u, "pids", "pids.max", buf);
+ (void) set_attribute_and_warn(u, "pids.max", buf);
} else
- (void) set_attribute_and_warn(u, "pids", "pids.max", "max\n");
+ (void) set_attribute_and_warn(u, "pids.max", "max\n");
}
}