[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201216182335.27227-9-willy@infradead.org>
Date: Wed, 16 Dec 2020 18:23:18 +0000
From: "Matthew Wilcox (Oracle)" <willy@...radead.org>
To: linux-fsdevel@...r.kernel.org, linux-mm@...ck.org
Cc: "Matthew Wilcox (Oracle)" <willy@...radead.org>,
linux-kernel@...r.kernel.org
Subject: [PATCH 08/25] mm: Add __alloc_folio_node and alloc_folio
These wrappers are mostly for typesafety, but they also ensure that
the page allocator allocates a compound page.
Signed-off-by: Matthew Wilcox (Oracle) <willy@...radead.org>
---
include/linux/gfp.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 53caa9846854..9e416efb4ff8 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -524,6 +524,12 @@ __alloc_pages_node(int nid, gfp_t gfp_mask, unsigned int order)
return __alloc_pages(gfp_mask, order, nid);
}
+static inline
+struct folio *__alloc_folio_node(int nid, gfp_t gfp, unsigned int order)
+{
+ return (struct folio *)__alloc_pages_node(nid, gfp | __GFP_COMP, order);
+}
+
/*
* Allocate pages, preferring the node given as nid. When nid == NUMA_NO_NODE,
* prefer the current CPU's closest node. Otherwise node must be valid and
@@ -565,6 +571,11 @@ static inline struct page *alloc_pages(gfp_t gfp_mask, unsigned int order)
#define alloc_page_vma(gfp_mask, vma, addr) \
alloc_pages_vma(gfp_mask, 0, vma, addr, numa_node_id(), false)
+static inline struct folio *alloc_folio(gfp_t gfp, unsigned int order)
+{
+ return (struct folio *)alloc_pages(gfp | __GFP_COMP, order);
+}
+
extern unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order);
extern unsigned long get_zeroed_page(gfp_t gfp_mask);
--
2.29.2
Powered by blists - more mailing lists