Commit b11f5796 authored by Mike Rapoport's avatar Mike Rapoport Committed by Andrei Vagin

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: 's avatarMike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 71a3f9aa
...@@ -1092,8 +1092,6 @@ static int handle_requests(int epollfd, struct epoll_event *events, int nr_fds) ...@@ -1092,8 +1092,6 @@ static int handle_requests(int epollfd, struct epoll_event *events, int nr_fds)
int ret; int ret;
for (;;) { for (;;) {
bool remaining = false;
ret = epoll_run_rfds(epollfd, events, nr_fds, poll_timeout); ret = epoll_run_rfds(epollfd, events, nr_fds, poll_timeout);
if (ret < 0) if (ret < 0)
goto out; goto out;
...@@ -1112,23 +1110,21 @@ static int handle_requests(int epollfd, struct epoll_event *events, int nr_fds) ...@@ -1112,23 +1110,21 @@ static int handle_requests(int epollfd, struct epoll_event *events, int nr_fds)
poll_timeout = 0; poll_timeout = 0;
list_for_each_entry_safe(lpi, n, &lpis, l) { 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)) { if (!list_empty(&lpi->iovs)) {
ret = xfer_pages(lpi); ret = xfer_pages(lpi);
if (ret < 0) if (ret < 0)
goto out; goto out;
break; break;
} }
if (list_empty(&lpi->reqs)) {
lazy_pages_summary(lpi);
list_del(&lpi->l);
lpi_fini(lpi);
}
} }
if (!remaining) if (list_empty(&lpis))
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment