mm/gup: remove the restriction on locked with FOLL_LONGTERM
authorJason Gunthorpe <jgg@nvidia.com>
Wed, 16 Nov 2022 20:07:09 +0000 (16:07 -0400)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 30 Nov 2022 23:58:56 +0000 (15:58 -0800)
commit53b2d09bdd12092a7341c08b6b863560db62fa57
tree99b1713aee05212084a2807c406c8c70b51cd322
parenteff6aa17aa7c06c25c0df80060cd0fe621dac276
mm/gup: remove the restriction on locked with FOLL_LONGTERM

This restriction was created because FOLL_LONGTERM used to scan the vma
list, so it could not tolerate becoming unlocked.  That was fixed in
commit 52650c8b466b ("mm/gup: remove the vma allocation from
gup_longterm_locked()") and the restriction on !vma was removed.

However, the locked restriction remained, even though it isn't necessary
anymore.

Adjust __gup_longterm_locked() so it can handle the mmap_read_lock()
becoming unlocked while it is looping for migration.  Migration does not
require the mmap_read_sem because it is only handling struct pages.  If we
had to unlock then ensure the whole thing returns unlocked.

Remove __get_user_pages_remote() and __gup_longterm_unlocked().  These
cases can now just directly call other functions.

Link: https://lkml.kernel.org/r/0-v1-b9ae39aa8884+14dbb-gup_longterm_locked_jgg@nvidia.com
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: John Hubbard <jhubbard@nvidia.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/gup.c