Commit 2299190c authored by Liu Shixin's avatar Liu Shixin Committed by Yongqiang Liu
Browse files

mm: hwpoison: enable memory error handling on 1GB hugepage optionaly

hulk inclusion
category: feature
bugzilla: 186704, https://gitee.com/openeuler/kernel/issues/I574NB


CVE: NA

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

The memory error handling on 1GB hugepage is disabled by commit 31286a84
because it may lead to a kernel panic.

However, the commit will result a more troublesome downstream problem. So we
have to revert it in some situation. At the same time, we backport commit
15494520 which resolve the kernel panic described in commit 31286a84.

We add a new cmdline named 'hugetlb_hwpoison_full' to enable memory error
handling on 1GB hugepage. By default, the memory error handling on 1GB hugepage
is disabled.

Note that the kernel panic may not have been completely resolved!

Signed-off-by: default avatarLiu Shixin <liushixin2@huawei.com>
Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarYongqiang Liu <liuyongqiang13@huawei.com>
parent 5a13dee5
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1425,6 +1425,9 @@
			x86-64 are 2M (when the CPU supports "pse") and 1G
			(when the CPU supports the "pdpe1gb" cpuinfo flag).

	hugetlb_hwpoison_full
			[HW] Enable memory error handling of 1GB hugepage.

	hung_task_panic=
			[KNL] Should the hung task detector generate panics.
			Format: <integer>
+11 −1
Original line number Diff line number Diff line
@@ -1155,6 +1155,15 @@ static int try_to_split_thp_page(struct page *page, const char *msg)
	return 0;
}

static bool hugetlb_hwpoison_full;

static int __init enable_hugetlb_hwpoison_full(char *str)
{
	hugetlb_hwpoison_full = true;
	return 0;
}
early_param("hugetlb_hwpoison_full", enable_hugetlb_hwpoison_full);

static int memory_failure_hugetlb(unsigned long pfn, int flags)
{
	struct page *p = pfn_to_page(pfn);
@@ -1213,7 +1222,8 @@ static int memory_failure_hugetlb(unsigned long pfn, int flags)
	 *  - other mm code walking over page table is aware of pud-aligned
	 *    hwpoison entries.
	 */
	if (huge_page_size(page_hstate(head)) > PMD_SIZE) {
	if (!hugetlb_hwpoison_full &&
	    huge_page_size(page_hstate(head)) > PMD_SIZE) {
		action_result(pfn, MF_MSG_NON_PMD_HUGE, MF_IGNORED);
		res = -EBUSY;
		goto out;