All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mm: Move page_mapping_file to pagemap.h
@ 2021-03-17 12:30 Matthew Wilcox (Oracle)
  2021-03-17 13:20 ` David Hildenbrand
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Matthew Wilcox (Oracle) @ 2021-03-17 12:30 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Matthew Wilcox (Oracle),
	linux-mm, Huang Ying, Mike Rapoport, linux-kernel

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>
---
v2: Ensure pagemap.h is included in all the files which use page_mapping_file
 arch/arm/mm/copypage-v4mc.c   |  1 +
 arch/arm/mm/copypage-v6.c     |  1 +
 arch/arm/mm/copypage-xscale.c |  1 +
 arch/csky/abiv1/cacheflush.c  |  1 +
 arch/mips/mm/cache.c          |  1 +
 arch/nios2/mm/cacheflush.c    |  1 +
 arch/sh/mm/cache-sh4.c        |  1 +
 arch/sh/mm/cache-sh7705.c     |  1 +
 arch/sparc/mm/tlb.c           |  1 +
 include/linux/mm.h            |  1 -
 include/linux/pagemap.h       | 10 ++++++++++
 mm/util.c                     | 10 ----------
 12 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mm/copypage-v4mc.c b/arch/arm/mm/copypage-v4mc.c
index 44f7292ec27b..f1da3b439b96 100644
--- a/arch/arm/mm/copypage-v4mc.c
+++ b/arch/arm/mm/copypage-v4mc.c
@@ -13,6 +13,7 @@
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <linux/highmem.h>
+#include <linux/pagemap.h>
 
 #include <asm/tlbflush.h>
 #include <asm/cacheflush.h>
diff --git a/arch/arm/mm/copypage-v6.c b/arch/arm/mm/copypage-v6.c
index 6a769a6c314e..d8a115de5507 100644
--- a/arch/arm/mm/copypage-v6.c
+++ b/arch/arm/mm/copypage-v6.c
@@ -8,6 +8,7 @@
 #include <linux/spinlock.h>
 #include <linux/mm.h>
 #include <linux/highmem.h>
+#include <linux/pagemap.h>
 
 #include <asm/shmparam.h>
 #include <asm/tlbflush.h>
diff --git a/arch/arm/mm/copypage-xscale.c b/arch/arm/mm/copypage-xscale.c
index eb5d338657d1..bcb485620a05 100644
--- a/arch/arm/mm/copypage-xscale.c
+++ b/arch/arm/mm/copypage-xscale.c
@@ -13,6 +13,7 @@
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <linux/highmem.h>
+#include <linux/pagemap.h>
 
 #include <asm/tlbflush.h>
 #include <asm/cacheflush.h>
diff --git a/arch/csky/abiv1/cacheflush.c b/arch/csky/abiv1/cacheflush.c
index 9f1fe80cc847..07ff17ea33de 100644
--- a/arch/csky/abiv1/cacheflush.c
+++ b/arch/csky/abiv1/cacheflush.c
@@ -4,6 +4,7 @@
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/fs.h>
+#include <linux/pagemap.h>
 #include <linux/syscalls.h>
 #include <linux/spinlock.h>
 #include <asm/page.h>
diff --git a/arch/mips/mm/cache.c b/arch/mips/mm/cache.c
index 7719d632df8d..a7bf0c80371c 100644
--- a/arch/mips/mm/cache.c
+++ b/arch/mips/mm/cache.c
@@ -15,6 +15,7 @@
 #include <linux/syscalls.h>
 #include <linux/mm.h>
 #include <linux/highmem.h>
+#include <linux/pagemap.h>
 
 #include <asm/cacheflush.h>
 #include <asm/processor.h>
diff --git a/arch/nios2/mm/cacheflush.c b/arch/nios2/mm/cacheflush.c
index 65de1bd6a760..6aa9257c3ede 100644
--- a/arch/nios2/mm/cacheflush.c
+++ b/arch/nios2/mm/cacheflush.c
@@ -11,6 +11,7 @@
 #include <linux/sched.h>
 #include <linux/mm.h>
 #include <linux/fs.h>
+#include <linux/pagemap.h>
 
 #include <asm/cacheflush.h>
 #include <asm/cpuinfo.h>
diff --git a/arch/sh/mm/cache-sh4.c b/arch/sh/mm/cache-sh4.c
index ddfa9685f1ef..72c2e1b46c08 100644
--- a/arch/sh/mm/cache-sh4.c
+++ b/arch/sh/mm/cache-sh4.c
@@ -16,6 +16,7 @@
 #include <linux/mutex.h>
 #include <linux/fs.h>
 #include <linux/highmem.h>
+#include <linux/pagemap.h>
 #include <asm/mmu_context.h>
 #include <asm/cache_insns.h>
 #include <asm/cacheflush.h>
diff --git a/arch/sh/mm/cache-sh7705.c b/arch/sh/mm/cache-sh7705.c
index 4c67b3d88775..9b63a53a5e46 100644
--- a/arch/sh/mm/cache-sh7705.c
+++ b/arch/sh/mm/cache-sh7705.c
@@ -13,6 +13,7 @@
 #include <linux/mman.h>
 #include <linux/mm.h>
 #include <linux/fs.h>
+#include <linux/pagemap.h>
 #include <linux/threads.h>
 #include <asm/addrspace.h>
 #include <asm/page.h>
diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c
index 20ee14739333..9a725547578e 100644
--- a/arch/sparc/mm/tlb.c
+++ b/arch/sparc/mm/tlb.c
@@ -9,6 +9,7 @@
 #include <linux/mm.h>
 #include <linux/swap.h>
 #include <linux/preempt.h>
+#include <linux/pagemap.h>
 
 #include <asm/tlbflush.h>
 #include <asm/cacheflush.h>
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] 5+ messages in thread

* Re: [PATCH v2] mm: Move page_mapping_file to pagemap.h
  2021-03-17 12:30 [PATCH v2] mm: Move page_mapping_file to pagemap.h Matthew Wilcox (Oracle)
@ 2021-03-17 13:20 ` David Hildenbrand
  2021-03-17 14:17 ` Mike Rapoport
  2021-03-30 17:11 ` Mike Rapoport
  2 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2021-03-17 13:20 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle), Andrew Morton
  Cc: linux-mm, Huang Ying, Mike Rapoport, linux-kernel

