[CRIU] [PATCH 01/11] lazy-pages: explicitly set process exited condition
Mike Rapoport
rppt at linux.vnet.ibm.com
Sun Mar 25 16:27:21 MSK 2018
Instead of relying on length of various lists add a boolean variable to
lazy_pages_info to make it clean when the process has exited
Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
criu/uffd.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/criu/uffd.c b/criu/uffd.c
index 088e3ea..62faa2f 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -78,6 +78,7 @@ struct lp_req {
struct lazy_pages_info {
int pid;
+ bool exited;
struct list_head iovs;
struct list_head reqs;
@@ -709,6 +710,7 @@ static int handle_exit(struct lazy_pages_info *lpi)
free_iovs(lpi);
close(lpi->lpfd.fd);
lpi->lpfd.fd = 0;
+ lpi->exited = true;
/* keep it for tracking in-flight requests and for the summary */
list_move_tail(&lpi->l, &lpis);
@@ -767,6 +769,14 @@ static int uffd_io_complete(struct page_read *pr, unsigned long img_addr, int nr
lpi = container_of(pr, struct lazy_pages_info, pr);
+ /*
+ * The process may exit while we still have requests in
+ * flight. We just drop the request and the received data in
+ * this case to avoid making uffd unhappy
+ */
+ if (lpi->exited)
+ return 0;
+
list_for_each_entry(req, &lpi->reqs, l) {
if (req->img_addr == img_addr) {
addr = req->addr;
@@ -776,14 +786,6 @@ static int uffd_io_complete(struct page_read *pr, unsigned long img_addr, int nr
}
}
- /*
- * The process may exit while we still have requests in
- * flight. We just drop the request and the received data in
- * this case to avoid making uffd unhappy
- */
- if (list_empty(&lpi->iovs))
- return 0;
-
BUG_ON(!addr);
if (uffd_copy(lpi, addr, nr))
--
2.7.4
More information about the CRIU
mailing list