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

lazy-pages: add handling of UFFD_EVENT_UNMAP

The UNMAP event is generated by userfaultfd when a VMA (or a part of it) is
unmapped from the process address space. We won't receive #PF's at the
unmapped range, but we need to make sure we are not trying to fill that
range at handle_remaining_pages.
Note, that the VMA is gone, so there is no sense to unregister uffd from
it.

travis-ci: success for lazy-pages: add non-#PF events handling (rev2)
Signed-off-by: 's avatarMike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent ba3d099b
...@@ -678,9 +678,17 @@ static int handle_remove(struct lazy_pages_info *lpi, struct uffd_msg *msg) ...@@ -678,9 +678,17 @@ static int handle_remove(struct lazy_pages_info *lpi, struct uffd_msg *msg)
unreg.start = msg->arg.remove.start; unreg.start = msg->arg.remove.start;
unreg.len = msg->arg.remove.end - msg->arg.remove.start; unreg.len = msg->arg.remove.end - msg->arg.remove.start;
lp_debug(lpi, "REMOVE: %Lx(%Lx)\n", unreg.start, unreg.len); lp_debug(lpi, "%s: %Lx(%Lx)\n",
msg->event == UFFD_EVENT_REMOVE ? "REMOVE" : "UNMAP",
unreg.start, unreg.len);
if (ioctl(lpi->lpfd.fd, UFFDIO_UNREGISTER, &unreg)) { /*
* The REMOVE event does not change the VMA, so we need to
* make sure that we won't handle #PFs in the removed
* range. With UNMAP, there's no VMA to worry about
*/
if (msg->event == UFFD_EVENT_REMOVE &&
ioctl(lpi->lpfd.fd, UFFDIO_UNREGISTER, &unreg)) {
pr_perror("Failed to unregister (%llx - %llx)", unreg.start, pr_perror("Failed to unregister (%llx - %llx)", unreg.start,
unreg.start + unreg.len); unreg.start + unreg.len);
return -1; return -1;
...@@ -750,6 +758,7 @@ static int handle_uffd_event(struct epoll_rfd *lpfd) ...@@ -750,6 +758,7 @@ static int handle_uffd_event(struct epoll_rfd *lpfd)
case UFFD_EVENT_PAGEFAULT: case UFFD_EVENT_PAGEFAULT:
return handle_page_fault(lpi, &msg); return handle_page_fault(lpi, &msg);
case UFFD_EVENT_REMOVE: case UFFD_EVENT_REMOVE:
case UFFD_EVENT_UNMAP:
return handle_remove(lpi, &msg); return handle_remove(lpi, &msg);
default: default:
lp_err(lpi, "unexpected uffd event %u\n", msg.event); lp_err(lpi, "unexpected uffd event %u\n", msg.event);
......
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