summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wilcox (Oracle) <willy@infradead.org>2021-04-22 22:58:32 -0400
committerMatthew Wilcox (Oracle) <willy@infradead.org>2021-09-27 09:27:30 -0400
commitb47393f8448ade8bafe09ed302ce2a15093e9718 (patch)
tree1d4317c21fb3ccbed8a7787b58344262c17bd479
parentdf4d4f12739495332e0d1f916ef4270f7d25d207 (diff)
downloadlinux-stable-b47393f8448ade8bafe09ed302ce2a15093e9718.tar.gz
linux-stable-b47393f8448ade8bafe09ed302ce2a15093e9718.tar.bz2
linux-stable-b47393f8448ade8bafe09ed302ce2a15093e9718.zip
mm/filemap: Add folio private_2 functions
end_page_private_2() becomes folio_end_private_2(), wait_on_page_private_2() becomes folio_wait_private_2() and wait_on_page_private_2_killable() becomes folio_wait_private_2_killable(). Adjust the fscache equivalents to call page_folio() before calling these functions to avoid adding wrappers. Ends up costing 1 byte of text in ceph & netfs, but the core shrinks by three calls to page_folio(). Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Acked-by: Vlastimil Babka <vbabka@suse.cz> Reviewed-by: William Kucharski <william.kucharski@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: David Howells <dhowells@redhat.com> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
-rw-r--r--include/linux/netfs.h6
-rw-r--r--include/linux/pagemap.h6
-rw-r--r--mm/filemap.c41
3 files changed, 24 insertions, 29 deletions
diff --git a/include/linux/netfs.h b/include/linux/netfs.h
index 5d6a4158a9a6..3d4cbf2f7dc4 100644
--- a/include/linux/netfs.h
+++ b/include/linux/netfs.h
@@ -55,7 +55,7 @@ static inline void set_page_fscache(struct page *page)
*/
static inline void end_page_fscache(struct page *page)
{
- end_page_private_2(page);
+ folio_end_private_2(page_folio(page));
}
/**
@@ -66,7 +66,7 @@ static inline void end_page_fscache(struct page *page)
*/
static inline void wait_on_page_fscache(struct page *page)
{
- wait_on_page_private_2(page);
+ folio_wait_private_2(page_folio(page));
}
/**
@@ -82,7 +82,7 @@ static inline void wait_on_page_fscache(struct page *page)
*/
static inline int wait_on_page_fscache_killable(struct page *page)
{
- return wait_on_page_private_2_killable(page);
+ return folio_wait_private_2_killable(page_folio(page));
}
enum netfs_read_source {
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index ebc62e9e453b..05f91bfc048d 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -795,9 +795,9 @@ static inline void set_page_private_2(struct page *page)
SetPagePrivate2(page);
}
-void end_page_private_2(struct page *page);
-void wait_on_page_private_2(struct page *page);
-int wait_on_page_private_2_killable(struct page *page);
+void folio_end_private_2(struct folio *folio);
+void folio_wait_private_2(struct folio *folio);
+int folio_wait_private_2_killable(struct folio *folio);
/*
* Add an arbitrary waiter to a page's wait queue
diff --git a/mm/filemap.c b/mm/filemap.c
index 1f8c00c2a4b7..d74be9fb3aa2 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1506,56 +1506,51 @@ void folio_unlock(struct folio *folio)
EXPORT_SYMBOL(folio_unlock);
/**
- * end_page_private_2 - Clear PG_private_2 and release any waiters
- * @page: The page
+ * folio_end_private_2 - Clear PG_private_2 and wake any waiters.
+ * @folio: The folio.
*
- * Clear the PG_private_2 bit on a page and wake up any sleepers waiting for
- * this. The page ref held for PG_private_2 being set is released.
+ * Clear the PG_private_2 bit on a folio and wake up any sleepers waiting for
+ * it. The folio reference held for PG_private_2 being set is released.
*
- * This is, for example, used when a netfs page is being written to a local
- * disk cache, thereby allowing writes to the cache for the same page to be
+ * This is, for example, used when a netfs folio is being written to a local
+ * disk cache, thereby allowing writes to the cache for the same folio to be
* serialised.
*/
-void end_page_private_2(struct page *page)
+void folio_end_private_2(struct folio *folio)
{
- struct folio *folio = page_folio(page);
-
VM_BUG_ON_FOLIO(!folio_test_private_2(folio), folio);
clear_bit_unlock(PG_private_2, folio_flags(folio, 0));
folio_wake_bit(folio, PG_private_2);
folio_put(folio);
}
-EXPORT_SYMBOL(end_page_private_2);
+EXPORT_SYMBOL(folio_end_private_2);
/**
- * wait_on_page_private_2 - Wait for PG_private_2 to be cleared on a page
- * @page: The page to wait on
+ * folio_wait_private_2 - Wait for PG_private_2 to be cleared on a folio.
+ * @folio: The folio to wait on.
*
- * Wait for PG_private_2 (aka PG_fscache) to be cleared on a page.
+ * Wait for PG_private_2 (aka PG_fscache) to be cleared on a folio.
*/
-void wait_on_page_private_2(struct page *page)
+void folio_wait_private_2(struct folio *folio)
{
- struct folio *folio = page_folio(page);
-
while (folio_test_private_2(folio))
folio_wait_bit(folio, PG_private_2);
}
-EXPORT_SYMBOL(wait_on_page_private_2);
+EXPORT_SYMBOL(folio_wait_private_2);
/**
- * wait_on_page_private_2_killable - Wait for PG_private_2 to be cleared on a page
- * @page: The page to wait on
+ * folio_wait_private_2_killable - Wait for PG_private_2 to be cleared on a folio.
+ * @folio: The folio to wait on.
*
- * Wait for PG_private_2 (aka PG_fscache) to be cleared on a page or until a
+ * Wait for PG_private_2 (aka PG_fscache) to be cleared on a folio or until a
* fatal signal is received by the calling task.
*
* Return:
* - 0 if successful.
* - -EINTR if a fatal signal was encountered.
*/
-int wait_on_page_private_2_killable(struct page *page)
+int folio_wait_private_2_killable(struct folio *folio)
{
- struct folio *folio = page_folio(page);
int ret = 0;
while (folio_test_private_2(folio)) {
@@ -1566,7 +1561,7 @@ int wait_on_page_private_2_killable(struct page *page)
return ret;
}
-EXPORT_SYMBOL(wait_on_page_private_2_killable);
+EXPORT_SYMBOL(folio_wait_private_2_killable);
/**
* folio_end_writeback - End writeback against a folio.