[CRIU] [PATCH 7/8] lazy-pages: return to epoll_wait after completing forks

Mike Rapoport rppt at linux.vnet.ibm.com
Mon Apr 16 19:59:03 MSK 2018


If we get fork() event just before transferring last IOV of the parent
process, continuing to background fetch after completing fork event
handling will cause lazy-pages daemon to exit and nothing will monitor the
child process memory.

Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
 criu/uffd.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/criu/uffd.c b/criu/uffd.c
index 39273e7..4022fc5 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -1062,7 +1062,7 @@ static int complete_forks(int epollfd, struct epoll_event **events, int *nr_fds)
 	struct lazy_pages_info *lpi, *n;
 
 	if (list_empty(&pending_lpis))
-		return 0;
+		return 1;
 
 	list_for_each_entry(lpi, &pending_lpis, l)
 		(*nr_fds)++;
@@ -1195,12 +1195,15 @@ static int handle_requests(int epollfd, struct epoll_event *events, int nr_fds)
 			goto out;
 		if (ret > 0) {
 			ret = complete_forks(epollfd, &events, &nr_fds);
-			if (ret)
+			if (ret < 0)
 				goto out;
 			if (!restore_finished)
 				continue;
 		}
 
+		/* make sure we return success if there is nothing to xfer */
+		ret = 0;
+
 		poll_timeout = 0;
 		list_for_each_entry_safe(lpi, n, &lpis, l) {
 			if (!list_empty(&lpi->iovs) && list_empty(&lpi->reqs)) {
-- 
2.7.4



More information about the CRIU mailing list