[CRIU] [PATCH] mm: Record page size in checkpoint and check it at run time

Christopher Covington cov at codeaurora.org
Tue Nov 1 16:23:05 PDT 2016


Page size is a build time kernel configuration option on 64-bit ARM and
PowerPC. Record the page size when a checkpoint is dumped, and check that
it is the same during restore.

With a run-time check in place, remove the build-time check that was
unnecessarily preventing CRIU to be built with PAGE_SHIFT=16 (64K) on arm64 and
PAGE_SHIFT=12 (4K) on ppc64, for example.

Signed-off-by: Christopher Covington <cov at codeaurora.org>
Reviewed-by: Andrei Vagin <avagin at gmail.com>
---
 criu/crtools.c         |  1 -
 criu/image.c           | 10 ++++++++++
 criu/include/image.h   |  5 -----
 images/inventory.proto |  1 +
 4 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/criu/crtools.c b/criu/crtools.c
index 1b40b87..f400c32 100644
--- a/criu/crtools.c
+++ b/criu/crtools.c
@@ -286,7 +286,6 @@ int main(int argc, char *argv[], char *envp[])
 		{ },
 	};
 
-	BUILD_BUG_ON(PAGE_SIZE != PAGE_IMAGE_SIZE);
 	BUILD_BUG_ON(CTL_32 != SYSCTL_TYPE__CTL_32);
 	BUILD_BUG_ON(__CTL_STR != SYSCTL_TYPE__CTL_STR);
 
diff --git a/criu/image.c b/criu/image.c
index 7d8bc7a..43f1f37 100644
--- a/criu/image.c
+++ b/criu/image.c
@@ -16,6 +16,7 @@
 #include "xmalloc.h"
 #include "images/inventory.pb-c.h"
 #include "images/pagemap.pb-c.h"
+#include "page.h"
 
 bool ns_per_id = false;
 bool img_common_magic = true;
@@ -84,6 +85,13 @@ int check_img_inventory(void)
 	if (opts.check_only)
 		pr_msg("Checking mode enabled\n");
 
+	if (he->has_page_size && he->page_size != page_size()) {
+		pr_err("Dump page size %u != restore %ld\n",
+		       he->page_size, page_size());
+		return -1;
+	}
+
+
 	ret = 0;
 
 out_err:
@@ -106,6 +114,8 @@ int write_img_inventory(InventoryEntry *he)
 	if (pb_write_one(img, he, PB_INVENTORY) < 0)
 		return -1;
 
+	he->page_size = page_size();
+
 	xfree(he->root_ids);
 	close_image(img);
 	return 0;
diff --git a/criu/include/image.h b/criu/include/image.h
index 1c22a4f..3b3b05a 100644
--- a/criu/include/image.h
+++ b/criu/include/image.h
@@ -12,11 +12,6 @@
 #include "log.h"
 #include "common/bug.h"
 
-#ifdef _ARCH_PPC64
-#define PAGE_IMAGE_SIZE	65536
-#else
-#define PAGE_IMAGE_SIZE	4096
-#endif /* _ARCH_PPC64 */
 #define PAGE_RSS	1
 #define PAGE_ANON	2
 
diff --git a/images/inventory.proto b/images/inventory.proto
index 5bc3db2..cce5d92 100644
--- a/images/inventory.proto
+++ b/images/inventory.proto
@@ -16,4 +16,5 @@ message inventory_entry {
 	optional uint32			root_cg_set	= 5;
 	optional lsmtype		lsmtype		= 6;
 	optional bool			check_only	= 7;
+	optional uint32			page_size	= 8;
 }
-- 
Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.



More information about the CRIU mailing list