[Devel,libvzctl] env_nsops: Add debug print for catching memory limits setup problem

Submitted by Cyrill Gorcunov on April 12, 2017, 4:44 p.m.

Details

Message ID 1492015458-23632-1-git-send-email-gorcunov@openvz.org
State New
Series "env_nsops: Add debug print for catching memory limits setup problem"
Headers show

Commit Message

Cyrill Gorcunov April 12, 2017, 4:44 p.m.
In a sake of

https://jira.sw.ru/browse/PSBM-64043

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
Igor, I believe this is suitable for cathing problems.

 lib/cgroup.h    | 2 ++
 lib/env_nsops.c | 7 +++++++
 2 files changed, 9 insertions(+)

Patch hide | download patch | download mbox

diff --git a/lib/cgroup.h b/lib/cgroup.h
index 23bd45a..a27ca96 100644
--- a/lib/cgroup.h
+++ b/lib/cgroup.h
@@ -37,7 +37,9 @@ 
 #define CG_PIDS		"pids"
 
 #define CG_MEM_LIMIT	"memory.limit_in_bytes"
+#define CG_MEM_USAGE	"memory.usage_in_bytes"
 #define CG_SWAP_LIMIT	"memory.memsw.limit_in_bytes"
+#define CG_SWAP_USAGE	"memory.memsw.usage_in_bytes"
 #define CG_NET_CLASSID	"net_cls.classid"
 
 /* For x86-64 kernels */
diff --git a/lib/env_nsops.c b/lib/env_nsops.c
index 95df816..a15096a 100644
--- a/lib/env_nsops.c
+++ b/lib/env_nsops.c
@@ -285,10 +285,17 @@  static int ns_set_memory_param(struct vzctl_env_handle *h,
 	int pagesize = get_pagesize();
 	float x;
 	unsigned long cur_ms, cur_mem, new_ms, new_mem = 0;
+	unsigned long cur_mem_usage = 0, cur_ms_usage = 0;
 
 	if (ub->physpages == NULL && ub->swappages == NULL)
 		return 0;
 
+	cg_env_get_memory(h->ctid, CG_MEM_USAGE, &cur_mem_usage);
+	cg_env_get_memory(h->ctid, CG_SWAP_USAGE, &cur_ms_usage);
+
+	logger(3, 0, "current mem %lu and swap %lu usage",
+	       cur_mem_usage, cur_ms_usage);
+
 	ret = cg_env_get_memory(h->ctid, CG_SWAP_LIMIT, &cur_ms);
 	if (ret)
 		return ret;