[CRIU] [PATCH 08/11] lazy-pages: simplify background transfer logic

Mike Rapoport rppt at linux.vnet.ibm.com
Sun Mar 25 16:27:28 MSK 2018


First check if there are pages we need to transfer and only afterwards
check if there are outstanding requests. Also, instead checking 'bool
remaining' to see if there is more work to do we can simply check if all
the lpi's have been already serviced.

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

diff --git a/criu/uffd.c b/criu/uffd.c
index 8bbfb5c..14a7ab4 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -1092,8 +1092,6 @@ static int handle_requests(int epollfd, struct epoll_event *events, int nr_fds)
 	int ret;
 
 	for (;;) {
-		bool remaining = false;
-
 		ret = epoll_run_rfds(epollfd, events, nr_fds, poll_timeout);
 		if (ret < 0)
 			goto out;
@@ -1112,23 +1110,21 @@ static int handle_requests(int epollfd, struct epoll_event *events, int nr_fds)
 
 		poll_timeout = 0;
 		list_for_each_entry_safe(lpi, n, &lpis, l) {
-			if (list_empty(&lpi->iovs) && list_empty(&lpi->reqs)) {
-				lazy_pages_summary(lpi);
-				list_del(&lpi->l);
-				lpi_fini(lpi);
-				continue;
-			}
-
-			remaining = true;
 			if (!list_empty(&lpi->iovs)) {
 				ret = xfer_pages(lpi);
 				if (ret < 0)
 					goto out;
 				break;
 			}
+
+			if (list_empty(&lpi->reqs)) {
+				lazy_pages_summary(lpi);
+				list_del(&lpi->l);
+				lpi_fini(lpi);
+			}
 		}
 
-		if (!remaining)
+		if (list_empty(&lpis))
 			break;
 	}
 
-- 
2.7.4



More information about the CRIU mailing list