On 17.03.21 13:30, Matthew Wilcox (Oracle) wrote:
> 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>
> ---
> v2: Ensure pagemap.h is included in all the files which use page_mapping_file
>   arch/arm/mm/copypage-v4mc.c   |  1 +
>   arch/arm/mm/copypage-v6.c     |  1 +
>   arch/arm/mm/copypage-xscale.c |  1 +
>   arch/csky/abiv1/cacheflush.c  |  1 +
>   arch/mips/mm/cache.c          |  1 +
>   arch/nios2/mm/cacheflush.c    |  1 +
>   arch/sh/mm/cache-sh4.c        |  1 +
>   arch/sh/mm/cache-sh7705.c     |  1 +
>   arch/sparc/mm/tlb.c           |  1 +
>   include/linux/mm.h            |  1 -
>   include/linux/pagemap.h       | 10 ++++++++++
>   mm/util.c                     | 10 ----------
>   12 files changed, 19 insertions(+), 11 deletions(-)
> 
> diff --git a/arch/arm/mm/copypage-v4mc.c b/arch/arm/mm/copypage-v4mc.c
> index 44f7292ec27b..f1da3b439b96 100644
> --- a/arch/arm/mm/copypage-v4mc.c
> +++ b/arch/arm/mm/copypage-v4mc.c
> @@ -13,6 +13,7 @@
>   #include <linux/init.h>
>   #include <linux/mm.h>
>   #include <linux/highmem.h>
> +#include <linux/pagemap.h>
>   
>   #include <asm/tlbflush.h>
>   #include <asm/cacheflush.h>
> diff --git a/arch/arm/mm/copypage-v6.c b/arch/arm/mm/copypage-v6.c
> index 6a769a6c314e..d8a115de5507 100644
> --- a/arch/arm/mm/copypage-v6.c
> +++ b/arch/arm/mm/copypage-v6.c
> @@ -8,6 +8,7 @@
>   #include <linux/spinlock.h>
>   #include <linux/mm.h>
>   #include <linux/highmem.h>
> +#include <linux/pagemap.h>
>   
>   #include <asm/shmparam.h>
>   #include <asm/tlbflush.h>
> diff --git a/arch/arm/mm/copypage-xscale.c b/arch/arm/mm/copypage-xscale.c
> index eb5d338657d1..bcb485620a05 100644
> --- a/arch/arm/mm/copypage-xscale.c
> +++ b/arch/arm/mm/copypage-xscale.c
> @@ -13,6 +13,7 @@
>   #include <linux/init.h>
>   #include <linux/mm.h>
>   #include <linux/highmem.h>
> +#include <linux/pagemap.h>
>   
>   #include <asm/tlbflush.h>
>   #include <asm/cacheflush.h>
> diff --git a/arch/csky/abiv1/cacheflush.c b/arch/csky/abiv1/cacheflush.c
> index 9f1fe80cc847..07ff17ea33de 100644
> --- a/arch/csky/abiv1/cacheflush.c
> +++ b/arch/csky/abiv1/cacheflush.c
> @@ -4,6 +4,7 @@
>   #include <linux/kernel.h>
>   #include <linux/mm.h>
>   #include <linux/fs.h>
> +#include <linux/pagemap.h>
>   #include <linux/syscalls.h>
>   #include <linux/spinlock.h>
>   #include <asm/page.h>
> diff --git a/arch/mips/mm/cache.c b/arch/mips/mm/cache.c
> index 7719d632df8d..a7bf0c80371c 100644
> --- a/arch/mips/mm/cache.c
> +++ b/arch/mips/mm/cache.c
> @@ -15,6 +15,7 @@
>   #include <linux/syscalls.h>
>   #include <linux/mm.h>
>   #include <linux/highmem.h>
> +#include <linux/pagemap.h>
>   
>   #include <asm/cacheflush.h>
>   #include <asm/processor.h>
> diff --git a/arch/nios2/mm/cacheflush.c b/arch/nios2/mm/cacheflush.c
> index 65de1bd6a760..6aa9257c3ede 100644
> --- a/arch/nios2/mm/cacheflush.c
> +++ b/arch/nios2/mm/cacheflush.c
> @@ -11,6 +11,7 @@
>   #include <linux/sched.h>
>   #include <linux/mm.h>
>   #include <linux/fs.h>
> +#include <linux/pagemap.h>
>   
>   #include <asm/cacheflush.h>
>   #include <asm/cpuinfo.h>
> diff --git a/arch/sh/mm/cache-sh4.c b/arch/sh/mm/cache-sh4.c
> index ddfa9685f1ef..72c2e1b46c08 100644
> --- a/arch/sh/mm/cache-sh4.c
> +++ b/arch/sh/mm/cache-sh4.c
> @@ -16,6 +16,7 @@
>   #include <linux/mutex.h>
>   #include <linux/fs.h>
>   #include <linux/highmem.h>
> +#include <linux/pagemap.h>
>   #include <asm/mmu_context.h>
>   #include <asm/cache_insns.h>
>   #include <asm/cacheflush.h>
> diff --git a/arch/sh/mm/cache-sh7705.c b/arch/sh/mm/cache-sh7705.c
> index 4c67b3d88775..9b63a53a5e46 100644
> --- a/arch/sh/mm/cache-sh7705.c
> +++ b/arch/sh/mm/cache-sh7705.c
> @@ -13,6 +13,7 @@
>   #include <linux/mman.h>
>   #include <linux/mm.h>
>   #include <linux/fs.h>
> +#include <linux/pagemap.h>
>   #include <linux/threads.h>
>   #include <asm/addrspace.h>
>   #include <asm/page.h>
> diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c
> index 20ee14739333..9a725547578e 100644
> --- a/arch/sparc/mm/tlb.c
> +++ b/arch/sparc/mm/tlb.c
> @@ -9,6 +9,7 @@
>   #include <linux/mm.h>
>   #include <linux/swap.h>
>   #include <linux/preempt.h>
> +#include <linux/pagemap.h>
>   
>   #include <asm/tlbflush.h>
>   #include <asm/cacheflush.h>
> 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)
>   {
> 

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb


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

* Re: [PATCH v2] mm: Move page_mapping_file to pagemap.h
  2021-03-17 12:30 [PATCH v2] mm: Move page_mapping_file to pagemap.h Matthew Wilcox (Oracle)
  2021-03-17 13:20 ` David Hildenbrand
@ 2021-03-17 14:17 ` Mike Rapoport
  2021-03-30 17:11 ` Mike Rapoport
  2 siblings, 0 replies; 5+ messages in thread
From: Mike Rapoport @ 2021-03-17 14:17 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle)
  Cc: Andrew Morton, linux-mm, Huang Ying, Mike Rapoport, linux-kernel

On Wed, Mar 17, 2021 at 12:30:11PM +0000, Matthew Wilcox (Oracle) wrote:
> 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>

Acked-by: Mike Rapoport <rppt@linux.ibm.com>

> ---
> v2: Ensure pagemap.h is included in all the files which use page_mapping_file
>  arch/arm/mm/copypage-v4mc.c   |  1 +
>  arch/arm/mm/copypage-v6.c     |  1 +
>  arch/arm/mm/copypage-xscale.c |  1 +
>  arch/csky/abiv1/cacheflush.c  |  1 +
>  arch/mips/mm/cache.c          |  1 +
>  arch/nios2/mm/cacheflush.c    |  1 +
>  arch/sh/mm/cache-sh4.c        |  1 +
>  arch/sh/mm/cache-sh7705.c     |  1 +
>  arch/sparc/mm/tlb.c           |  1 +
>  include/linux/mm.h            |  1 -
>  include/linux/pagemap.h       | 10 ++++++++++
>  mm/util.c                     | 10 ----------
>  12 files changed, 19 insertions(+), 11 deletions(-)
> 
> diff --git a/arch/arm/mm/copypage-v4mc.c b/arch/arm/mm/copypage-v4mc.c
> index 44f7292ec27b..f1da3b439b96 100644
> --- a/arch/arm/mm/copypage-v4mc.c
> +++ b/arch/arm/mm/copypage-v4mc.c
> @@ -13,6 +13,7 @@
>  #include <linux/init.h>
>  #include <linux/mm.h>
>  #include <linux/highmem.h>
> +#include <linux/pagemap.h>
> 
>  #include <asm/tlbflush.h>
>  #include <asm/cacheflush.h>
> diff --git a/arch/arm/mm/copypage-v6.c b/arch/arm/mm/copypage-v6.c
> index 6a769a6c314e..d8a115de5507 100644
> --- a/arch/arm/mm/copypage-v6.c
> +++ b/arch/arm/mm/copypage-v6.c
> @@ -8,6 +8,7 @@
>  #include <linux/spinlock.h>
>  #include <linux/mm.h>
>  #include <linux/highmem.h>
> +#include <linux/pagemap.h>
> 
>  #include <asm/shmparam.h>
>  #include <asm/tlbflush.h>
> diff --git a/arch/arm/mm/copypage-xscale.c b/arch/arm/mm/copypage-xscale.c
> index eb5d338657d1..bcb485620a05 100644
> --- a/arch/arm/mm/copypage-xscale.c
> +++ b/arch/arm/mm/copypage-xscale.c
> @@ -13,6 +13,7 @@
>  #include <linux/init.h>
>  #include <linux/mm.h>
>  #include <linux/highmem.h>
> +#include <linux/pagemap.h>
> 
>  #include <asm/tlbflush.h>
>  #include <asm/cacheflush.h>
> diff --git a/arch/csky/abiv1/cacheflush.c b/arch/csky/abiv1/cacheflush.c
> index 9f1fe80cc847..07ff17ea33de 100644
> --- a/arch/csky/abiv1/cacheflush.c
> +++ b/arch/csky/abiv1/cacheflush.c
> @@ -4,6 +4,7 @@
>  #include <linux/kernel.h>
>  #include <linux/mm.h>
>  #include <linux/fs.h>
> +#include <linux/pagemap.h>
>  #include <linux/syscalls.h>
>  #include <linux/spinlock.h>
>  #include <asm/page.h>
> diff --git a/arch/mips/mm/cache.c b/arch/mips/mm/cache.c
> index 7719d632df8d..a7bf0c80371c 100644
> --- a/arch/mips/mm/cache.c
> +++ b/arch/mips/mm/cache.c
> @@ -15,6 +15,7 @@
>  #include <linux/syscalls.h>
>  #include <linux/mm.h>
>  #include <linux/highmem.h>
> +#include <linux/pagemap.h>
> 
>  #include <asm/cacheflush.h>
>  #include <asm/processor.h>
> diff --git a/arch/nios2/mm/cacheflush.c b/arch/nios2/mm/cacheflush.c
> index 65de1bd6a760..6aa9257c3ede 100644
> --- a/arch/nios2/mm/cacheflush.c
> +++ b/arch/nios2/mm/cacheflush.c
> @@ -11,6 +11,7 @@
>  #include <linux/sched.h>
>  #include <linux/mm.h>
>  #include <linux/fs.h>
> +#include <linux/pagemap.h>
> 
>  #include <asm/cacheflush.h>
>  #include <asm/cpuinfo.h>
> diff --git a/arch/sh/mm/cache-sh4.c b/arch/sh/mm/cache-sh4.c
> index ddfa9685f1ef..72c2e1b46c08 100644
> --- a/arch/sh/mm/cache-sh4.c
> +++ b/arch/sh/mm/cache-sh4.c
> @@ -16,6 +16,7 @@
>  #include <linux/mutex.h>
>  #include <linux/fs.h>
>  #include <linux/highmem.h>
> +#include <linux/pagemap.h>
>  #include <asm/mmu_context.h>
>  #include <asm/cache_insns.h>
>  #include <asm/cacheflush.h>
> diff --git a/arch/sh/mm/cache-sh7705.c b/arch/sh/mm/cache-sh7705.c
> index 4c67b3d88775..9b63a53a5e46 100644
> --- a/arch/sh/mm/cache-sh7705.c
> +++ b/arch/sh/mm/cache-sh7705.c
> @@ -13,6 +13,7 @@
>  #include <linux/mman.h>
>  #include <linux/mm.h>
>  #include <linux/fs.h>
> +#include <linux/pagemap.h>
>  #include <linux/threads.h>
>  #include <asm/addrspace.h>
>  #include <asm/page.h>
> diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c
> index 20ee14739333..9a725547578e 100644
> --- a/arch/sparc/mm/tlb.c
> +++ b/arch/sparc/mm/tlb.c
> @@ -9,6 +9,7 @@
>  #include <linux/mm.h>
>  #include <linux/swap.h>
>  #include <linux/preempt.h>
> +#include <linux/pagemap.h>
> 
>  #include <asm/tlbflush.h>
>  #include <asm/cacheflush.h>
> 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
> 

-- 
Sincerely yours,
Mike.

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

* Re: [PATCH v2] mm: Move page_mapping_file to pagemap.h
  2021-03-17 12:30 [PATCH v2] mm: Move page_mapping_file to pagemap.h Matthew Wilcox (Oracle)
  2021-03-17 13:20 ` David Hildenbrand
  2021-03-17 14:17 ` Mike Rapoport
@ 2021-03-30 17:11 ` Mike Rapoport
  2021-03-30 17:14   ` Matthew Wilcox
  2 siblings, 1 reply; 5+ messages in thread
From: Mike Rapoport @ 2021-03-30 17:11 UTC (permalink / raw)
  To: Matthew Wilcox (Oracle)
  Cc: Andrew Morton, linux-mm, Huang Ying, Mike Rapoport, linux-kernel

On Wed, Mar 17, 2021 at 12:30:11PM +0000, Matthew Wilcox (Oracle) wrote:
> 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>
> ---
> v2: Ensure pagemap.h is included in all the files which use page_mapping_file
>  arch/arm/mm/copypage-v4mc.c   |  1 +
>  arch/arm/mm/copypage-v6.c     |  1 +
>  arch/arm/mm/copypage-xscale.c |  1 +
>  arch/csky/abiv1/cacheflush.c  |  1 +
>  arch/mips/mm/cache.c          |  1 +
>  arch/nios2/mm/cacheflush.c    |  1 +
>  arch/sh/mm/cache-sh4.c        |  1 +
>  arch/sh/mm/cache-sh7705.c     |  1 +
>  arch/sparc/mm/tlb.c           |  1 +
>  include/linux/mm.h            |  1 -
>  include/linux/pagemap.h       | 10 ++++++++++
>  mm/util.c                     | 10 ----------
>  12 files changed, 19 insertions(+), 11 deletions(-)
 
As the original commit that replaced page_mapping() with
page_mapping_file() [cb9f753a3731 ("mm: fix races between swapoff and flush
dcache")] missed arch/nds32 I think it'll make sense to add the below hunk
to this patch:

diff --git a/arch/nds32/mm/cacheflush.c b/arch/nds32/mm/cacheflush.c
index 6eb98a7ad27d..ad5344ef5d33 100644
--- a/arch/nds32/mm/cacheflush.c
+++ b/arch/nds32/mm/cacheflush.c
@@ -238,7 +238,7 @@ void flush_dcache_page(struct page *page)
 {
 	struct address_space *mapping;
 
-	mapping = page_mapping(page);
+	mapping = page_mapping_file(page);
 	if (mapping && !mapping_mapped(mapping))
 		set_bit(PG_dcache_dirty, &page->flags);
 	else {

> diff --git a/arch/arm/mm/copypage-v4mc.c b/arch/arm/mm/copypage-v4mc.c
> index 44f7292ec27b..f1da3b439b96 100644
> --- a/arch/arm/mm/copypage-v4mc.c
> +++ b/arch/arm/mm/copypage-v4mc.c
> @@ -13,6 +13,7 @@
>  #include <linux/init.h>
>  #include <linux/mm.h>
>  #include <linux/highmem.h>
> +#include <linux/pagemap.h>
> 
>  #include <asm/tlbflush.h>
>  #include <asm/cacheflush.h>
> diff --git a/arch/arm/mm/copypage-v6.c b/arch/arm/mm/copypage-v6.c
> index 6a769a6c314e..d8a115de5507 100644
> --- a/arch/arm/mm/copypage-v6.c
> +++ b/arch/arm/mm/copypage-v6.c
> @@ -8,6 +8,7 @@
>  #include <linux/spinlock.h>
>  #include <linux/mm.h>
>  #include <linux/highmem.h>
> +#include <linux/pagemap.h>
> 
>  #include <asm/shmparam.h>
>  #include <asm/tlbflush.h>
> diff --git a/arch/arm/mm/copypage-xscale.c b/arch/arm/mm/copypage-xscale.c
> index eb5d338657d1..bcb485620a05 100644
> --- a/arch/arm/mm/copypage-xscale.c
> +++ b/arch/arm/mm/copypage-xscale.c
> @@ -13,6 +13,7 @@
>  #include <linux/init.h>
>  #include <linux/mm.h>
>  #include <linux/highmem.h>
> +#include <linux/pagemap.h>
> 
>  #include <asm/tlbflush.h>
>  #include <asm/cacheflush.h>
> diff --git a/arch/csky/abiv1/cacheflush.c b/arch/csky/abiv1/cacheflush.c
> index 9f1fe80cc847..07ff17ea33de 100644
> --- a/arch/csky/abiv1/cacheflush.c
> +++ b/arch/csky/abiv1/cacheflush.c
> @@ -4,6 +4,7 @@
>  #include <linux/kernel.h>
>  #include <linux/mm.h>
>  #include <linux/fs.h>
> +#include <linux/pagemap.h>
>  #include <linux/syscalls.h>
>  #include <linux/spinlock.h>
>  #include <asm/page.h>
> diff --git a/arch/mips/mm/cache.c b/arch/mips/mm/cache.c
> index 7719d632df8d..a7bf0c80371c 100644
> --- a/arch/mips/mm/cache.c
> +++ b/arch/mips/mm/cache.c
> @@ -15,6 +15,7 @@
>  #include <linux/syscalls.h>
>  #include <linux/mm.h>
>  #include <linux/highmem.h>
> +#include <linux/pagemap.h>
> 
>  #include <asm/cacheflush.h>
>  #include <asm/processor.h>
> diff --git a/arch/nios2/mm/cacheflush.c b/arch/nios2/mm/cacheflush.c
> index 65de1bd6a760..6aa9257c3ede 100644
> --- a/arch/nios2/mm/cacheflush.c
> +++ b/arch/nios2/mm/cacheflush.c
> @@ -11,6 +11,7 @@
>  #include <linux/sched.h>
>  #include <linux/mm.h>
>  #include <linux/fs.h>
> +#include <linux/pagemap.h>
> 
>  #include <asm/cacheflush.h>
>  #include <asm/cpuinfo.h>
> diff --git a/arch/sh/mm/cache-sh4.c b/arch/sh/mm/cache-sh4.c
> index ddfa9685f1ef..72c2e1b46c08 100644
> --- a/arch/sh/mm/cache-sh4.c
> +++ b/arch/sh/mm/cache-sh4.c
> @@ -16,6 +16,7 @@
>  #include <linux/mutex.h>
>  #include <linux/fs.h>
>  #include <linux/highmem.h>
> +#include <linux/pagemap.h>
>  #include <asm/mmu_context.h>
>  #include <asm/cache_insns.h>
>  #include <asm/cacheflush.h>
> diff --git a/arch/sh/mm/cache-sh7705.c b/arch/sh/mm/cache-sh7705.c
> index 4c67b3d88775..9b63a53a5e46 100644
> --- a/arch/sh/mm/cache-sh7705.c
> +++ b/arch/sh/mm/cache-sh7705.c
> @@ -13,6 +13,7 @@
>  #include <linux/mman.h>
>  #include <linux/mm.h>
>  #include <linux/fs.h>
> +#include <linux/pagemap.h>
>  #include <linux/threads.h>
>  #include <asm/addrspace.h>
>  #include <asm/page.h>
> diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c
> index 20ee14739333..9a725547578e 100644
> --- a/arch/sparc/mm/tlb.c
> +++ b/arch/sparc/mm/tlb.c
> @@ -9,6 +9,7 @@
>  #include <linux/mm.h>
>  #include <linux/swap.h>
>  #include <linux/preempt.h>
> +#include <linux/pagemap.h>
> 
>  #include <asm/tlbflush.h>
>  #include <asm/cacheflush.h>
> 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
> 

-- 
Sincerely yours,
Mike.

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

* Re: [PATCH v2] mm: Move page_mapping_file to pagemap.h
  2021-03-30 17:11 ` Mike Rapoport
@ 2021-03-30 17:14   ` Matthew Wilcox
  0 siblings, 0 replies; 5+ messages in thread
From: Matthew Wilcox @ 2021-03-30 17:14 UTC (permalink / raw)
  To: Mike Rapoport
  Cc: Andrew Morton, linux-mm, Huang Ying, Mike Rapoport, linux-kernel

On Tue, Mar 30, 2021 at 08:11:19PM +0300, Mike Rapoport wrote:
> On Wed, Mar 17, 2021 at 12:30:11PM +0000, Matthew Wilcox (Oracle) wrote:
> > 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.
>  
> As the original commit that replaced page_mapping() with
> page_mapping_file() [cb9f753a3731 ("mm: fix races between swapoff and flush
> dcache")] missed arch/nds32 I think it'll make sense to add the below hunk
> to this patch:
> 
> diff --git a/arch/nds32/mm/cacheflush.c b/arch/nds32/mm/cacheflush.c
> index 6eb98a7ad27d..ad5344ef5d33 100644
> --- a/arch/nds32/mm/cacheflush.c
> +++ b/arch/nds32/mm/cacheflush.c
> @@ -238,7 +238,7 @@ void flush_dcache_page(struct page *page)
>  {
>  	struct address_space *mapping;
>  
> -	mapping = page_mapping(page);
> +	mapping = page_mapping_file(page);
>  	if (mapping && !mapping_mapped(mapping))
>  		set_bit(PG_dcache_dirty, &page->flags);
>  	else {

Good catch, but it's its own distinct problem, so I'd make it a separate
patch.

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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-17 12:30 [PATCH v2] mm: Move page_mapping_file to pagemap.h Matthew Wilcox (Oracle)
2021-03-17 13:20 ` David Hildenbrand
2021-03-17 14:17 ` Mike Rapoport
2021-03-30 17:11 ` Mike Rapoport
2021-03-30 17:14   ` Matthew Wilcox

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.