On Wed, Nov 16, 2022 at 02:11:04PM -0800, John Hubbard wrote: > On 11/16/22 12:07, Jason Gunthorpe wrote: > > 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. > > > > Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx> > > --- > > mm/gup.c | 109 ++++++++++++++----------------------------------------- > > 1 file changed, 27 insertions(+), 82 deletions(-) > > Looks nice. > > Even after this cleanup, gup.c is still a bit of a ball of string, what > with things like __gup_longterm_locked() actually handling > !FOLL_LONGTERM, and a bunch of other vestigial stuff, but this takes us > in the right direction. What do you think of this: https://github.com/jgunthorpe/linux/commits/gup Jason