naccyde / rpms / systemd

Forked from rpms/systemd 11 months ago
Clone
b677e7
From 4e589237979fdf90af38d466abd7fcd852356f02 Mon Sep 17 00:00:00 2001
b677e7
From: Kai Krakow <kai@kaishome.de>
b677e7
Date: Sat, 17 Aug 2019 02:33:43 +0200
b677e7
Subject: [PATCH] cgroup: Also set io.bfq.weight
b677e7
b677e7
Current kernels with BFQ scheduler do not yet set their IO weight
b677e7
through "io.weight" but through "io.bfq.weight" (using a slightly
b677e7
different interface supporting only default weights, not per-device
b677e7
weights). This commit enables "IOWeight=" to just to that.
b677e7
b677e7
This patch may be dropped at some time later.
b677e7
b677e7
Github-Link: https://github.com/systemd/systemd/issues/7057
b677e7
Signed-off-by: Kai Krakow <kai@kaishome.de>
b677e7
b677e7
(cherry picked from commit 21221ce1ce9a572e82d46d80692afd65c224fc50)
b677e7
b677e7
Related: #1927290
b677e7
---
b677e7
 src/core/cgroup.c | 8 ++++++++
b677e7
 1 file changed, 8 insertions(+)
b677e7
b677e7
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
b677e7
index 71e30fd4db..f02cc31c6e 100644
b677e7
--- a/src/core/cgroup.c
b677e7
+++ b/src/core/cgroup.c
b677e7
@@ -984,6 +984,14 @@ static void cgroup_context_apply(
b677e7
                                 log_unit_full(u, IN_SET(r, -ENOENT, -EROFS, -EACCES) ? LOG_DEBUG : LOG_WARNING, r,
b677e7
                                               "Failed to set io.weight: %m");
b677e7
 
b677e7
+                        /* FIXME: drop this when distro kernels properly support BFQ through "io.weight"
b677e7
+                         * See also: https://github.com/systemd/systemd/pull/13335 */
b677e7
+                        xsprintf(buf, "%" PRIu64 "\n", weight);
b677e7
+                        r = cg_set_attribute("io", path, "io.bfq.weight", buf);
b677e7
+                        if (r < 0)
b677e7
+                                log_unit_full(u, IN_SET(r, -ENOENT, -EROFS, -EACCES) ? LOG_DEBUG : LOG_WARNING, r,
b677e7
+                                              "Failed to set io.bfq.weight: %m");
b677e7
+
b677e7
                         if (has_io) {
b677e7
                                 CGroupIODeviceWeight *w;
b677e7