From b11f5796268e3f66c5ad41909916ca751c29f4bd Mon Sep 17 00:00:00 2001 From: Mike Rapoport Date: Sun, 25 Mar 2018 16:27:28 +0300 Subject: [PATCH] lazy-pages: simplify background transfer logic 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 Signed-off-by: Andrei Vagin --- criu/uffd.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/criu/uffd.c b/criu/uffd.c index 8bbfb5c64..14a7ab41b 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; }