[PATCH mm-unstable v2 1/4] mm: Add folio_get_nontail_page()

From: Vishal Moola (Oracle)
Date: Mon Jan 30 2023 - 16:44:06 EST


folio_get_nontail_page() returns the folio associated with a head
page. This is necessary for folio conversions where the behavior of that
function differs between head pages and tail pages.

Signed-off-by: Vishal Moola (Oracle) <vishal.moola@xxxxxxxxx>
---
include/linux/mm.h | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index dd295c020e85..5da260346406 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -879,6 +879,13 @@ static inline bool get_page_unless_zero(struct page *page)
return page_ref_add_unless(page, 1, 0);
}

+static inline struct folio *folio_get_nontail_page(struct page *page)
+{
+ if (unlikely(!get_page_unless_zero(page)))
+ return NULL;
+ return (struct folio *)page;
+}
+
extern int page_is_ram(unsigned long pfn);

enum {
--
2.38.1