cgroup: Also set blkio.bfq.weight
authorPavel Hrdina <phrdina@redhat.com>
Wed, 25 Nov 2020 08:05:36 +0000 (09:05 +0100)
committerThe Plumber <50238977+systemd-rhel-bot@users.noreply.github.com>
Mon, 25 Jan 2021 14:00:51 +0000 (15:00 +0100)
Commit [1] added a workaround when unified cgroups are used but missed
legacy cgroups where there is the same issue.

[1] <https://github.com/systemd/systemd/commit/2dbc45aea747f25cc1c3848fded2ec0062f96bcf>

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit 35e7a62ca32a30169a94693b831e53c832251984)

Resolves: #1657810

src/core/cgroup.c

index f1ce070f9a624a1c7dc758fc4078b788692526ee..71e30fd4dba93cf5015769e3504dddc376766910 100644 (file)
@@ -1063,6 +1063,14 @@ static void cgroup_context_apply(
                                 log_unit_full(u, IN_SET(r, -ENOENT, -EROFS, -EACCES) ? LOG_DEBUG : LOG_WARNING, r,
                                               "Failed to set blkio.weight: %m");
 
+                        /* 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);
+                        r = cg_set_attribute("blkio", path, "blkio.bfq.weight", buf);
+                        if (r < 0)
+                                log_unit_full(u, IN_SET(r, -ENOENT, -EROFS, -EACCES) ? LOG_DEBUG : LOG_WARNING, r,
+                                              "Failed to set blkio.bfq.weight: %m");
+
                         if (has_io) {
                                 CGroupIODeviceWeight *w;