mm: Move page_mapping_file to pagemap.h
Subsystems (9)
Matthew Wilcox (Oracle)
maintainerPATCH v2 1/1 mm: Move page_mapping_file to pagemap.h
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.
---
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(-)
arch/arm/mm/copypage-v4mc.c +1 -0
@@ -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>
arch/arm/mm/copypage-v6.c +1 -0
@@ -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>
arch/arm/mm/copypage-xscale.c +1 -0
@@ -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>
arch/csky/abiv1/cacheflush.c +1 -0
@@ -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>
arch/mips/mm/cache.c +1 -0
@@ -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>
arch/nios2/mm/cacheflush.c +1 -0
@@ -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>
arch/sh/mm/cache-sh4.c +1 -0
@@ -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>
arch/sh/mm/cache-sh7705.c +1 -0
@@ -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>
arch/sparc/mm/tlb.c +1 -0
@@ -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>
include/linux/mm.h +0 -1
@@ -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
include/linux/pagemap.h +10 -0
@@ -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
mm/util.c +0 -10
@@ -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) {
Signature · 1 line
2.30.1
Quoted 174 lines · Matthew Wilcox (Oracle)
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) <[email protected]>---
v2: Ensurepagemap.his included in all the files which usepage_mapping_filearch/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(-)arch/arm/mm/copypage-v4mc.c +1
-0@@ -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> arch/arm/mm/copypage-v6.c +1
-0@@ -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> arch/arm/mm/copypage-xscale.c +1
-0@@ -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> arch/csky/abiv1/cacheflush.c +1
-0@@ -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> arch/mips/mm/cache.c +1
-0@@ -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> arch/nios2/mm/cacheflush.c +1
-0@@ -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> arch/sh/mm/cache-sh4.c +1
-0@@ -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> arch/sh/mm/cache-sh7705.c +1
-0@@ -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> arch/sparc/mm/tlb.c +1
-0@@ -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> include/linux/mm.h +0
-1@@ -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 include/linux/pagemap.h +10
-0@@ -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 mm/util.c +0
-3@@ -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 -*/
mm/util.c struct address_space *page_mapping(struct page *page) · line 716
Quoted 10 lines
mm/util.c +0
-7-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) {
Signature · 3 lines
Thanks, David / dhildenb
Quoted 5 lines · Matthew Wilcox (Oracle)
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) <[email protected]>
Quoted 181 lines
---
v2: Ensurepagemap.his included in all the files which usepage_mapping_filearch/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(-)arch/arm/mm/copypage-v4mc.c +1
-0@@ -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> arch/arm/mm/copypage-v6.c +1
-0@@ -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> arch/arm/mm/copypage-xscale.c +1
-0@@ -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> arch/csky/abiv1/cacheflush.c +1
-0@@ -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> arch/mips/mm/cache.c +1
-0@@ -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> arch/nios2/mm/cacheflush.c +1
-0@@ -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> arch/sh/mm/cache-sh4.c +1
-0@@ -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> arch/sh/mm/cache-sh7705.c +1
-0@@ -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> arch/sparc/mm/tlb.c +1
-0@@ -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> include/linux/mm.h +0
-1@@ -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 include/linux/pagemap.h +10
-0@@ -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 mm/util.c +0
-10@@ -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) {Signature · 1 line
2.30.1
Signature · 2 lines
Sincerely yours, Mike.
Quoted 7 lines · Matthew Wilcox (Oracle)
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) <[email protected]>---
v2: Ensurepagemap.his included in all the files which usepage_mapping_file
Quoted 13 lines
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:
arch/nds32/mm/cacheflush.c +1 -1
@@ -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 {
Quoted 165 lines
arch/arm/mm/copypage-v4mc.c +1
-0@@ -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> arch/arm/mm/copypage-v6.c +1
-0@@ -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> arch/arm/mm/copypage-xscale.c +1
-0@@ -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> arch/csky/abiv1/cacheflush.c +1
-0@@ -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> arch/mips/mm/cache.c +1
-0@@ -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> arch/nios2/mm/cacheflush.c +1
-0@@ -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> arch/sh/mm/cache-sh4.c +1
-0@@ -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> arch/sh/mm/cache-sh7705.c +1
-0@@ -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> arch/sparc/mm/tlb.c +1
-0@@ -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> include/linux/mm.h +0
-1@@ -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 include/linux/pagemap.h +10
-0@@ -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 mm/util.c +0
-10@@ -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) {Signature · 1 line
2.30.1
Signature · 2 lines
Sincerely yours, Mike.
Matthew Wilcox
maintainerQuoted 15 lines · Mike Rapoport
Quoted 3 lines · Matthew Wilcox (Oracle)
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()withpage_mapping_file()[cb9f753a3731("mm: fix races between swapoff and flush dcache")] missedarch/nds32I think it'll make sense to add the below hunk to this patch:arch/nds32/mm/cacheflush.c +0
-0
arch/nds32/mm/cacheflush.c void flush_dcache_page(struct page *page) · line 244
Quoted 8 lines
arch/nds32/mm/cacheflush.c +1
-1@@ -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.