[CRIU] [PATCH 09/11] vma: Add vma_next() helper

Pavel Emelyanov xemul at virtuozzo.com
Fri May 5 09:03:46 PDT 2017


Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/cr-restore.c  | 4 ++--
 criu/include/vma.h | 5 +++++
 criu/mem.c         | 6 +++---
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index bbe0dad..92945f3 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -2249,7 +2249,7 @@ static long restorer_get_vma_hint(struct list_head *tgt_vma_list,
 				break;
 			if (prev_vma_end < s_vma->e->end)
 				prev_vma_end = s_vma->e->end;
-			s_vma = list_entry(s_vma->list.next, struct vma_area, list);
+			s_vma = vma_next(s_vma);
 			continue;
 		}
 
@@ -2262,7 +2262,7 @@ static long restorer_get_vma_hint(struct list_head *tgt_vma_list,
 				break;
 			if (prev_vma_end < t_vma->e->end)
 				prev_vma_end = t_vma->e->end;
-			t_vma = list_entry(t_vma->list.next, struct vma_area, list);
+			t_vma = vma_next(t_vma);
 			continue;
 		}
 
diff --git a/criu/include/vma.h b/criu/include/vma.h
index dcce080..de8b411 100644
--- a/criu/include/vma.h
+++ b/criu/include/vma.h
@@ -126,4 +126,9 @@ static inline bool vma_entry_can_be_lazy(VmaEntry *e)
 		!(vma_entry_is(e, VMA_AREA_VSYSCALL)));
 }
 
+static inline struct vma_area *vma_next(struct vma_area *vma)
+{
+	return list_entry(vma->list.next, struct vma_area, list);
+}
+
 #endif /* __CR_VMA_H__ */
diff --git a/criu/mem.c b/criu/mem.c
index 6cefa9d..e8ca093 100644
--- a/criu/mem.c
+++ b/criu/mem.c
@@ -594,14 +594,14 @@ static void prepare_cow_vmas_for(struct vm_area_list *vmas, struct vm_area_list
 
 		/* <= here to shift from matching VMAs and ... */
 		while (vma->e->start <= pvma->e->start) {
-			vma = list_entry(vma->list.next, struct vma_area, list);
+			vma = vma_next(vma);
 			if (&vma->list == &vmas->h)
 				return;
 		}
 
 		/* ... no == here since we must stop on matching pair */
 		while (pvma->e->start < vma->e->start) {
-			pvma = list_entry(pvma->list.next, struct vma_area, list);
+			pvma = vma_next(pvma);
 			if (&pvma->list == &pvmas->h)
 				return;
 		}
@@ -813,7 +813,7 @@ static int restore_priv_vma_content(struct pstree_item *t, struct page_read *pr)
 			while (va >= vma->e->end) {
 				if (vma->list.next == vmas)
 					goto err_addr;
-				vma = list_entry(vma->list.next, struct vma_area, list);
+				vma = vma_next(vma);
 			}
 
 			/*
-- 
2.5.5



More information about the CRIU mailing list