mm: Move page_mapping_file to pagemap.h
Subsystems (3)
Matthew Wilcox (Oracle)
maintainerPATCH 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.
---
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(-)
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
kernel test robot
build botThank you for the patch! Yet something to improve:
Hi "Matthew,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on hnaz-linux-mm/master]
url: https://github.com/0day-ci/linux/commits/Matthew-Wilcox-Oracle/mm-Move-page_mapping_file-to-pagemap-h/20210316-221138 base: https://github.com/hnaz/linux-mm master config: nios2-defconfig (attached as .config) compiler: nios2-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/5f7b112de945843f38fbf9f602dd547010e8b8d0
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Matthew-Wilcox-Oracle/mm-Move-page_mapping_file-to-pagemap-h/20210316-221138 git checkout 5f7b112de945843f38fbf9f602dd547010e8b8d0
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=nios2
If you fix the issue, kindly add following tag as appropriate
All error/warnings (new ones prefixed by >>):
arch/nios2/mm/cacheflush.c:160:6: warning: no previous prototype for '__flush_dcache_page' [-Wmissing-prototypes]
160 | void __flush_dcache_page(struct address_space *mapping, struct page *page)
| ^~~~~~~~~~~~~~~~~~~
arch/nios2/mm/cacheflush.c: In function 'flush_dcache_page':
>> arch/nios2/mm/cacheflush.c:183:12: error: implicit declaration of function 'page_mapping_file'; did you mean 'page_mapping'? [-Werror=implicit-function-declaration]
183 | mapping = page_mapping_file(page);
| ^~~~~~~~~~~~~~~~~
| page_mapping
>> arch/nios2/mm/cacheflush.c:183:10: warning: assignment to 'struct address_space *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
183 | mapping = page_mapping_file(page);
| ^
arch/nios2/mm/cacheflush.c: In function 'update_mmu_cache':
arch/nios2/mm/cacheflush.c:221:10: warning: assignment to 'struct address_space *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
221 | mapping = page_mapping_file(page);
| ^cc1: some warnings being treated as errors
vim +183 arch/nios2/mm/cacheflush.c
93c91cb228e76b Ley Foon Tan 2014-11-06 159
1a70db49a73535 Ley Foon Tan 2015-04-24 @160 void __flush_dcache_page(struct address_space *mapping, struct page *page)
1a70db49a73535 Ley Foon Tan 2015-04-24 161 {
1a70db49a73535 Ley Foon Tan 2015-04-24 162 /*
1a70db49a73535 Ley Foon Tan 2015-04-24 163 * Writeback any data associated with the kernel mapping of this
1a70db49a73535 Ley Foon Tan 2015-04-24 164 * page. This ensures that data in the physical page is mutually
1a70db49a73535 Ley Foon Tan 2015-04-24 165 * coherent with the kernels mapping.
1a70db49a73535 Ley Foon Tan 2015-04-24 166 */
1a70db49a73535 Ley Foon Tan 2015-04-24 167 unsigned long start = (unsigned long)page_address(page);
1a70db49a73535 Ley Foon Tan 2015-04-24 168
8e3d7c834ba0f7 Ley Foon Tan 2015-11-26 169 __flush_dcache(start, start + PAGE_SIZE);
1a70db49a73535 Ley Foon Tan 2015-04-24 170 }
1a70db49a73535 Ley Foon Tan 2015-04-24 171
93c91cb228e76b Ley Foon Tan 2014-11-06 172 void flush_dcache_page(struct page *page)
93c91cb228e76b Ley Foon Tan 2014-11-06 173 {
93c91cb228e76b Ley Foon Tan 2014-11-06 174 struct address_space *mapping;
93c91cb228e76b Ley Foon Tan 2014-11-06 175
93c91cb228e76b Ley Foon Tan 2014-11-06 176 /*
93c91cb228e76b Ley Foon Tan 2014-11-06 177 * The zero page is never written to, so never has any dirty
93c91cb228e76b Ley Foon Tan 2014-11-06 178 * cache lines, and therefore never needs to be flushed.
93c91cb228e76b Ley Foon Tan 2014-11-06 179 */
93c91cb228e76b Ley Foon Tan 2014-11-06 180 if (page == ZERO_PAGE(0))
93c91cb228e76b Ley Foon Tan 2014-11-06 181 return;
93c91cb228e76b Ley Foon Tan 2014-11-06 182
cb9f753a3731f7 Huang Ying 2018-04-05 @183 mapping = page_mapping_file(page);
93c91cb228e76b Ley Foon Tan 2014-11-06 184
93c91cb228e76b Ley Foon Tan 2014-11-06 185 /* Flush this page if there are aliases. */
93c91cb228e76b Ley Foon Tan 2014-11-06 186 if (mapping && !mapping_mapped(mapping)) {
93c91cb228e76b Ley Foon Tan 2014-11-06 187 clear_bit(PG_dcache_clean, &page->flags);
93c91cb228e76b Ley Foon Tan 2014-11-06 188 } else {
1a70db49a73535 Ley Foon Tan 2015-04-24 189 __flush_dcache_page(mapping, page);
1a70db49a73535 Ley Foon Tan 2015-04-24 190 if (mapping) {
93c91cb228e76b Ley Foon Tan 2014-11-06 191 unsigned long start = (unsigned long)page_address(page);
93c91cb228e76b Ley Foon Tan 2014-11-06 192 flush_aliases(mapping, page);
1a70db49a73535 Ley Foon Tan 2015-04-24 193 flush_icache_range(start, start + PAGE_SIZE);
1a70db49a73535 Ley Foon Tan 2015-04-24 194 }
93c91cb228e76b Ley Foon Tan 2014-11-06 195 set_bit(PG_dcache_clean, &page->flags);
93c91cb228e76b Ley Foon Tan 2014-11-06 196 }
93c91cb228e76b Ley Foon Tan 2014-11-06 197 }
93c91cb228e76b Ley Foon Tan 2014-11-06 198 EXPORT_SYMBOL(flush_dcache_page);
93c91cb228e76b Ley Foon Tan 2014-11-06 199 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botThank you for the patch! Yet something to improve:
Hi "Matthew,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on hnaz-linux-mm/master]
url: https://github.com/0day-ci/linux/commits/Matthew-Wilcox-Oracle/mm-Move-page_mapping_file-to-pagemap-h/20210316-221138 base: https://github.com/hnaz/linux-mm master config: mips-randconfig-r032-20210316 (attached as .config) compiler: mips-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/5f7b112de945843f38fbf9f602dd547010e8b8d0
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Matthew-Wilcox-Oracle/mm-Move-page_mapping_file-to-pagemap-h/20210316-221138 git checkout 5f7b112de945843f38fbf9f602dd547010e8b8d0
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=mips
If you fix the issue, kindly add following tag as appropriate
All error/warnings (new ones prefixed by >>):
arch/mips/mm/cache.c: In function '__flush_dcache_page':
>> arch/mips/mm/cache.c:85:34: error: implicit declaration of function 'page_mapping_file'; did you mean 'page_mapping'? [-Werror=implicit-function-declaration]
85 | struct address_space *mapping = page_mapping_file(page);
| ^~~~~~~~~~~~~~~~~
| page_mapping
>> arch/mips/mm/cache.c:85:34: warning: initialization of 'struct address_space *' from 'int' makes pointer from integer without a cast [-Wint-conversion] arch/mips/mm/cache.c: At top level:
arch/mips/mm/cache.c:129:6: warning: no previous prototype for '__update_cache' [-Wmissing-prototypes]
129 | void __update_cache(unsigned long address, pte_t pte)
| ^~~~~~~~~~~~~~
arch/mips/mm/cache.c:236:12: warning: no previous prototype for '__uncached_access' [-Wmissing-prototypes]
236 | int __weak __uncached_access(struct file *file, unsigned long addr)
| ^~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +85 arch/mips/mm/cache.c
^1da177e4c3f41 Linus Torvalds 2005-04-16 82
^1da177e4c3f41 Linus Torvalds 2005-04-16 83 void __flush_dcache_page(struct page *page)
^1da177e4c3f41 Linus Torvalds 2005-04-16 84 {
cb9f753a3731f7 Huang Ying 2018-04-05 @85 struct address_space *mapping = page_mapping_file(page);
^1da177e4c3f41 Linus Torvalds 2005-04-16 86 unsigned long addr;
^1da177e4c3f41 Linus Torvalds 2005-04-16 87
^1da177e4c3f41 Linus Torvalds 2005-04-16 88 if (mapping && !mapping_mapped(mapping)) {
^1da177e4c3f41 Linus Torvalds 2005-04-16 89 SetPageDcacheDirty(page);
^1da177e4c3f41 Linus Torvalds 2005-04-16 90 return;
^1da177e4c3f41 Linus Torvalds 2005-04-16 91 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 92
^1da177e4c3f41 Linus Torvalds 2005-04-16 93 /*
^1da177e4c3f41 Linus Torvalds 2005-04-16 94 * We could delay the flush for the !page_mapping case too. But that
^1da177e4c3f41 Linus Torvalds 2005-04-16 95 * case is for exec env/arg pages and those are %99 certainly going to
^1da177e4c3f41 Linus Torvalds 2005-04-16 96 * get faulted into the tlb (and thus flushed) anyways.
^1da177e4c3f41 Linus Torvalds 2005-04-16 97 */
234859e49a1532 Paul Burton 2016-03-01 98 if (PageHighMem(page))
234859e49a1532 Paul Burton 2016-03-01 99 addr = (unsigned long)kmap_atomic(page);
234859e49a1532 Paul Burton 2016-03-01 100 else
^1da177e4c3f41 Linus Torvalds 2005-04-16 101 addr = (unsigned long)page_address(page);
234859e49a1532 Paul Burton 2016-03-01 102
^1da177e4c3f41 Linus Torvalds 2005-04-16 103 flush_data_cache_page(addr);
234859e49a1532 Paul Burton 2016-03-01 104
234859e49a1532 Paul Burton 2016-03-01 105 if (PageHighMem(page))
abca2500c0c1b2 Ira Weiny 2020-06-04 106 kunmap_atomic((void *)addr);
^1da177e4c3f41 Linus Torvalds 2005-04-16 107 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 108 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org