提交 bb3c579e 编写于 作者: M Matthew Wilcox (Oracle)

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: NMatthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NDavid Howells <dhowells@redhat.com>
Acked-by: NVlastimil Babka <vbabka@suse.cz>
上级 cc09cb13
...@@ -262,14 +262,19 @@ static inline void *detach_page_private(struct page *page) ...@@ -262,14 +262,19 @@ static inline void *detach_page_private(struct page *page)
} }
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
extern struct page *__page_cache_alloc(gfp_t gfp); struct folio *filemap_alloc_folio(gfp_t gfp, unsigned int order);
#else #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 folio_alloc(gfp, order);
} }
#endif #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) static inline struct page *page_cache_alloc(struct address_space *x)
{ {
return __page_cache_alloc(mapping_gfp_mask(x)); return __page_cache_alloc(mapping_gfp_mask(x));
......
...@@ -1006,24 +1006,24 @@ int add_to_page_cache_lru(struct page *page, struct address_space *mapping, ...@@ -1006,24 +1006,24 @@ int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
EXPORT_SYMBOL_GPL(add_to_page_cache_lru); EXPORT_SYMBOL_GPL(add_to_page_cache_lru);
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
struct page *__page_cache_alloc(gfp_t gfp) struct folio *filemap_alloc_folio(gfp_t gfp, unsigned int order)
{ {
int n; int n;
struct page *page; struct folio *folio;
if (cpuset_do_page_mem_spread()) { if (cpuset_do_page_mem_spread()) {
unsigned int cpuset_mems_cookie; unsigned int cpuset_mems_cookie;
do { do {
cpuset_mems_cookie = read_mems_allowed_begin(); cpuset_mems_cookie = read_mems_allowed_begin();
n = cpuset_mem_spread_node(); n = cpuset_mem_spread_node();
page = __alloc_pages_node(n, gfp, 0); folio = __folio_alloc_node(gfp, order, n);
} while (!page && read_mems_allowed_retry(cpuset_mems_cookie)); } while (!folio && read_mems_allowed_retry(cpuset_mems_cookie));
return page; return folio;
} }
return alloc_pages(gfp, 0); return folio_alloc(gfp, order);
} }
EXPORT_SYMBOL(__page_cache_alloc); EXPORT_SYMBOL(filemap_alloc_folio);
#endif #endif
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册