Commit 275e97c7 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov

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: 's avatarCyrill Gorcunov <gorcunov@gmail.com>
parent b78c664b
......@@ -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,
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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment