Skip to content
Snippets Groups Projects
Commit 89c1905d authored by Vivek Kasireddy's avatar Vivek Kasireddy Committed by Andrew Morton
Browse files

mm/gup: introduce memfd_pin_folios() for pinning memfd folios

For drivers that would like to longterm-pin the folios associated with a
memfd, the memfd_pin_folios() API provides an option to not only pin the
folios via FOLL_PIN but also to check and migrate them if they reside in
movable zone or CMA block.  This API currently works with memfds but it
should work with any files that belong to either shmemfs or hugetlbfs. 
Files belonging to other filesystems are rejected for now.

The folios 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.

[akpm@linux-foundation.org: improve the CONFIG_MMU=n situation, per SeongJae]
[vivek.kasireddy@intel.com: return -EINVAL if the end offset is greater than the size of memfd]
  Link: https://lkml.kernel.org/r/IA0PR11MB71850525CBC7D541CAB45DF1F8DB2@IA0PR11MB7185.namprd11.prod.outlook.com
Link: https://lkml.kernel.org/r/20240624063952.1572359-4-vivek.kasireddy@intel.com


Signed-off-by: default avatarVivek Kasireddy <vivek.kasireddy@intel.com>
Suggested-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> (v2)
Reviewed-by: David Hildenbrand <david@redhat.com> (v3)
Reviewed-by: Christoph Hellwig <hch@lst.de> (v6)
Acked-by: default avatarDave Airlie <airlied@redhat.com>
Acked-by: default avatarGerd Hoffmann <kraxel@redhat.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Hugh Dickins <hughd@google.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Dongwon Kim <dongwon.kim@intel.com>
Cc: Junxiao Chang <junxiao.chang@intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 53ba78de
No related branches found
No related tags found
Loading
Loading
  • CI @project_6562_bot_3b694df01c2c1ffadb3454960c315475

    mentioned in commit 59e081ff

    ·

    mentioned in commit 59e081ff

    Toggle commit list
  • CI @project_6562_bot_3b694df01c2c1ffadb3454960c315475

    mentioned in commit 570dd14b

    ·

    mentioned in commit 570dd14b

    Toggle commit list
  • CI @project_6562_bot_3b694df01c2c1ffadb3454960c315475

    mentioned in commit e28f39b3

    ·

    mentioned in commit e28f39b3

    Toggle commit list
  • CI @project_6562_bot_3b694df01c2c1ffadb3454960c315475

    mentioned in commit 7fab8b32

    ·

    mentioned in commit 7fab8b32

    Toggle commit list
  • CI @project_6562_bot_3b694df01c2c1ffadb3454960c315475

    mentioned in commit 4f11f60d

    ·

    mentioned in commit 4f11f60d

    Toggle commit list
  • CI @project_6562_bot_3b694df01c2c1ffadb3454960c315475

    mentioned in commit 0b20d280

    ·

    mentioned in commit 0b20d280

    Toggle commit list
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment