Commit cc4492e1 authored by Pavel Emelyanov's avatar Pavel Emelyanov

rst: Don't allocate page for child stack (v2)

When clone-ing kids we can set their stack on current, as
it will anyway be COW-ed later. One thing to note -- we do
need to reserve some space on the stack for glibc's arguments
and retcode allocation. 128 bytes should be enough for 16
pointers while clone has 5 arguments.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent d3b63428
......@@ -945,7 +945,11 @@ static int restore_one_task(int pid, CoreEntry *core)
/* All arguments should be above stack, because it grows down */
struct cr_clone_arg {
char stack[PAGE_SIZE] __attribute__((aligned (8)));
/*
* Reserve some space for clone() to locate arguments
* and retcode in this place
*/
char stack[128] __attribute__((aligned (8)));
char stack_ptr[0];
struct pstree_item *item;
unsigned long clone_flags;
......@@ -993,8 +997,8 @@ static void maybe_clone_parent(struct pstree_item *item,
static inline int fork_with_pid(struct pstree_item *item)
{
int ret = -1, fd;
struct cr_clone_arg ca;
int ret = -1, fd;
pid_t pid = item->pid.virt;
if (item->state != TASK_HELPER) {
......@@ -1037,6 +1041,8 @@ static inline int fork_with_pid(struct pstree_item *item)
ca.item = item;
ca.clone_flags = item->rst->clone_flags;
BUG_ON(ca.clone_flags & CLONE_VM);
pr_info("Forking task with %d pid (flags 0x%lx)\n", pid, ca.clone_flags);
if (!(ca.clone_flags & CLONE_NEWPID)) {
......
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