Re: [PATCH v2 1/2] mm/gup.c: Don't pass gup_flags to check_and_migrate_movable_pages()

From: Alistair Popple
Date: Sun Aug 07 2022 - 22:20:12 EST



Jason Gunthorpe <jgg@xxxxxxxxxx> writes:

> On Fri, Aug 05, 2022 at 04:29:52PM +1000, Alistair Popple wrote:
>> @@ -2053,7 +2046,9 @@ static long __gup_longterm_locked(struct mm_struct *mm,
>> NULL, gup_flags);
>> if (rc <= 0)
>> break;
>> - rc = check_and_migrate_movable_pages(rc, pages, gup_flags);
>> +
>> + WARN_ON_ONCE(!(gup_flags & FOLL_PIN));
>> + rc = check_and_migrate_movable_pages(rc, pages);
>
> This should be moved up:

Ok. I debated doing that originally but wanted to keep the WARN_ON
close to the code that makes that assumption. On the other hand a
comment would achieve that so will move it up. Thanks.

> if (!(gup_flags & FOLL_LONGTERM))
> return __get_user_pages_locked(mm, start, nr_pages, pages, vmas,
> NULL, gup_flags);
> if (WARN_ON(!(gup_flags & FOLL_PIN)))
> return -EINVAL;
> flags = memalloc_pin_save();
>
> Jason