On Sun, Nov 05, 2023 at 10:15:39PM -0800, Vivek Kasireddy wrote: > For drivers that would like to longterm-pin the pages associated > with a file, the pin_user_pages_fd() API provides an option to > not only pin the pages via FOLL_PIN but also to check and migrate > them if they reside in movable zone or CMA block. This API > currently works with files that belong to either shmem or hugetlbfs. > Files belonging to other filesystems are rejected for now. > > The pages need to be located first before pinning them via FOLL_PIN. > If they are found in the page cache, they can be immediately pinned. > Otherwise, they need to be allocated using the filesystem specific > APIs and then pinned. > > v2: > - Drop gup_flags and improve comments and commit message (David) > - Allocate a page if we cannot find in page cache for the hugetlbfs > case as well (David) > - Don't unpin pages if there is a migration related failure (David) > - Drop the unnecessary nr_pages <= 0 check (Jason) > - Have the caller of the API pass in file * instead of fd (Jason) > > Cc: David Hildenbrand <[email protected]> > Cc: Daniel Vetter <[email protected]> > Cc: Mike Kravetz <[email protected]> > Cc: Hugh Dickins <[email protected]> > Cc: Peter Xu <[email protected]> > Cc: Gerd Hoffmann <[email protected]> > Cc: Dongwon Kim <[email protected]> > Cc: Junxiao Chang <[email protected]> > Suggested-by: Jason Gunthorpe <[email protected]> > Signed-off-by: Vivek Kasireddy <[email protected]> > --- > include/linux/mm.h | 2 + > mm/gup.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 101 insertions(+)
Reviewed-by: Jason Gunthorpe <[email protected]> Jason
