@@ -849,6 +849,8 @@ void __put_page(struct page *page);
void put_pages_list(struct list_head *pages);
+void split_page_by_order(struct page *page, unsigned int order,
+ unsigned int new_order);
void split_page(struct page *page, unsigned int order);
/*
@@ -98,7 +98,7 @@ static void split_map_pages(struct list_head *list)
post_alloc_hook(page, order, __GFP_MOVABLE);
if (order)
- split_page(page, order);
+ split_page_by_order(page, order, 0);
for (i = 0; i < nr_pages; i++) {
list_add(&page->lru, &tmp_list);
@@ -3188,6 +3188,24 @@ void free_unref_page_list(struct list_head *list)
local_irq_restore(flags);
}
+/*
+ * split_page_by_order takes a non-compound higher-order page, and splits
+ * it into n (1 << (order - new_order)) sub-order pages: page[0..n]
+ * Each sub-page must be freed individually.
+ */
+void split_page_by_order(struct page *page, unsigned int order,
+ unsigned int new_order)
+{
+ int i;
+
+ VM_BUG_ON_PAGE(PageCompound(page), page);
+ VM_BUG_ON_PAGE(!page_count(page), page);
+
+ for (i = 1; i < (1 << (order - new_order)); i++)
+ set_page_refcounted(page + i * (1 << new_order));
+ split_page_owner(page, order, new_order);
+}
+
/*
* split_page takes a non-compound higher-order page, and splits it into
* n (1<<order) sub-pages: page[0..n]
@@ -3198,14 +3216,7 @@ void free_unref_page_list(struct list_head *list)
*/
void split_page(struct page *page, unsigned int order)
{
- int i;
-
- VM_BUG_ON_PAGE(PageCompound(page), page);
- VM_BUG_ON_PAGE(!page_count(page), page);
-
- for (i = 1; i < (1 << order); i++)
- set_page_refcounted(page + i);
- split_page_owner(page, order, 0);
+ split_page_by_order(page, order, 0);
}
EXPORT_SYMBOL_GPL(split_page);
This patch introduces split_page_by_order to support splitting a high-order page into group of smaller high-order pages and use it in split_map_pages for supporting upcoming high-order bulk operation. This patch shouldn't change any behavior. Signed-off-by: Minchan Kim <minchan@kernel.org> --- include/linux/mm.h | 2 ++ mm/compaction.c | 2 +- mm/page_alloc.c | 27 +++++++++++++++++++-------- 3 files changed, 22 insertions(+), 9 deletions(-)