Commit f234ebe8 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 cd3ac806
Loading
Loading
Loading
Loading
+5 −17
Original line number Original line Diff line number Diff line
@@ -2641,17 +2641,14 @@ static void __vunmap(const void *addr, int deallocate_pages)
	vm_remove_mappings(area, deallocate_pages);
	vm_remove_mappings(area, deallocate_pages);


	if (deallocate_pages) {
	if (deallocate_pages) {
		unsigned int page_order = vm_area_page_order(area);
		int i;
		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];
			struct page *page = area->pages[i];


			BUG_ON(!page);
			BUG_ON(!page);
			/*
			__free_pages(page, page_order);
			 * High-order allocs for huge vmallocs are split, so
			 * can be freed as an array of order-0 allocations
			 */
			__free_pages(page, 0);
		}
		}
		atomic_long_sub(area->nr_pages, &nr_vmalloc_pages);
		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;
		struct page *page;
		int p;
		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)) {
		if (unlikely(!page)) {
			/* Successfully allocated i pages, free them in __vfree() */
			/* Successfully allocated i pages, free them in __vfree() */
			area->nr_pages = i;
			area->nr_pages = i;
@@ -2945,16 +2943,6 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
			goto fail;
			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++)
		for (p = 0; p < (1U << page_order); p++)
			area->pages[i + p] = page + p;
			area->pages[i + p] = page + p;