[lxc-devel] [lxd/master] lxd/cgroup: Fix memory controller detection

stgraber on Github lxc-bot at linuxcontainers.org
Thu Apr 23 13:58:16 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200423/15446594/attachment.bin>
-------------- next part --------------
From f35ed9e23e29153a276ba6ca4465b3d50c660ba4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 23 Apr 2020 09:49:19 -0400
Subject: [PATCH] lxd/cgroup: Fix memory controller detection
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/cgroup/init.go | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/lxd/cgroup/init.go b/lxd/cgroup/init.go
index 6d04d33073..335d91e820 100644
--- a/lxd/cgroup/init.go
+++ b/lxd/cgroup/init.go
@@ -387,8 +387,22 @@ func init() {
 	}
 
 	val, ok = cgControllers["memory"]
-	if ok && val == V1 && shared.PathExists("/sys/fs/cgroup/memory/memory.memsw.limit_in_bytes") {
-		cgControllers["memory.memsw.limit_in_bytes"] = V2
+	if ok && val == V1 {
+		if shared.PathExists("/sys/fs/cgroup/memory/memory.max_usage_in_bytes") {
+			cgControllers["memory.max_usage_in_bytes"] = V1
+		}
+
+		if shared.PathExists("/sys/fs/cgroup/memory/memory.memsw.limit_in_bytes") {
+			cgControllers["memory.memsw.limit_in_bytes"] = V1
+		}
+
+		if shared.PathExists("/sys/fs/cgroup/memory/memory.memsw.usage_in_bytes") {
+			cgControllers["memory.memsw.usage_in_bytes"] = V1
+		}
+
+		if shared.PathExists("/sys/fs/cgroup/memory/memory.memsw.max_usage_in_bytes") {
+			cgControllers["memory.memsw.max_usage_in_bytes"] = V1
+		}
 	}
 
 	val, ok = cgControllers["memory"]


More information about the lxc-devel mailing list