]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
mm: Add folios_put()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Tue, 14 Jun 2022 14:05:17 +0000 (10:05 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 17 Jun 2022 14:35:21 +0000 (10:35 -0400)
This is just a wrapper around release_pages() for now.  Place the
prototype in mm.h along with folio_put() and folio_put_refs().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
include/linux/mm.h
include/linux/pagemap.h

index bc8f326be0ce4a398bf5e69613bcc8589c261889..8141947555ef854f87997b039b91f8a578246a30 100644 (file)
@@ -1220,6 +1220,25 @@ static inline void folio_put_refs(struct folio *folio, int refs)
                __put_page(&folio->page);
 }
 
+void release_pages(struct page **pages, int nr);
+
+/**
+ * folios_put - Decrement the reference count on an array of folios.
+ * @folios: The folios.
+ * @nr: How many folios there are.
+ *
+ * Like folio_put(), but for an array of folios.  This is more efficient
+ * than writing the loop yourself as it will optimise the locks which
+ * need to be taken if the folios are freed.
+ *
+ * Context: May be called in process or interrupt context, but not in NMI
+ * context.  May be called while holding a spinlock.
+ */
+static inline void folios_put(struct folio **folios, unsigned int nr)
+{
+       release_pages((struct page **)folios, nr);
+}
+
 static inline void put_page(struct page *page)
 {
        struct folio *folio = page_folio(page);
index ce96866fbec4050c8826c9809b5156a15f6ba410..c399a9c5da7d45d52bcf4ec92e7247fb0e83abf0 100644 (file)
@@ -345,8 +345,6 @@ static inline void filemap_nr_thps_dec(struct address_space *mapping)
 #endif
 }
 
-void release_pages(struct page **pages, int nr);
-
 struct address_space *page_mapping(struct page *);
 struct address_space *folio_mapping(struct folio *);
 struct address_space *swapcache_mapping(struct folio *);