提交 9a60fa50 编写于 作者: L Liu Shixin 提交者: Zheng Zengkai

mm/dynamic_hugetlb: improve the initialization of huge pages

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

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

Referring to alloc_buddy_huge_page function, replace prep_compound_page
with prep_new_page which is more appropriate because it's the opposite of
free_pages_prepare.
And initialize page->mapping for huge pages as they are initialized in
free_huge_page too.
Signed-off-by: NLiu Shixin <liushixin2@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 aa1306e1
......@@ -30,15 +30,22 @@ static void add_new_page_to_pool(struct dhugetlb_pool *hpool, struct page *page,
switch (hpages_pool_idx) {
case HUGE_PAGES_POOL_1G:
prep_compound_gigantic_page(page, PUD_SHIFT - PAGE_SHIFT);
set_page_count(page, 0);
set_compound_page_dtor(page, HUGETLB_PAGE_DTOR);
hugetlb_set_page_subpool(page, NULL);
set_hugetlb_cgroup(page, NULL);
set_hugetlb_cgroup_rsvd(page, NULL);
break;
case HUGE_PAGES_POOL_2M:
prep_compound_page(page, PMD_SHIFT - PAGE_SHIFT);
prep_new_page(page, PMD_SHIFT - PAGE_SHIFT, __GFP_COMP, 0);
set_page_count(page, 0);
set_compound_page_dtor(page, HUGETLB_PAGE_DTOR);
hugetlb_set_page_subpool(page, NULL);
set_hugetlb_cgroup(page, NULL);
set_hugetlb_cgroup_rsvd(page, NULL);
break;
}
page->mapping = NULL;
list_add_tail(&page->lru, &hpages_pool->hugepage_freelists);
hpages_pool->free_normal_pages++;
}
......@@ -74,10 +81,8 @@ static void __hpool_split_huge_page(struct dhugetlb_pool *hpool, struct page *pa
__ClearPageHead(page);
for (i = 0; i < nr_pages; i++) {
if (i != 0) {
page[i].mapping = NULL;
if (i != 0)
clear_compound_head(&page[i]);
}
/*
* If a hugepage is mapped in private mode, the PG_uptodate bit
* will not be cleared when the hugepage freed. Clear the
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册