Skip to contentSkip to conversation

minor cleanups of include/linux/mm.h

PATCH In review Mike Rapoport 3 participants 7 messages Apr 5, 2021

Subsystems (2)
lore
Share & tools
lore

Mike Rapoport

author reviewer
#0 lore raw

cover minor cleanups of include/linux/mm.h

From: Mike Rapoport <[email protected]>

Hi,

While looking at recent page_mapping_file() changes I've noticed that page_rmapping() and page_anon_vma() could be moved from include/linux/mm.h and we don't need two forward declarations of page_mapping().

I've also noticed that except page_mapping_file() we have somewhat similar page_file_mapping(), which seems superfluous, but I didn't dig further to see how one of them can be dropped.

The patches are vs v5.12-rc5-mmots-2021-03-31-22-26.

Mike Rapoport (2):
mm: move page_rmapping() and page_anon_vma() to mm/internal.h include/linux/mm.h: remove duplicated declaration of page_mapping()

 include/linux/mm.h | 4 ----
 mm/internal.h      | 3 +++
 2 files changed, 3 insertions(+), 4 deletions(-)
Signature · 1 line
2.28.0
author reviewer
#1 lore raw

PATCH 1/2 mm: move page_rmapping() and page_anon_vma() to mm/internal.h

From: Mike Rapoport <[email protected]>

The functions page_rmapping() and page_anon_vma() are not used outside core mm. Move their declaration from include/linux/mm.h to mm/internal.h

---
 include/linux/mm.h | 2 --
 mm/internal.h      | 3 +++
 2 files changed, 3 insertions(+), 2 deletions(-)
include/linux/mm.h +0 -2
index 8ec63f37a78d..74a05dbdcc19 100644
@@ -1619,8 +1619,6 @@ void page_address_init(void);
 #define page_address_init()  do { } while(0)
 #endif
 
-extern void *page_rmapping(struct page *page);
-extern struct anon_vma *page_anon_vma(struct page *page);
 extern struct address_space *page_mapping(struct page *page);
 
 extern struct address_space *__page_file_mapping(struct page *);
mm/internal.h +3 -0
index 547a8d7f0cbb..77e0b726eef3 100644
@@ -358,6 +358,9 @@ void __vma_link_list(struct mm_struct *mm, struct vm_area_struct *vma,
 		struct vm_area_struct *prev);
 void __vma_unlink_list(struct mm_struct *mm, struct vm_area_struct *vma);
 
+void *page_rmapping(struct page *page);
+struct anon_vma *page_anon_vma(struct page *page);
+
 #ifdef CONFIG_MMU
 extern long populate_vma_page_range(struct vm_area_struct *vma,
 		unsigned long start, unsigned long end, int *nonblocking);
Signature · 1 line
2.28.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] mm: move page_rmapping() and page_anon_vma() to mm/internal.h

Quoted 6 lines · Mike Rapoport

From: Mike Rapoport <[email protected]>

The functions page_rmapping() and page_anon_vma() are not used outside core mm. Move their declaration from include/linux/mm.h to mm/internal.h

This has purely textual conflicts with the folio series, but no conceptual conflicts. I generally approve of moving things out of mm.h, so

#3 lore raw

Re: [PATCH 1/2] mm: move page_rmapping() and page_anon_vma() to mm/internal.h

In reply to Mike Rapoport
I love your patch! Yet something to improve:

Hi Mike,

I love your patch! Yet something to improve:

[auto build test ERROR on hnaz-linux-mm/master]
[also build test ERROR on v5.12-rc6 next-20210401]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Mike-Rapoport/minor-cleanups-of-include-linux-mm-h/20210405-231514
base:   https://github.com/hnaz/linux-mm master
config: x86_64-randconfig-a004-20210405 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 2760a808b9916a2839513b7fd7314a464f52481e)

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
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://github.com/0day-ci/linux/commit/c025240d41e9b6388c57fd4cde4a520074e41539
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Mike-Rapoport/minor-cleanups-of-include-linux-mm-h/20210405-231514 git checkout c025240d41e9b6388c57fd4cde4a520074e41539
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

>> mm/page_idle.c:105:7: error: implicit declaration of function 'page_rmapping' [-Werror,-Wimplicit-function-declaration]
               !page_rmapping(page))
                ^
   mm/page_idle.c:105:7: note: did you mean 'page_mapping'?
   include/linux/mm.h:1549:23: note: 'page_mapping' declared here
   struct address_space *page_mapping(struct page *page);
                         ^

1 error generated.

vim +/page_rmapping +105 mm/page_idle.c

33c3fc71c8cfa3 Vladimir Davydov 2015-09-09   91  
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09   92  static void page_idle_clear_pte_refs(struct page *page)
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09   93  {
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09   94  	/*
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09   95  	 * Since rwc.arg is unused, rwc is effectively immutable, so we
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09   96  	 * can make it static const to save some cycles and stack.
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09   97  	 */
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09   98  	static const struct rmap_walk_control rwc = {
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09   99  		.rmap_one = page_idle_clear_pte_refs_one,
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09  100  		.anon_lock = page_lock_anon_vma_read,
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09  101  	};
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09  102  	bool need_lock;
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09  103  
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09  104  	if (!page_mapped(page) ||
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09 @105  	    !page_rmapping(page))
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09  106  		return;
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09  107  
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09  108  	need_lock = !PageAnon(page) || PageKsm(page);
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09  109  	if (need_lock && !trylock_page(page))
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09  110  		return;
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09  111  
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09  112  	rmap_walk(page, (struct rmap_walk_control *)&rwc);
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09  113  
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09  114  	if (need_lock)
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09  115  		unlock_page(page);
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09  116  }
33c3fc71c8cfa3 Vladimir Davydov 2015-09-09  117  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

author reviewer
#4 lore raw

PATCH 2/2 include/linux/mm.h: remove duplicated declaration of page_mapping()

In reply to Mike Rapoport

From: Mike Rapoport <[email protected]>

There are two declarations of page_mapping() in include/linux/mm.h a dozen lines apart.

Remove the older one with unnecessary "extern".

---
 include/linux/mm.h | 2 --
 1 file changed, 2 deletions(-)
include/linux/mm.h +0 -2
index 74a05dbdcc19..d831ca0fcfa1 100644
@@ -1619,8 +1619,6 @@ void page_address_init(void);
 #define page_address_init()  do { } while(0)
 #endif
 
-extern struct address_space *page_mapping(struct page *page);
-
 extern struct address_space *__page_file_mapping(struct page *);
 
 static inline
Signature · 1 line
2.28.0
#6 lore raw
In reply to Mike Rapoport
Quoted 3 lines · Mike Rapoport

I've also noticed that except page_mapping_file() we have somewhat similar page_file_mapping(), which seems superfluous, but I didn't dig further to see how one of them can be dropped.

They can't ;-( I looked at it, and they do different things.

+ * folio_file_mapping - Find the mapping this folio belongs to.
+ * @folio: The folio.
+ *
+ * For folios which are in the page cache, return the mapping that this
+ * page belongs to. Folios in the swap cache return the mapping of the
+ * swap file or swap device where the data is stored. This is different
+ * from the mapping returned by folio_mapping(). The only reason to
+ * use it is if, like NFS, you return 0 from ->activate_swapfile.

page_mapping_file() returns NULL for pages which are in the swap cache, as they no longer need the dcache flushed.