From 9062e59e5ef54aec2018e669c8e221415504f0be Mon Sep 17 00:00:00 2001 From: Dmitry Safonov Date: Thu, 16 Feb 2017 19:20:43 +0300 Subject: [PATCH] vdso: move VMAs traverse cycle in vdso_proxify() Reduce __export_restore_task(), which is fat and too long, drop needless parameter from vdso_proxify() and drop also that find-tuple logic, which isn't needed really. Acked-by: Cyrill Gorcunov Signed-off-by: Dmitry Safonov Signed-off-by: Andrei Vagin --- criu/include/parasite-vdso.h | 2 +- criu/pie/parasite-vdso.c | 29 ++++++++++++++++------------- criu/pie/restorer.c | 14 +++----------- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/criu/include/parasite-vdso.h b/criu/include/parasite-vdso.h index 8f7aaf9e0..11a4135e0 100644 --- a/criu/include/parasite-vdso.h +++ b/criu/include/parasite-vdso.h @@ -82,7 +82,7 @@ static inline bool is_vdso_mark(void *addr) extern int vdso_do_park(struct vdso_symtable *sym_rt, unsigned long park_at, unsigned long park_size); extern int vdso_map_compat(unsigned long map_at); extern int vdso_proxify(struct vdso_symtable *sym_rt, - unsigned long vdso_rt_parked_at, size_t index, + unsigned long vdso_rt_parked_at, VmaEntry *vmas, size_t nr_vmas, bool compat_vdso); #else /* CONFIG_VDSO */ diff --git a/criu/pie/parasite-vdso.c b/criu/pie/parasite-vdso.c index e55c23a07..dc4d03376 100644 --- a/criu/pie/parasite-vdso.c +++ b/criu/pie/parasite-vdso.c @@ -104,26 +104,29 @@ int __vdso_fill_symtable(uintptr_t mem, size_t size, #endif int vdso_proxify(struct vdso_symtable *sym_rt, - unsigned long vdso_rt_parked_at, size_t index, + unsigned long vdso_rt_parked_at, VmaEntry *vmas, size_t nr_vmas, bool compat_vdso) { VmaEntry *vma_vdso = NULL, *vma_vvar = NULL; struct vdso_symtable s = VDSO_SYMTABLE_INIT; bool remap_rt = false; + unsigned int i; - /* - * Figure out which kind of vdso tuple we get. - */ - if (vma_entry_is(&vmas[index], VMA_AREA_VDSO)) - vma_vdso = &vmas[index]; - else if (vma_entry_is(&vmas[index], VMA_AREA_VVAR)) - vma_vvar = &vmas[index]; + for (i = 0; i < nr_vmas; i++) { + if (vma_entry_is(&vmas[i], VMA_AREA_VDSO)) + vma_vdso = &vmas[i]; + else if (vma_entry_is(&vmas[i], VMA_AREA_VVAR)) + vma_vvar = &vmas[i]; + } - if (index < (nr_vmas - 1)) { - if (vma_entry_is(&vmas[index + 1], VMA_AREA_VDSO)) - vma_vdso = &vmas[index + 1]; - else if (vma_entry_is(&vmas[index + 1], VMA_AREA_VVAR)) - vma_vvar = &vmas[index + 1]; + 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() + */ + return 0; } if (!vma_vdso) { diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c index 9ead57199..929c478b7 100644 --- a/criu/pie/restorer.c +++ b/criu/pie/restorer.c @@ -1185,17 +1185,9 @@ long __export_restore_task(struct task_restore_args *args) /* * Proxify vDSO. */ - for (i = 0; i < args->vmas_n; i++) { - if (vma_entry_is(&args->vmas[i], VMA_AREA_VDSO) || - vma_entry_is(&args->vmas[i], VMA_AREA_VVAR)) { - if (vdso_proxify(&args->vdso_sym_rt, - args->vdso_rt_parked_at, - i, args->vmas, args->vmas_n, - args->compatible_mode)) - goto core_restore_end; - break; - } - } + if (vdso_proxify(&args->vdso_sym_rt, args->vdso_rt_parked_at, + args->vmas, args->vmas_n, args->compatible_mode)) + goto core_restore_end; #endif /*