criu: lazy-pages: reduce amount of page_read resets

Submitted by Mike Rapoport on June 29, 2016, 5:15 a.m.

Details

Message ID 1467177331-7748-1-git-send-email-rppt@linux.vnet.ibm.com
State Rejected
Series "criu: make pagemap friendlier to random access"
Headers show

Commit Message

Mike Rapoport June 29, 2016, 5:15 a.m.
xemul: reset the pr _only_ if the requesting address is below the recently
read one

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

Patch hide | download patch | download mbox

diff --git a/criu/uffd.c b/criu/uffd.c
index 1e0a57a..a826e26 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -331,9 +331,15 @@  out:
 static int get_page(struct lazy_pages_info *lpi, unsigned long addr, void *dest)
 {
 	int ret;
+	struct iovec iov;
 	unsigned char buf[PAGE_SIZE];
 
-	lpi->pr.reset(&lpi->pr);
+	ret = lpi->pr.get_pagemap(&lpi->pr, &iov);
+	if (ret <= 0)
+		return ret;
+
+	if (addr < (unsigned long)iov.iov_base)
+		lpi->pr.reset(&lpi->pr);
 
 	ret = lpi->pr.seek_page(&lpi->pr, addr, true);
 	pr_debug("seek_pagemap_page ret 0x%x\n", ret);
@@ -345,6 +351,8 @@  static int get_page(struct lazy_pages_info *lpi, unsigned long addr, void *dest)
 	if (ret <= 0)
 		return ret;
 
+	lpi->pr.put_pagemap(&lpi->pr);
+
 	memcpy(dest, buf, PAGE_SIZE);
 
 	return 1;
@@ -616,6 +624,8 @@  static int find_vmas(struct lazy_pages_info *lpi)
 		}
 	} while (ret);
 
+	lpi->pr.reset(&lpi->pr);
+
 	/* Count detected pages */
 	list_for_each_entry(uffd_pages, &lpi->pages, list)
 	    ret++;