File 5011-cgroup-Add-EffectiveMemoryMax-compatibility-for-cgro.patch of Package systemd
From 29adc840dc92c75be02d13e56f602bac57130e83 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michal=20Koutn=C3=BD?= <mkoutny@suse.com>
Date: Tue, 23 Jan 2024 11:30:22 +0100
Subject: [PATCH 5011/5011] cgroup: Add EffectiveMemoryMax= compatibility for
cgroup v1
There is no EffectiveMemoryLimit= but in the case a unit has the legacy
directives only, MemoryLimit= will be used when calculating effective
limit. This is consistent with the value that is actually applied by
systemd when configuring the cgroup.
[mkoutny: jsc#PED-5659]
---
src/core/cgroup.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index 2d8d61a26d..6e4b681021 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -4020,9 +4020,9 @@ static uint64_t unit_get_effective_limit_one(Unit *u, CGroupLimitType type) {
cc = unit_get_cgroup_context(u);
switch (type) {
/* Note: on legacy/hybrid hierarchies memory_max stays CGROUP_LIMIT_MAX unless configured
- * explicitly. Effective value of MemoryLimit= (cgroup v1) is not implemented. */
+ * explicitly, look at MemoryLimit= (cgroup v1) too. */
case CGROUP_LIMIT_MEMORY_MAX:
- return cc->memory_max;
+ return unit_has_unified_memory_config(u) ? cc->memory_max : cc->memory_limit;
case CGROUP_LIMIT_MEMORY_HIGH:
return cc->memory_high;
case CGROUP_LIMIT_TASKS_MAX:
--
2.35.3