[CRIU] [PATCH v2] lazy-pages: don't close page_read when a parent process exits
Mike Rapoport
rppt at linux.vnet.ibm.com
Thu Sep 7 18:15:57 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>
---
v2: rebased on current criu-dev
criu/uffd.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/criu/uffd.c b/criu/uffd.c
index 077724b..43dc0ce 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -80,6 +80,7 @@ struct lazy_pages_info {
struct list_head reqs;
struct lazy_pages_info *parent;
+ unsigned num_children;
struct page_read pr;
@@ -136,7 +137,9 @@ static void lpi_fini(struct lazy_pages_info *lpi)
free_iovs(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);
}
@@ -947,6 +950,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