[PATCH] parasite: Try to map big memory slab if available

Cyrill Gorcunov gorcunov at openvz.org
Tue Feb 5 10:35:40 EST 2013


Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 pie/parasite.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/pie/parasite.c b/pie/parasite.c
index 4f02934..510b687 100644
--- a/pie/parasite.c
+++ b/pie/parasite.c
@@ -137,6 +137,7 @@ static int dump_pages(struct parasite_dump_pages_args *args)
 {
 	unsigned long nrpages, pfn, length;
 	unsigned long prot_old, prot_new;
+	bool bigmap = false;
 	u64 *map, off;
 	int ret = -1;
 
@@ -154,8 +155,17 @@ static int dump_pages(struct parasite_dump_pages_args *args)
 	 */
 	map = brk_alloc(length);
 	if (!map) {
-		ret = -ENOMEM;
-		goto err;
+		/*
+		 * OK, it's a big VMA area. Lets try another way.
+		 */
+		map = (u64 *)sys_mmap(NULL, length,
+				      PROT_READ | PROT_WRITE,
+				      MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+		if ((long)(void *)map > TASK_SIZE) {
+			ret = -ENOMEM;
+			goto err;
+		}
+		bigmap = true;
 	}
 
 	off = pfn * sizeof(*map);
@@ -226,7 +236,10 @@ static int dump_pages(struct parasite_dump_pages_args *args)
 
 	ret = 0;
 err_free:
-	brk_free(length);
+	if (!bigmap)
+		brk_free(length);
+	else
+		sys_munmap(map, length);
 err:
 	return ret;
 }
-- 
1.8.1


--neYutvxvOLaeuPCA--


More information about the CRIU mailing list