[CRIU] [PATCH 1/3] rst: Don't allocate page for child stack

Pavel Emelyanov xemul at parallels.com
Fri Sep 12 05:42:43 PDT 2014


When clone-ing kids we can set their stack on current, as
it will anyway be COW-ed later.

Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 cr-restore.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/cr-restore.c b/cr-restore.c
index 4d5ccd5..ee15b6c 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -945,7 +945,6 @@ 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)));
 	char stack_ptr[0];
 	struct pstree_item *item;
 	unsigned long clone_flags;
@@ -993,8 +992,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 +1036,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)) {
-- 
1.8.4.2



More information about the CRIU mailing list