Re: [PATCH] mm/gup: Let __get_user_pages_locked() return -EINTR for fatal signal

Michal Hocko
2020-04-08T17:13:17Z

On Wed 08-04-20 09:20:00, Linus Torvalds wrote:
> On Wed, Apr 8, 2020 at 8:59 AM Peter Xu <peterx@redhat.com> wrote:
> >
> > __get_user_pages_locked() will return 0 instead of -EINTR after commit
> > 4426e945df588 which added extra code to allow gup detect fatal signal
> > faster. Restore that behavior.
>
> I've applied this, but it's worth noting that
> __get_user_pages_locked() can still return 0 in other situations.
>
> I realize that "I got zero pages" is a valid return value, but I do
> wonder if we should make the rule be that a zero return value isn't
> possible (return -EAGAIN or whatever if you doin't have the
> EFAULT/EINTR conditions).
>
> So that you'd always get either an error, or a successful number of pages.
>
> The only case where __get_user_pages_locked() might return zero is if
> you pass in a zero 'nr_pages', although I suspect even for that case
> returning -EINVAL might be a better option.

Yeah, that makes sense to me. And get_user_pages_locked documentation
would benefit from an actual documentation as well. What we have right
now is more suited to the lower level (__get_user_pages_locked) and have
a high level user oriented documentation.
--
Michal Hocko
SUSE Labs