linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: Move page_mapping_file to pagemap.h
@ 2021-03-16 14:10 Matthew Wilcox (Oracle)
  2021-03-16 16:03 ` kernel test robot
  2021-03-16 17:18 ` kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Matthew Wilcox (Oracle) @ 2021-03-16 14:10 UTC (permalink / raw)
  To: linux-kernel, Andrew Morton
  Cc: Matthew Wilcox (Oracle), linux-mm, Huang Ying, Mike Rapoport

page_mapping_file() is only used by some architectures, and then it
is usually only used in one place.  Make it a static inline function
so other architectures don't have to carry this dead code.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
I'm not entirely sure all the affected architectures include pagemap.h,
so give this a couple of days for the buildbots to chew on it.

 include/linux/mm.h      |  1 -
 include/linux/pagemap.h | 10 ++++++++++
 mm/util.c               | 10 ----------
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index fbe0843daa90..f69a72f63e44 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1645,7 +1645,6 @@ static inline pgoff_t page_index(struct page *page)
 
 bool page_mapped(struct page *page);
 struct address_space *page_mapping(struct page *page);
-struct address_space *page_mapping_file(struct page *page);
 
 /*
  * Return true only if the page has been allocated with
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 08fa117f405c..f68fe61c1dec 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -162,6 +162,16 @@ static inline void filemap_nr_thps_dec(struct address_space *mapping)
 
 void release_pages(struct page **pages, int nr);
 
+/*
+ * For file cache pages, return the address_space, otherwise return NULL
+ */
+static inline struct address_space *page_mapping_file(struct page *page)
+{
+	if (unlikely(PageSwapCache(page)))
+		return NULL;
+	return page_mapping(page);
+}
+
 /*
  * speculatively take a reference to a page.
  * If the page is free (_refcount == 0), then _refcount is untouched, and 0
diff --git a/mm/util.c b/mm/util.c
index 143c627fb3e8..972e7a0cda5e 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -711,16 +711,6 @@ struct address_space *page_mapping(struct page *page)
 }
 EXPORT_SYMBOL(page_mapping);
 
-/*
- * For file cache pages, return the address_space, otherwise return NULL
- */
-struct address_space *page_mapping_file(struct page *page)
-{
-	if (unlikely(PageSwapCache(page)))
-		return NULL;
-	return page_mapping(page);
-}
-
 /* Slow path of page_mapcount() for compound pages */
 int __page_mapcount(struct page *page)
 {
-- 
2.30.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-16 17:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-16 14:10 [PATCH] mm: Move page_mapping_file to pagemap.h Matthew Wilcox (Oracle)
2021-03-16 16:03 ` kernel test robot
2021-03-16 17:18 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox