lazy-pages: treat ENOMEM returned by UFFDIO_UNREGISTER as task exit

Submitted by Mike Rapoport on Sept. 28, 2017, 5:58 p.m.

Details

Message ID 1506621532-2898-1-git-send-email-rppt@linux.vnet.ibm.com
State New
Series "lazy-pages: treat ENOMEM returned by UFFDIO_UNREGISTER as task exit"
Headers show

Commit Message

Mike Rapoport Sept. 28, 2017, 5:58 p.m.
The UFFDIO_UNREGISTER returns ENOMEM only when it is unable to get
mm_struct. We can assume in such case that the task is exited.

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

Patch hide | download patch | download mbox

diff --git a/criu/uffd.c b/criu/uffd.c
index 7e85890..77c02c4 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -914,6 +914,11 @@  static int handle_remove(struct lazy_pages_info *lpi, struct uffd_msg *msg)
 	 */
 	if (msg->event == UFFD_EVENT_REMOVE &&
 	    ioctl(lpi->lpfd.fd, UFFDIO_UNREGISTER, &unreg)) {
+		if (errno == ENOMEM) {
+			handle_exit(lpi);
+			return 0;
+		}
+
 		pr_perror("Failed to unregister (%llx - %llx)", unreg.start,
 			  unreg.start + unreg.len);
 		return -1;

Comments

Andrey Vagin Oct. 3, 2017, 10:25 p.m.
On Thu, Sep 28, 2017 at 08:58:52PM +0300, Mike Rapoport wrote:
> The UFFDIO_UNREGISTER returns ENOMEM only when it is unable to get
> mm_struct. We can assume in such case that the task is exited.
> 
> Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
> ---
>  criu/uffd.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/criu/uffd.c b/criu/uffd.c
> index 7e85890..77c02c4 100644
> --- a/criu/uffd.c
> +++ b/criu/uffd.c
> @@ -914,6 +914,11 @@ static int handle_remove(struct lazy_pages_info *lpi, struct uffd_msg *msg)
>  	 */
>  	if (msg->event == UFFD_EVENT_REMOVE &&
>  	    ioctl(lpi->lpfd.fd, UFFDIO_UNREGISTER, &unreg)) {
> +		if (errno == ENOMEM) {
pls, add a comment here
> +			handle_exit(lpi);
> +			return 0;
> +		}
> +
>  		pr_perror("Failed to unregister (%llx - %llx)", unreg.start,
>  			  unreg.start + unreg.len);
>  		return -1;
> -- 
> 2.7.4
>