diff options
author | Matthew Wilcox (Oracle) <willy@infradead.org> | 2020-12-16 04:55:54 +0100 |
---|---|---|
committer | Matthew Wilcox (Oracle) <willy@infradead.org> | 2021-10-18 13:49:40 +0200 |
commit | cc09cb134124a42fbe3bdcebefdc54e286d8f3e5 (patch) | |
tree | 9b4d5703a69507091b2c689a1f111088c19592ec /mm/page_alloc.c | |
parent | mm/lru: Add folio_add_lru() (diff) | |
download | linux-cc09cb134124a42fbe3bdcebefdc54e286d8f3e5.tar.xz linux-cc09cb134124a42fbe3bdcebefdc54e286d8f3e5.zip |
mm/page_alloc: Add folio allocation functions
The __folio_alloc(), __folio_alloc_node() and folio_alloc() functions
are mostly for type safety, but they also ensure that the page allocator
allocates a compound page and initialises the deferred list if the page
is large enough to have one.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r-- | mm/page_alloc.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 869d0b06e1ef..544ff5a11cb8 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5400,6 +5400,18 @@ out: } EXPORT_SYMBOL(__alloc_pages); +struct folio *__folio_alloc(gfp_t gfp, unsigned int order, int preferred_nid, + nodemask_t *nodemask) +{ + struct page *page = __alloc_pages(gfp | __GFP_COMP, order, + preferred_nid, nodemask); + + if (page && order > 1) + prep_transhuge_page(page); + return (struct folio *)page; +} +EXPORT_SYMBOL(__folio_alloc); + /* * Common helper functions. Never use with __GFP_HIGHMEM because the returned * address cannot represent highmem pages. Use alloc_pages and then kmap if |