Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1705502 > unrolled thread

[PATCH] userfaultfd: replace ENOSPC with ESRCH in case mm has gone during copy/zeropage

Started byMike Rapoport <rppt@linux.vnet.ibm.com>
First post2017-08-07 15:20 +0200
Last post2017-08-10 11:40 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] userfaultfd: replace ENOSPC with ESRCH in case mm has gone during copy/zeropage Mike Rapoport <rppt@linux.vnet.ibm.com> - 2017-08-07 15:20 +0200
    Re: [PATCH] userfaultfd: replace ENOSPC with ESRCH in case mm has  gone during copy/zeropage Mike Rapoport <rppt@linux.vnet.ibm.com> - 2017-08-08 08:10 +0200
      Re: [PATCH] userfaultfd: replace ENOSPC with ESRCH in case mm has  gone during copy/zeropage Michal Hocko <mhocko@kernel.org> - 2017-08-10 11:40 +0200

#1705502 — [PATCH] userfaultfd: replace ENOSPC with ESRCH in case mm has gone during copy/zeropage

FromMike Rapoport <rppt@linux.vnet.ibm.com>
Date2017-08-07 15:20 +0200
Subject[PATCH] userfaultfd: replace ENOSPC with ESRCH in case mm has gone during copy/zeropage
Message-ID<ubQ6S-fz-15@gated-at.bofh.it>
When the process exit races with outstanding mcopy_atomic, it would be
better to return ESRCH error. When such race occurs the process and it's mm
are going away and returning "no such process" to the uffd monitor seems
better fit than ENOSPC.

Suggested-by: Michal Hocko <mhocko@suse.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: Pavel Emelyanov <xemul@virtuozzo.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
---
The man-pages update is ready and I'll send it out once the patch is
merged.

 fs/userfaultfd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index 06ea26b8c996..b0d5897bc4e6 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -1600,7 +1600,7 @@ static int userfaultfd_copy(struct userfaultfd_ctx *ctx,
 				   uffdio_copy.len);
 		mmput(ctx->mm);
 	} else {
-		return -ENOSPC;
+		return -ESRCH;
 	}
 	if (unlikely(put_user(ret, &user_uffdio_copy->copy)))
 		return -EFAULT;
@@ -1647,7 +1647,7 @@ static int userfaultfd_zeropage(struct userfaultfd_ctx *ctx,
 				     uffdio_zeropage.range.len);
 		mmput(ctx->mm);
 	} else {
-		return -ENOSPC;
+		return -ESRCH;
 	}
 	if (unlikely(put_user(ret, &user_uffdio_zeropage->zeropage)))
 		return -EFAULT;
-- 
2.7.4

[toc] | [next] | [standalone]


#1706048 — Re: [PATCH] userfaultfd: replace ENOSPC with ESRCH in case mm has gone during copy/zeropage

FromMike Rapoport <rppt@linux.vnet.ibm.com>
Date2017-08-08 08:10 +0200
SubjectRe: [PATCH] userfaultfd: replace ENOSPC with ESRCH in case mm has gone during copy/zeropage
Message-ID<uc5Sh-3MH-7@gated-at.bofh.it>
In reply to#1705502
(adding Michal)

