lazy-pages: uffd_zero: igore -EEXIST error

Submitted by Mike Rapoport on Sept. 13, 2017, 6:13 p.m.

Details

Message ID 1505326391-6561-1-git-send-email-rppt@linux.vnet.ibm.com
State New
Series "lazy-pages: uffd_zero: igore -EEXIST error"
Headers show

Commit Message

Mike Rapoport Sept. 13, 2017, 6:13 p.m.
The UFFDIO_ZEROPAGE returns -EEXIST when the page is already mapped. This
may happen when a page fault processing races with handle_remaining_pages.

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

Patch hide | download patch | download mbox

diff --git a/criu/uffd.c b/criu/uffd.c
index 80cc8d1..34ca41e 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -1007,9 +1007,15 @@  static int uffd_zero(struct lazy_pages_info *lpi, __u64 address, int nr_pages)
 	lp_debug(lpi, "zero page at 0x%llx\n", address);
 	rc = ioctl(lpi->lpfd.fd, UFFDIO_ZEROPAGE, &uffdio_zeropage);
 	if (rc) {
-		lp_perror(lpi, "zero page failed: %Ld",
-			  uffdio_zeropage.zeropage);
-		return -1;
+		if (errno == ENOSPC) {
+			handle_exit(lpi);
+			return 0;
+		}
+		if (uffdio_zeropage.zeropage != -EEXIST) {
+			lp_perror(lpi, "zero page failed: %Ld",
+				  uffdio_zeropage.zeropage);
+			return -1;
+		}
 	}
 
 	return 0;