[CRIU] [PATCH 03/11] vdso: Don't park vdso/vvar if restoree doesn't have them

Dmitry Safonov dsafonov at virtuozzo.com
Thu Jun 15 19:36:07 MSK 2017


Let's just unmap criu's vdso & vvar if restoree doesn't
have them.
This could be fired e.g. by migrating task from vdso-disabled
kernel to vdso-enabled one.

Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
 criu/pie/parasite-vdso.c |  5 ++---
 criu/pie/restorer.c      | 23 +++++++++++++++++++++--
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/criu/pie/parasite-vdso.c b/criu/pie/parasite-vdso.c
index 5a97629d4d4f..4442a1179ed6 100644
--- a/criu/pie/parasite-vdso.c
+++ b/criu/pie/parasite-vdso.c
@@ -122,9 +122,8 @@ int vdso_proxify(struct vdso_symtable *sym_rt, unsigned long vdso_rt_parked_at,
 	if (!vma_vdso && !vma_vvar) {
 		pr_info("No VVAR, no vDSO in image\n");
 		/*
-		 * We don't have to unmap rt-vdso, rt-vvar as they will
-		 * be unmapped with restorer blob in the end,
-		 * see __export_unmap()
+		 * We don't have to unmap rt-vdso, rt-vvar as we didn't
+		 * park them previously.
 		 */
 		return 0;
 	}
diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c
index e8c111870a63..269616454794 100644
--- a/criu/pie/restorer.c
+++ b/criu/pie/restorer.c
@@ -1159,6 +1159,26 @@ static int wait_zombies(struct task_restore_args *task_args)
 	return 0;
 }
 
+static bool vdso_needs_parking(struct task_restore_args *args)
+{
+	unsigned int i;
+
+	/* Compatible vDSO will be mapped, not moved */
+	if (args->compatible_mode)
+		return false;
+
+	/* Don't park rt-vdso or rt-vvar if dumpee doesn't have them */
+	for (i = 0; i < args->vmas_n; i++) {
+		VmaEntry *vma = &args->vmas[i];
+
+		if (vma_entry_is(vma, VMA_AREA_VDSO) ||
+				vma_entry_is(vma, VMA_AREA_VVAR))
+			return true;
+	}
+
+	return false;
+}
+
 /*
  * The main routine to restore task via sigreturn.
  * This one is very special, we never return there
@@ -1216,8 +1236,7 @@ long __export_restore_task(struct task_restore_args *args)
 		pr_debug("lazy-pages: uffd %d\n", args->uffd);
 	}
 
-	if (!args->compatible_mode) {
-		/* Compatible vDSO will be mapped, not moved */
+	if (vdso_needs_parking(args)) {
 		if (vdso_do_park(&args->vdso_sym_rt,
 				args->vdso_rt_parked_at, vdso_rt_size))
 			goto core_restore_end;
-- 
2.12.2



More information about the CRIU mailing list