Re: [PATCH v5 6/7] mm/gup: Take mmap_lock in get_dump_page()

From: Linus Torvalds
Date: Thu Aug 27 2020 - 13:14:13 EST


On Thu, Aug 27, 2020 at 4:50 AM Jann Horn <jannh@xxxxxxxxxx> wrote:
>
> Properly take the mmap_lock before calling into the GUP code from
> get_dump_page(); and play nice, allowing the GUP code to drop the mmap_lock
> if it has to sleep.

Hmm. Of all the patches in the series, this simple one is now the only
one I feel makes for ugly code. Certainly not uglier than it used to
be, but also not as pretty as it could be..

I think you're pretty much just re-implementing
get_user_pages_unlocked(), aren't you?

There are differences - you use mmap_read_lock_killable(), for
example. But I think get_user_pages_unlocked() should too.

The other difference is that you don't set FOLL_TOUCH. So it's not
*exactly* the same thing, but it's close enough that I get the feeling
that this should be cleaned up to use a common helper between the two.

That said, I suspect that falls under the heading of "future cleanup".
I don't think there's any need to re-spin this series for this, it's
just the only slightly negative reaction I had for the whole series
now.

Linus