Skip to content

Commit d3bfbfb

Browse files
Kundan Kumaraxboe
authored andcommitted
mm: release number of pages of a folio
Add a new function unpin_user_folio() to put the refs of a folio by npages count. The check for BIO_PAGE_PINNED flag is removed as it is already checked in bio_release_pages(). Signed-off-by: Kundan Kumar <[email protected]> Tested-by: Luis Chamberlain <[email protected]> Reviewed-by: Matthew Wilcox (Oracle) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent ed9832b commit d3bfbfb

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

include/linux/mm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,6 +1597,7 @@ void unpin_user_pages_dirty_lock(struct page **pages, unsigned long npages,
15971597
void unpin_user_page_range_dirty_lock(struct page *page, unsigned long npages,
15981598
bool make_dirty);
15991599
void unpin_user_pages(struct page **pages, unsigned long npages);
1600+
void unpin_user_folio(struct folio *folio, unsigned long npages);
16001601
void unpin_folios(struct folio **folios, unsigned long nfolios);
16011602

16021603
static inline bool is_cow_mapping(vm_flags_t flags)

mm/gup.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,19 @@ void unpin_user_pages(struct page **pages, unsigned long npages)
415415
}
416416
EXPORT_SYMBOL(unpin_user_pages);
417417

418+
/**
419+
* unpin_user_folio() - release pages of a folio
420+
* @folio: pointer to folio to be released
421+
* @npages: number of pages of same folio
422+
*
423+
* Release npages of the folio
424+
*/
425+
void unpin_user_folio(struct folio *folio, unsigned long npages)
426+
{
427+
gup_put_folio(folio, npages, FOLL_PIN);
428+
}
429+
EXPORT_SYMBOL(unpin_user_folio);
430+
418431
/**
419432
* unpin_folios() - release an array of gup-pinned folios.
420433
* @folios: array of folios to be marked dirty and released.

0 commit comments

Comments
 (0)