[CRIU] [PATCH 1/3] pie: restore madvise flags after aio rings have been created

Ivan Shapovalov intelfx at intelfx.name
Fri Feb 19 07:05:49 PST 2016


AIO rings internally are memory mappings, so they may have restorable
madvise bits on them. Create the mappings before restoring their properties.

Signed-off-by: Ivan Shapovalov <intelfx at intelfx.name>
---
 criu/pie/restorer.c | 54 ++++++++++++++++++++++++++---------------------------
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c
index 5bcae4f..f7bde75 100644
--- a/criu/pie/restorer.c
+++ b/criu/pie/restorer.c
@@ -996,33 +996,6 @@ long __export_restore_task(struct task_restore_args *args)
 	}
 
 	/*
-	 * Finally restore madivse() bits
-	 */
-	for (i = 0; i < args->vmas_n; i++) {
-		unsigned long m;
-
-		vma_entry = args->vmas + i;
-		if (!vma_entry->has_madv || !vma_entry->madv)
-			continue;
-
-		for (m = 0; m < sizeof(vma_entry->madv) * 8; m++) {
-			if (vma_entry->madv & (1ul << m)) {
-				ret = sys_madvise(vma_entry->start,
-						  vma_entry_len(vma_entry),
-						  m);
-				if (ret) {
-					pr_err("madvise(%"PRIx64", %"PRIu64", %ld) "
-					       "failed with %ld\n",
-						vma_entry->start,
-						vma_entry_len(vma_entry),
-						m, ret);
-					goto core_restore_end;
-				}
-			}
-		}
-	}
-
-	/*
 	 * Now when all VMAs are in their places time to set
 	 * up AIO rings.
 	 */
@@ -1076,6 +1049,33 @@ long __export_restore_task(struct task_restore_args *args)
 		}
 	}
 
+	/*
+	 * Finally restore madivse() bits
+	 */
+	for (i = 0; i < args->vmas_n; i++) {
+		unsigned long m;
+
+		vma_entry = args->vmas + i;
+		if (!vma_entry->has_madv || !vma_entry->madv)
+			continue;
+
+		for (m = 0; m < sizeof(vma_entry->madv) * 8; m++) {
+			if (vma_entry->madv & (1ul << m)) {
+				ret = sys_madvise(vma_entry->start,
+						  vma_entry_len(vma_entry),
+						  m);
+				if (ret) {
+					pr_err("madvise(%"PRIx64", %"PRIu64", %ld) "
+					       "failed with %ld\n",
+						vma_entry->start,
+						vma_entry_len(vma_entry),
+						m, ret);
+					goto core_restore_end;
+				}
+			}
+		}
+	}
+
 	ret = 0;
 
 	/*
-- 
2.7.1



More information about the CRIU mailing list