]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/cgroup: do not consider cgroup_context_has_io_config() if only IOAccounting=yes
authorMike Yuan <me@yhndnzj.com>
Mon, 19 Jan 2026 01:05:33 +0000 (02:05 +0100)
committerMike Yuan <me@yhndnzj.com>
Mon, 19 Jan 2026 12:33:28 +0000 (13:33 +0100)
This makes things in line with unit_has_memory_config(),
and suppresses pointless application of IO configs.

src/core/cgroup.c

index c4336cd80ecaa51c797e3ac0ef7ec540693bfe73..6519440e457315d4e6e4c4f421e943db313e150d 100644 (file)
@@ -1150,8 +1150,9 @@ static void cgroup_apply_cpuset(Unit *u, const CPUSet *cpus, const char *name) {
 }
 
 static bool cgroup_context_has_io_config(CGroupContext *c) {
-        return c->io_accounting ||
-                c->io_weight != CGROUP_WEIGHT_INVALID ||
+        assert(c);
+
+        return c->io_weight != CGROUP_WEIGHT_INVALID ||
                 c->startup_io_weight != CGROUP_WEIGHT_INVALID ||
                 c->io_device_weights ||
                 c->io_device_latencies ||
@@ -1691,7 +1692,8 @@ static CGroupMask unit_get_cgroup_mask(Unit *u) {
         if (cgroup_context_has_allowed_cpus(c) || cgroup_context_has_allowed_mems(c))
                 mask |= CGROUP_MASK_CPUSET;
 
-        if (cgroup_context_has_io_config(c))
+        if (c->io_accounting ||
+            cgroup_context_has_io_config(c))
                 mask |= CGROUP_MASK_IO;
 
         if (c->memory_accounting ||