From db54d1a6b70bac70f61fb140bb77a32e6b29dd54 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Sun, 6 Jul 2025 20:50:38 +0200 Subject: [PATCH 1/3] core/exec-invoke: pass "/" instead of "" for cgroup root --- src/core/exec-invoke.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/exec-invoke.c b/src/core/exec-invoke.c index 771308848a..6058553aac 100644 --- a/src/core/exec-invoke.c +++ b/src/core/exec-invoke.c @@ -5552,7 +5552,7 @@ int exec_invoke( * memory_pressure_path != NULL in the conditional below. */ if (memory_pressure_path && needs_sandboxing && exec_needs_cgroup_namespace(context)) { memory_pressure_path = mfree(memory_pressure_path); - r = cg_get_path("memory", "", "memory.pressure", &memory_pressure_path); + r = cg_get_path("memory", "/", "memory.pressure", &memory_pressure_path); if (r < 0) { *exit_status = EXIT_MEMORY; return log_oom(); From 77af13ffdbaf0fbda4c46e8ce403589b00dbdc32 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Fri, 11 Jul 2025 22:38:49 +0200 Subject: [PATCH 2/3] core/cgroup: remove deserialization for "cpuacct-usage-base" This has been superseded by "cpu-usage-base" ever since the introduction of cgroup v2. With upgrading and thus deserialzing from cgroup v1 systems becoming impossible it is eligible for removal. --- src/core/cgroup.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/cgroup.c b/src/core/cgroup.c index 118fe988a6..c2f6f47e6e 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -4380,8 +4380,7 @@ int cgroup_runtime_deserialize_one(Unit *u, const char *key, const char *value, if (!UNIT_HAS_CGROUP_CONTEXT(u)) return 0; - if (MATCH_DESERIALIZE_IMMEDIATE(u, "cpu-usage-base", key, value, safe_atou64, cpu_usage_base) || - MATCH_DESERIALIZE_IMMEDIATE(u, "cpuacct-usage-base", key, value, safe_atou64, cpu_usage_base)) + if (MATCH_DESERIALIZE_IMMEDIATE(u, "cpu-usage-base", key, value, safe_atou64, cpu_usage_base)) return 1; if (MATCH_DESERIALIZE_IMMEDIATE(u, "cpu-usage-last", key, value, safe_atou64, cpu_usage_last)) From e0d3213e09a97ec2bbf0dd2a6dfe58f08f6cb5d5 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Sat, 12 Jul 2025 17:39:14 +0200 Subject: [PATCH 3/3] core/cgroup: always submit unit to realize queue if all controllers are being invalidated Alternative to #38190 Fixes #38112 --- src/core/cgroup.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/cgroup.c b/src/core/cgroup.c index c2f6f47e6e..980d9b0f0b 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -3950,7 +3950,11 @@ bool unit_invalidate_cgroup(Unit *u, CGroupMask m) { if (!crt) return false; - if (FLAGS_SET(crt->cgroup_invalidated_mask, m)) /* NOP? */ + /* If all controllers shall be invalidated, let's unconditionally submit the unit to realize queue. + * We initialize the field to _CGROUP_MASK_ALL after all, and semantically it makes sense to use + * it as a special signal to forcibly re-realize cgroup. */ + if (m != _CGROUP_MASK_ALL && + FLAGS_SET(crt->cgroup_invalidated_mask, m)) /* NOP? */ return false; crt->cgroup_invalidated_mask |= m;