[Devel] [PATCH libvzctl] nsops: cgroup, pids -- Don't exceed kernel limit on write

Cyrill Gorcunov gorcunov at virtuozzo.com
Fri Mar 24 05:09:25 PDT 2017


The kernel has own compiled in limit for pids.max inside
cgroup (see pids_max_write in kernel code).

Thus don't exceed it on write.

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

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 lib/cgroup.h    | 4 ++++
 lib/env_nsops.c | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/lib/cgroup.h b/lib/cgroup.h
index 8dd74a2..23bd45a 100644
--- a/lib/cgroup.h
+++ b/lib/cgroup.h
@@ -40,6 +40,10 @@
 #define CG_SWAP_LIMIT	"memory.memsw.limit_in_bytes"
 #define CG_NET_CLASSID	"net_cls.classid"
 
+/* For x86-64 kernels */
+#define PID_MAX_LIMIT		(4 * 1024 * 1024)
+#define PIDS_MAX		(PID_MAX_LIMIT + 1ULL)
+
 struct vzctl_env_handle;
 
 const char *cg_get_slice_name(void);
diff --git a/lib/env_nsops.c b/lib/env_nsops.c
index 3ebb8fb..4c6404a 100644
--- a/lib/env_nsops.c
+++ b/lib/env_nsops.c
@@ -393,6 +393,8 @@ static int ns_apply_res_param(struct vzctl_env_handle *h,
 
 	if (env->res->ub->numproc) {
 		ret = cg_set_ull(EID(h), CG_PIDS, "pids.max",
+				env->res->ub->numproc->l >= PIDS_MAX ?
+				PID_MAX_LIMIT :
 				env->res->ub->numproc->l);
 		if (ret == -1)
 			goto err;
-- 
2.7.4



More information about the Devel mailing list