Commit b4ecc9be authored by ZhangPeng's avatar ZhangPeng Committed by Jialin Zhang
Browse files

Revert "mm/vmalloc: huge vmalloc backing pages should be split rather than compound"

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I6LD0S


CVE: NA

----------------------------------------

This reverts commit 49ed1f1e.

It will have a great impact on the product if we can't use vmalloc to
alloc high-order physical pages.

Signed-off-by: default avatarZhangPeng <zhangpeng362@huawei.com>
Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parent f25c3308
Loading
Loading
Loading
Loading
+5 −17
Original line number Diff line number Diff line
@@ -2639,17 +2639,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);

@@ -2929,7 +2926,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;
@@ -2941,16 +2939,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;