[CRIU] [PATCH 08/10] vdso: move VMAs traverse cycle in vdso_proxify()
Dmitry Safonov
dsafonov at virtuozzo.com
Thu Feb 16 08:20:43 PST 2017
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.
Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
criu/include/parasite-vdso.h | 2 +-
criu/pie/parasite-vdso.c | 31 +++++++++++++++++--------------
criu/pie/restorer.c | 18 ++++--------------
3 files changed, 22 insertions(+), 29 deletions(-)
diff --git a/criu/include/parasite-vdso.h b/criu/include/parasite-vdso.h
index 8f7aaf9e0fd2..11a4135e053e 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 e55c23a0734e..dc4d033764d6 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];
-
- 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];
+ 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 (!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 4bea30293575..7783ce2f16e9 100644
--- a/criu/pie/restorer.c
+++ b/criu/pie/restorer.c
@@ -1250,23 +1250,13 @@ long __export_restore_task(struct task_restore_args *args)
}
#ifdef CONFIG_VDSO
- if (args->check_only)
- goto skip_vdso;
/*
* 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;
- }
- }
-skip_vdso:
+ if (!args->check_only)
+ 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
/*
--
2.11.1
More information about the CRIU
mailing list