Messages in this thread | | | Subject | Re: [PATCH 1/2] mm/gup: introduce pin_user_pages_locked() | From | John Hubbard <> | Date | Sun, 31 May 2020 12:52:21 -0700 |
| |
On 2020-05-31 00:04, Souptick Joarder wrote: ... >> +/* >> + * pin_user_pages_locked() is the FOLL_PIN variant of get_user_pages_locked(). >> + * Behavior is the same, except that this one sets FOLL_PIN and rejects >> + * FOLL_GET. >> + */ >> +long pin_user_pages_locked(unsigned long start, unsigned long nr_pages, >> + unsigned int gup_flags, struct page **pages, >> + int *locked) >> +{ >> + /* >> + * FIXME: Current FOLL_LONGTERM behavior is incompatible with >> + * FAULT_FLAG_ALLOW_RETRY because of the FS DAX check requirement on >> + * vmas. As there are no users of this flag in this call we simply >> + * disallow this option for now. >> + */ >> + if (WARN_ON_ONCE(gup_flags & FOLL_LONGTERM)) >> + return -EINVAL; >> + >> + /* FOLL_GET and FOLL_PIN are mutually exclusive. */ >> + if (WARN_ON_ONCE(gup_flags & FOLL_GET)) >> + return -EINVAL; >> + >> + gup_flags |= FOLL_PIN; > > Right now get_user_pages_locked() doesn't have similar check for FOLL_PIN
Yes, that should be added...
> and also not setting FOLL_GET internally irrespective of gup_flags > passed by user. > Do we need to add the same in get_user_pages_locked() ?
...and no, that should not.
Yes, it's prudent to assert that FOLL_PIN is *not* set, at all the get_user_pages*() API calls, thanks for spotting that. I'll add that to this patch and send out a v2.
The same check should also be added to get_user_pages_unlocked(). I'll send out a correction (I think just a v3 of that patchset) to add that.
The setting of FOLL_GET, on the other hand, is something best left as-is so far. Some call sites set FOLL_GET, some want it *not* set, and some expect that FOLL_GET is implied, and at the moment, the delicate balance is correct. :)
thanks, -- John Hubbard NVIDIA
| |