[v9,77/96] mm/filemap: Add filemap_alloc_folio
diff mbox series

Message ID 20210505150628.111735-78-willy@infradead.org
State New, archived
Headers show
Series
  • Memory folios
Related show

Commit Message

Matthew Wilcox May 5, 2021, 3:06 p.m. UTC
Reimplement __page_cache_alloc as a wrapper around filemap_alloc_folio
to allow filesystems to be converted at our leisure.  Increases
kernel text size by 133 bytes, mostly in cachefiles_read_backing_file().
pagecache_get_page() shrinks by 32 bytes, though.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 include/linux/pagemap.h | 11 ++++++++---
 mm/filemap.c            | 14 +++++++-------
 2 files changed, 15 insertions(+), 10 deletions(-)

Comments

kernel test robot May 6, 2021, midnight UTC | #1
Hi "Matthew,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on next-20210505]
[cannot apply to hnaz-linux-mm/master xfs-linux/for-next tip/perf/core shaggy/jfs-next block/for-next linus/master asm-generic/master v5.12 v5.12-rc8 v5.12-rc7 v5.12]
[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/Matthew-Wilcox-Oracle/Memory-folios/20210506-014108
base:    29955e0289b3255c5f609a7564a0f0bb4ae35c7a
config: x86_64-randconfig-s031-20210505 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-341-g8af24329-dirty
        # https://github.com/0day-ci/linux/commit/f694d0d59ba326a2db7840f6ff0a455620cdcaa1
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Matthew-Wilcox-Oracle/Memory-folios/20210506-014108
        git checkout f694d0d59ba326a2db7840f6ff0a455620cdcaa1
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)
>> mm/filemap.c:1000:52: sparse: sparse: incorrect type in argument 1 (different base types) @@     expected restricted gfp_t [usertype] gfp @@     got int [assigned] n @@
   mm/filemap.c:1000:52: sparse:     expected restricted gfp_t [usertype] gfp
   mm/filemap.c:1000:52: sparse:     got int [assigned] n
>> mm/filemap.c:1000:55: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected unsigned int order @@     got restricted gfp_t [usertype] gfp @@
   mm/filemap.c:1000:55: sparse:     expected unsigned int order
   mm/filemap.c:1000:55: sparse:     got restricted gfp_t [usertype] gfp

vim +1000 mm/filemap.c

   988	
   989	#ifdef CONFIG_NUMA
   990	struct folio *filemap_alloc_folio(gfp_t gfp, unsigned int order)
   991	{
   992		int n;
   993		struct folio *folio;
   994	
   995		if (cpuset_do_page_mem_spread()) {
   996			unsigned int cpuset_mems_cookie;
   997			do {
   998				cpuset_mems_cookie = read_mems_allowed_begin();
   999				n = cpuset_mem_spread_node();
> 1000				folio = __alloc_folio_node(n, gfp, order);
  1001			} while (!folio && read_mems_allowed_retry(cpuset_mems_cookie));
  1002	
  1003			return folio;
  1004		}
  1005		return alloc_folio(gfp, order);
  1006	}
  1007	EXPORT_SYMBOL(filemap_alloc_folio);
  1008	#endif
  1009	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Matthew Wilcox May 6, 2021, 2:28 a.m. UTC | #2
On Thu, May 06, 2021 at 08:00:25AM +0800, kernel test robot wrote:
> sparse warnings: (new ones prefixed by >>)
> >> mm/filemap.c:1000:52: sparse: sparse: incorrect type in argument 1 (different base types) @@     expected restricted gfp_t [usertype] gfp @@     got int [assigned] n @@
>    mm/filemap.c:1000:52: sparse:     expected restricted gfp_t [usertype] gfp
>    mm/filemap.c:1000:52: sparse:     got int [assigned] n
> >> mm/filemap.c:1000:55: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected unsigned int order @@     got restricted gfp_t [usertype] gfp @@
>    mm/filemap.c:1000:55: sparse:     expected unsigned int order
>    mm/filemap.c:1000:55: sparse:     got restricted gfp_t [usertype] gfp

fixed

Patch
diff mbox series

diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index d54772aa7a3a..64370f615aba 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -338,14 +338,19 @@  static inline void *detach_page_private(struct page *page)
 }
 
 #ifdef CONFIG_NUMA
-extern struct page *__page_cache_alloc(gfp_t gfp);
+extern struct folio *filemap_alloc_folio(gfp_t gfp, unsigned int order);
 #else
-static inline struct page *__page_cache_alloc(gfp_t gfp)
+static inline struct folio *filemap_alloc_folio(gfp_t gfp, unsigned int order)
 {
-	return alloc_pages(gfp, 0);
+	return alloc_folio(gfp, order);
 }
 #endif
 
+static inline struct page *__page_cache_alloc(gfp_t gfp)
+{
+	return &filemap_alloc_folio(gfp, 0)->page;
+}
+
 static inline struct page *page_cache_alloc(struct address_space *x)
 {
 	return __page_cache_alloc(mapping_gfp_mask(x));
diff --git a/mm/filemap.c b/mm/filemap.c
index 5c130bfcdb1c..a9c16f05b863 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -987,24 +987,24 @@  int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
 EXPORT_SYMBOL_GPL(add_to_page_cache_lru);
 
 #ifdef CONFIG_NUMA
-struct page *__page_cache_alloc(gfp_t gfp)
+struct folio *filemap_alloc_folio(gfp_t gfp, unsigned int order)
 {
 	int n;
-	struct page *page;
+	struct folio *folio;
 
 	if (cpuset_do_page_mem_spread()) {
 		unsigned int cpuset_mems_cookie;
 		do {
 			cpuset_mems_cookie = read_mems_allowed_begin();
 			n = cpuset_mem_spread_node();
-			page = __alloc_pages_node(n, gfp, 0);
-		} while (!page && read_mems_allowed_retry(cpuset_mems_cookie));
+			folio = __alloc_folio_node(n, gfp, order);
+		} while (!folio && read_mems_allowed_retry(cpuset_mems_cookie));
 
-		return page;
+		return folio;
 	}
-	return alloc_pages(gfp, 0);
+	return alloc_folio(gfp, order);
 }
-EXPORT_SYMBOL(__page_cache_alloc);
+EXPORT_SYMBOL(filemap_alloc_folio);
 #endif
 
 /*