Skip to content

Commit bb3c579

Browse files
author
Matthew Wilcox (Oracle)
committed
mm/filemap: Add filemap_alloc_folio
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> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: David Howells <dhowells@redhat.com> Acked-by: Vlastimil Babka <vbabka@suse.cz>
1 parent cc09cb1 commit bb3c579

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

include/linux/pagemap.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,19 @@ static inline void *detach_page_private(struct page *page)
262262
}
263263

264264
#ifdef CONFIG_NUMA
265-
extern struct page *__page_cache_alloc(gfp_t gfp);
265+
struct folio *filemap_alloc_folio(gfp_t gfp, unsigned int order);
266266
#else
267-
static inline struct page *__page_cache_alloc(gfp_t gfp)
267+
static inline struct folio *filemap_alloc_folio(gfp_t gfp, unsigned int order)
268268
{
269-
return alloc_pages(gfp, 0);
269+
return folio_alloc(gfp, order);
270270
}
271271
#endif
272272

273+
static inline struct page *__page_cache_alloc(gfp_t gfp)
274+
{
275+
return &filemap_alloc_folio(gfp, 0)->page;
276+
}
277+
273278
static inline struct page *page_cache_alloc(struct address_space *x)
274279
{
275280
return __page_cache_alloc(mapping_gfp_mask(x));

mm/filemap.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,24 +1006,24 @@ int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
10061006
EXPORT_SYMBOL_GPL(add_to_page_cache_lru);
10071007

10081008
#ifdef CONFIG_NUMA
1009-
struct page *__page_cache_alloc(gfp_t gfp)
1009+
struct folio *filemap_alloc_folio(gfp_t gfp, unsigned int order)
10101010
{
10111011
int n;
1012-
struct page *page;
1012+
struct folio *folio;
10131013

10141014
if (cpuset_do_page_mem_spread()) {
10151015
unsigned int cpuset_mems_cookie;
10161016
do {
10171017
cpuset_mems_cookie = read_mems_allowed_begin();
10181018
n = cpuset_mem_spread_node();
1019-
page = __alloc_pages_node(n, gfp, 0);
1020-
} while (!page && read_mems_allowed_retry(cpuset_mems_cookie));
1019+
folio = __folio_alloc_node(gfp, order, n);
1020+
} while (!folio && read_mems_allowed_retry(cpuset_mems_cookie));
10211021

1022-
return page;
1022+
return folio;
10231023
}
1024-
return alloc_pages(gfp, 0);
1024+
return folio_alloc(gfp, order);
10251025
}
1026-
EXPORT_SYMBOL(__page_cache_alloc);
1026+
EXPORT_SYMBOL(filemap_alloc_folio);
10271027
#endif
10281028

10291029
/*

0 commit comments

Comments
 (0)