diff options
author | 2022-01-22 10:43:07 +0200 | |
---|---|---|
committer | 2022-01-22 10:43:07 +0200 | |
commit | b68b10b6266009bc8770adf952d637250ee93135 (patch) | |
tree | 66944314c38fd57911bca88026d170df04bf9022 /include/linux/mm.h | |
parent | Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi (diff) | |
parent | filemap: Use folio_put_refs() in filemap_free_folio() (diff) | |
download | linux-b68b10b6266009bc8770adf952d637250ee93135.tar.gz linux-b68b10b6266009bc8770adf952d637250ee93135.tar.bz2 linux-b68b10b6266009bc8770adf952d637250ee93135.zip |
Merge tag 'folio-5.17a' of git://git.infradead.org/users/willy/pagecache
Pull more folio updates from Matthew Wilcox:
"Three small folio patches.
One bug fix, one patch pulled forward from the patches destined for
5.18 and then a patch to make use of that functionality"
* tag 'folio-5.17a' of git://git.infradead.org/users/willy/pagecache:
filemap: Use folio_put_refs() in filemap_free_folio()
mm: Add folio_put_refs()
pagevec: Initialise folio_batch->percpu_pvec_drained
Diffstat (limited to 'include/linux/mm.h')
-rw-r--r-- | include/linux/mm.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index aa47705191bc..e1a84b1e6787 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1199,6 +1199,26 @@ static inline void folio_put(struct folio *folio) __put_page(&folio->page); } +/** + * folio_put_refs - Reduce the reference count on a folio. + * @folio: The folio. + * @refs: The amount to subtract from the folio's reference count. + * + * If the folio's reference count reaches zero, the memory will be + * released back to the page allocator and may be used by another + * allocation immediately. Do not access the memory or the struct folio + * after calling folio_put_refs() unless you can be sure that these weren't + * the last references. + * + * Context: May be called in process or interrupt context, but not in NMI + * context. May be called while holding a spinlock. + */ +static inline void folio_put_refs(struct folio *folio, int refs) +{ + if (folio_ref_sub_and_test(folio, refs)) + __put_page(&folio->page); +} + static inline void put_page(struct page *page) { struct folio *folio = page_folio(page); |