return r;
}
+static void set_io_weight(Unit *u, const char *controller, uint64_t weight) {
+ char buf[8+DECIMAL_STR_MAX(uint64_t)+1];
+ const char *p;
+
+ p = strjoina(controller, ".weight");
+ xsprintf(buf, "default %" PRIu64 "\n", weight);
+ (void) set_attribute_and_warn(u, controller, p, buf);
+
+ /* FIXME: drop this 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.
+ * The range is 1..1000 apparently. */
+ p = strjoina(controller, ".bfq.weight");
+ xsprintf(buf, "%" PRIu64 "\n", (weight + 9) / 10);
+ (void) set_attribute_and_warn(u, controller, p, buf);
+}
+
static void cgroup_context_apply(
Unit *u,
CGroupMask apply_mask,
* 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) {
- char buf[8+DECIMAL_STR_MAX(uint64_t)+1];
bool has_io, has_blockio;
uint64_t weight;
} else
weight = CGROUP_WEIGHT_DEFAULT;
- xsprintf(buf, "default %" PRIu64 "\n", weight);
- (void) set_attribute_and_warn(u, "io", "io.weight", buf);
-
- /* FIXME: drop this when distro kernels properly support BFQ through "io.weight"
- * See also: https://github.com/systemd/systemd/pull/13335 */
- xsprintf(buf, "%" PRIu64 "\n", weight);
- (void) set_attribute_and_warn(u, "io", "io.bfq.weight", buf);
+ set_io_weight(u, "io", weight);
if (has_io) {
CGroupIODeviceLatency *latency;
/* Applying a 'weight' never makes sense for the host root cgroup, and for containers this should be
* left to our container manager, too. */
if (!is_local_root) {
- char buf[DECIMAL_STR_MAX(uint64_t)+1];
uint64_t weight;
if (has_io) {
else
weight = CGROUP_BLKIO_WEIGHT_DEFAULT;
- xsprintf(buf, "%" PRIu64 "\n", weight);
- (void) set_attribute_and_warn(u, "blkio", "blkio.weight", buf);
-
- /* FIXME: drop this when distro kernels properly support BFQ through "blkio.weight"
- * See also: https://github.com/systemd/systemd/pull/13335 */
- xsprintf(buf, "%" PRIu64 "\n", weight);
- (void) set_attribute_and_warn(u, "blkio", "blkio.bfq.weight", buf);
+ set_io_weight(u, "blkio", weight);
if (has_io) {
CGroupIODeviceWeight *w;