@@ -1002,11 +1002,16 @@ int filemap_add_folio(struct address_space *mapping, struct folio *folio,
10021002EXPORT_SYMBOL_GPL (filemap_add_folio );
10031003
10041004#ifdef CONFIG_NUMA
1005- struct folio * filemap_alloc_folio_noprof (gfp_t gfp , unsigned int order )
1005+ struct folio * filemap_alloc_folio_noprof (gfp_t gfp , unsigned int order ,
1006+ struct mempolicy * policy )
10061007{
10071008 int n ;
10081009 struct folio * folio ;
10091010
1011+ if (policy )
1012+ return folio_alloc_mpol_noprof (gfp , order , policy ,
1013+ NO_INTERLEAVE_INDEX , numa_node_id ());
1014+
10101015 if (cpuset_do_page_mem_spread ()) {
10111016 unsigned int cpuset_mems_cookie ;
10121017 do {
@@ -1923,11 +1928,12 @@ void *filemap_get_entry(struct address_space *mapping, pgoff_t index)
19231928}
19241929
19251930/**
1926- * __filemap_get_folio - Find and get a reference to a folio.
1931+ * __filemap_get_folio_mpol - Find and get a reference to a folio.
19271932 * @mapping: The address_space to search.
19281933 * @index: The page index.
19291934 * @fgp_flags: %FGP flags modify how the folio is returned.
19301935 * @gfp: Memory allocation flags to use if %FGP_CREAT is specified.
1936+ * @policy: NUMA memory allocation policy to follow.
19311937 *
19321938 * Looks up the page cache entry at @mapping & @index.
19331939 *
@@ -1938,8 +1944,8 @@ void *filemap_get_entry(struct address_space *mapping, pgoff_t index)
19381944 *
19391945 * Return: The found folio or an ERR_PTR() otherwise.
19401946 */
1941- struct folio * __filemap_get_folio (struct address_space * mapping , pgoff_t index ,
1942- fgf_t fgp_flags , gfp_t gfp )
1947+ struct folio * __filemap_get_folio_mpol (struct address_space * mapping ,
1948+ pgoff_t index , fgf_t fgp_flags , gfp_t gfp , struct mempolicy * policy )
19431949{
19441950 struct folio * folio ;
19451951
@@ -2009,7 +2015,7 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index,
20092015 err = - ENOMEM ;
20102016 if (order > min_order )
20112017 alloc_gfp |= __GFP_NORETRY | __GFP_NOWARN ;
2012- folio = filemap_alloc_folio (alloc_gfp , order );
2018+ folio = filemap_alloc_folio (alloc_gfp , order , policy );
20132019 if (!folio )
20142020 continue ;
20152021
@@ -2056,7 +2062,7 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index,
20562062 folio_clear_dropbehind (folio );
20572063 return folio ;
20582064}
2059- EXPORT_SYMBOL (__filemap_get_folio );
2065+ EXPORT_SYMBOL (__filemap_get_folio_mpol );
20602066
20612067static inline struct folio * find_get_entry (struct xa_state * xas , pgoff_t max ,
20622068 xa_mark_t mark )
@@ -2551,7 +2557,7 @@ static int filemap_create_folio(struct kiocb *iocb, struct folio_batch *fbatch)
25512557 if (iocb -> ki_flags & (IOCB_NOWAIT | IOCB_WAITQ ))
25522558 return - EAGAIN ;
25532559
2554- folio = filemap_alloc_folio (mapping_gfp_mask (mapping ), min_order );
2560+ folio = filemap_alloc_folio (mapping_gfp_mask (mapping ), min_order , NULL );
25552561 if (!folio )
25562562 return - ENOMEM ;
25572563 if (iocb -> ki_flags & IOCB_DONTCACHE )
@@ -3995,8 +4001,7 @@ static struct folio *do_read_cache_folio(struct address_space *mapping,
39954001repeat :
39964002 folio = filemap_get_folio (mapping , index );
39974003 if (IS_ERR (folio )) {
3998- folio = filemap_alloc_folio (gfp ,
3999- mapping_min_folio_order (mapping ));
4004+ folio = filemap_alloc_folio (gfp , mapping_min_folio_order (mapping ), NULL );
40004005 if (!folio )
40014006 return ERR_PTR (- ENOMEM );
40024007 index = mapping_align_index (mapping , index );
0 commit comments