[CRIU] [PATCH] lazy-pages: don't close page_read when a parent process exits

Mike Rapoport rppt at linux.vnet.ibm.com
Thu Sep 7 10:15:17 MSK 2017


If there were fork()'s during lazy-restore we create a shallow copy of the
parent process' page-read. Since all the copies reference the same open
files, we cannot close the page-read until we finish restore of all the
processes that share the page-read.

Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
Fixes faulure at Jenkins build 421
https://ci.openvz.org/job/CRIU/job/CRIU-lazy/job/criu-dev/421/

 criu/uffd.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/criu/uffd.c b/criu/uffd.c
index 494da85..bd5d2b9 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -109,6 +109,7 @@ struct lazy_pages_info {
 	struct list_head reqs;
 
 	struct lazy_pages_info *parent;
+	unsigned num_children;
 
 	struct page_read pr;
 
@@ -176,7 +177,9 @@ static void lpi_fini(struct lazy_pages_info *lpi)
 	free_vmas(lpi);
 	if (lpi->lpfd.fd > 0)
 		close(lpi->lpfd.fd);
-	if (!lpi->parent && lpi->pr.close)
+	if (lpi->parent)
+		lpi->parent->num_children--;
+	if (!lpi->parent && !lpi->num_children && lpi->pr.close)
 		lpi->pr.close(&lpi->pr);
 	free(lpi);
 }
@@ -1175,6 +1178,8 @@ static int handle_fork(struct lazy_pages_info *parent_lpi, struct uffd_msg *msg)
 
 	dup_page_read(&lpi->parent->pr, &lpi->pr);
 
+	lpi->parent->num_children++;
+
 	return 1;
 
 out:
-- 
2.7.4



More information about the CRIU mailing list