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 <da...@redhat.com> > Cc: Daniel Vetter <daniel.vet...@ffwll.ch> > Cc: Mike Kravetz <mike.krav...@oracle.com> > Cc: Hugh Dickins <hu...@google.com> > Cc: Peter Xu <pet...@redhat.com> > Cc: Gerd Hoffmann <kra...@redhat.com> > Cc: Dongwon Kim <dongwon....@intel.com> > Cc: Junxiao Chang <junxiao.ch...@intel.com> > Suggested-by: Jason Gunthorpe <j...@nvidia.com> > Signed-off-by: Vivek Kasireddy <vivek.kasire...@intel.com> > --- > include/linux/mm.h | 2 + > mm/gup.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 101 insertions(+)
Reviewed-by: Jason Gunthorpe <j...@nvidia.com> Jason