On Mon, Aug 07, 2017 at 04:12:25PM +0300, Mike Rapoport wrote:
> When the process exit races with outstanding mcopy_atomic, it would be
> better to return ESRCH error. When such race occurs the process and it's mm
> are going away and returning "no such process" to the uffd monitor seems
> better fit than ENOSPC.
> 
> Suggested-by: Michal Hocko <mhocko@suse.com>
> Cc: Andrea Arcangeli <aarcange@redhat.com>
> Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> Cc: Pavel Emelyanov <xemul@virtuozzo.com>
> Cc: Mike Kravetz <mike.kravetz@oracle.com>
> Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
> ---
> The man-pages update is ready and I'll send it out once the patch is
> merged.
> 
>  fs/userfaultfd.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
> index 06ea26b8c996..b0d5897bc4e6 100644
> --- a/fs/userfaultfd.c
> +++ b/fs/userfaultfd.c
> @@ -1600,7 +1600,7 @@ static int userfaultfd_copy(struct userfaultfd_ctx *ctx,
>  				   uffdio_copy.len);
>  		mmput(ctx->mm);
>  	} else {
> -		return -ENOSPC;
> +		return -ESRCH;
>  	}
>  	if (unlikely(put_user(ret, &user_uffdio_copy->copy)))
>  		return -EFAULT;
> @@ -1647,7 +1647,7 @@ static int userfaultfd_zeropage(struct userfaultfd_ctx *ctx,
>  				     uffdio_zeropage.range.len);
>  		mmput(ctx->mm);
>  	} else {
> -		return -ENOSPC;
> +		return -ESRCH;
>  	}
>  	if (unlikely(put_user(ret, &user_uffdio_zeropage->zeropage)))
>  		return -EFAULT;
> -- 
> 2.7.4
> 

-- 
Sincerely yours,
Mike.

[toc] | [prev] | [next] | [standalone]


#1708369 — Re: [PATCH] userfaultfd: replace ENOSPC with ESRCH in case mm has gone during copy/zeropage

FromMichal Hocko <mhocko@kernel.org>
Date2017-08-10 11:40 +0200
SubjectRe: [PATCH] userfaultfd: replace ENOSPC with ESRCH in case mm has gone during copy/zeropage
Message-ID<ucS6B-3LT-5@gated-at.bofh.it>
In reply to#1706048
On Tue 08-08-17 09:08:17, Mike Rapoport wrote:
> (adding Michal)

Thanks

> On Mon, Aug 07, 2017 at 04:12:25PM +0300, Mike Rapoport wrote:
> > When the process exit races with outstanding mcopy_atomic, it would be
> > better to return ESRCH error. When such race occurs the process and it's mm
> > are going away and returning "no such process" to the uffd monitor seems
> > better fit than ENOSPC.

Not only the error message would be less confusing I also think that
error handling should be more straightforward. Although I cannot find
any guidelines for ENOSPC handling I've considered this errno as
potentially temporary and retry might be feasible while ESRCH is a
terminal error. I do not expect any userfaultfd users would retry on
error but who knows how the interface will be used in future so better
be prepared.

> > Suggested-by: Michal Hocko <mhocko@suse.com>
> > Cc: Andrea Arcangeli <aarcange@redhat.com>
> > Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> > Cc: Pavel Emelyanov <xemul@virtuozzo.com>
> > Cc: Mike Kravetz <mike.kravetz@oracle.com>
> > Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>

Acked-by: Michal Hocko <mhocko@suse.com>

> > ---
> > The man-pages update is ready and I'll send it out once the patch is
> > merged.
> > 
> >  fs/userfaultfd.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
> > index 06ea26b8c996..b0d5897bc4e6 100644
> > --- a/fs/userfaultfd.c
> > +++ b/fs/userfaultfd.c
> > @@ -1600,7 +1600,7 @@ static int userfaultfd_copy(struct userfaultfd_ctx *ctx,
> >  				   uffdio_copy.len);
> >  		mmput(ctx->mm);
> >  	} else {
> > -		return -ENOSPC;
> > +		return -ESRCH;
> >  	}
> >  	if (unlikely(put_user(ret, &user_uffdio_copy->copy)))
> >  		return -EFAULT;
> > @@ -1647,7 +1647,7 @@ static int userfaultfd_zeropage(struct userfaultfd_ctx *ctx,
> >  				     uffdio_zeropage.range.len);
> >  		mmput(ctx->mm);
> >  	} else {
> > -		return -ENOSPC;
> > +		return -ESRCH;
> >  	}
> >  	if (unlikely(put_user(ret, &user_uffdio_zeropage->zeropage)))
> >  		return -EFAULT;
> > -- 
> > 2.7.4
> > 
> 
> -- 
> Sincerely yours,
> Mike.
> 

-- 
Michal Hocko
SUSE Labs

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web