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

mm/dynamic_hugetlb: check free_pages_prepares when split pages

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

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

The hugepages may still remain PG_uptodate flags when freed. When splitting
hugepage to pages, the flag is not clear. This causes the page to be allocated
with PG_uptodate flags and user may read incorrect datas.

In order to solve this problem and similar problems, add free_pages_prepares()
to clear page when splitting pages to small pool.
Signed-off-by: NLiu Shixin <liushixin2@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 0a1bc196
......@@ -74,14 +74,16 @@ static void __hpool_split_huge_page(struct dhugetlb_pool *hpool, struct page *pa
__ClearPageHead(page);
for (i = 0; i < nr_pages; i++) {
page[i].flags &= ~(1 << PG_locked | 1 << PG_error |
1 << PG_referenced | 1 << PG_dirty |
1 << PG_active | 1 << PG_private |
1 << PG_writeback);
if (i != 0) {
page[i].mapping = NULL;
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
* hugepage using free_pages_prepare() here.
*/
free_pages_prepare(&page[i], 0, false);
add_new_page_to_pool(hpool, &page[i], HUGE_PAGES_POOL_4K);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册