From: ZhangPeng zhangpeng362@huawei.com
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I6LD0S CVE: NA
----------------------------------------
This reverts commit 49ed1f1e68851efc04d2796eb8d6b6cdcba4dbb7.
It will have a great impact on the product if we can't use vmalloc to alloc high-order physical pages.
Signed-off-by: ZhangPeng zhangpeng362@huawei.com Reviewed-by: Kefeng Wang wangkefeng.wang@huawei.com Signed-off-by: Jialin Zhang zhangjialin11@huawei.com --- mm/vmalloc.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 2ca2c1bc0db9..e27cd716ca95 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -2641,17 +2641,14 @@ static void __vunmap(const void *addr, int deallocate_pages) vm_remove_mappings(area, deallocate_pages);
if (deallocate_pages) { + unsigned int page_order = vm_area_page_order(area); int i;
- for (i = 0; i < area->nr_pages; i++) { + for (i = 0; i < area->nr_pages; i += 1U << page_order) { struct page *page = area->pages[i];
BUG_ON(!page); - /* - * High-order allocs for huge vmallocs are split, so - * can be freed as an array of order-0 allocations - */ - __free_pages(page, 0); + __free_pages(page, page_order); } atomic_long_sub(area->nr_pages, &nr_vmalloc_pages);
@@ -2933,7 +2930,8 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, struct page *page; int p;
- page = alloc_pages_node(node, gfp_mask, page_order); + /* Compound pages required for remap_vmalloc_page */ + page = alloc_pages_node(node, gfp_mask | __GFP_COMP, page_order); if (unlikely(!page)) { /* Successfully allocated i pages, free them in __vfree() */ area->nr_pages = i; @@ -2945,16 +2943,6 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, goto fail; }
- /* - * Higher order allocations must be able to be treated as - * indepdenent small pages by callers (as they can with - * small-page vmallocs). Some drivers do their own refcounting - * on vmalloc_to_page() pages, some use page->mapping, - * page->lru, etc. - */ - if (page_order) - split_page(page, page_order); - for (p = 0; p < (1U << page_order); p++) area->pages[i + p] = page + p;