From 275e97c77d2e24caa06f709cc4bd3f22e3e11a90 Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Mon, 7 Nov 2011 22:58:18 +0400 Subject: [PATCH] restore: Increase the stack size for cloned processes Wasted a couple of hours trying to resolve this non-obvious issue. It's because bootstrapping the restorer code might requre more memory than 16K on stack. Strictly speaking we need a compile time constant here and BUG_ON. Signed-off-by: Cyrill Gorcunov --- cr-restore.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cr-restore.c b/cr-restore.c index 11f27c8c7..f517e93ce 100644 --- a/cr-restore.c +++ b/cr-restore.c @@ -1097,17 +1097,18 @@ static int do_child(void *arg) static inline int fork_with_pid(int pid, char *pstree_path) { + const int stack_size = 128 << 10; int ret = 0; void *stack; - stack = mmap(0, 4 * 4096, PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANON | MAP_GROWSDOWN, 0, 0); + stack = mmap(0, stack_size, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANON | MAP_GROWSDOWN, 0, 0); if (stack == MAP_FAILED) { pr_perror("mmap failed"); return -1; } - stack += 4 * 4096; + stack += stack_size; ret = clone(do_child, stack, SIGCHLD | CLONE_CHILD_USEPID, pstree_path, NULL, NULL, &pid); if (ret < 0) pr_perror("clone failed\n");