Commit f1cfb617 authored by Liu Shixin's avatar Liu Shixin Committed by Zheng Zengkai
Browse files

mm: hugetlb_vmemmap: disable hugetlb_vmemmap when dynamic hugetlb is enabled

hulk inclusion
category: feature
bugzilla: 187198, https://gitee.com/openeuler/kernel/issues/I5GVFO


CVE: NA

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

Disable hugetlb_vmemmap when dynamic hugetlb is enabled.
By the way, fix a similar spelling error.

Signed-off-by: default avatarLiu Shixin <liushixin2@huawei.com>
Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 1d2bbc77
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1150,6 +1150,6 @@ static int __init dynamic_hugetlb_setup(char *s)
{
	if (!strcmp(s, "on"))
		enable_dhugetlb = true;
	return 1;
	return 0;
}
__setup("dynamic_hugetlb=", dynamic_hugetlb_setup);
early_param("dynamic_hugetlb", dynamic_hugetlb_setup);
+1 −1
Original line number Diff line number Diff line
@@ -401,7 +401,7 @@ static int __init hugepage_init(void)
	 */
	if (enable_dhugetlb) {
		transparent_hugepage_flags = 0;
		pr_info("transparent hugepage is disabled due to confilct with dynamic hugetlb\n");
		pr_info("transparent hugepage is disabled due to conflict with dynamic hugetlb\n");
		return -EINVAL;
	}

+10 −1
Original line number Diff line number Diff line
@@ -176,6 +176,7 @@
 */
#define pr_fmt(fmt)	"HugeTLB: " fmt

#include <linux/dynamic_hugetlb.h>
#include "hugetlb_vmemmap.h"

/*
@@ -304,6 +305,12 @@ void __init hugetlb_vmemmap_init(struct hstate *h)
	BUILD_BUG_ON(__NR_USED_SUBPAGE >=
		     RESERVE_VMEMMAP_SIZE / sizeof(struct page));

	if (enable_dhugetlb) {
		pr_warn_once("cannot optimize vmemmap pages due to conflict with dynamic hugetlb\n");
		static_branch_disable(&hugetlb_optimize_vmemmap_key);
		return;
	}

	if (!is_power_of_2(sizeof(struct page))) {
		pr_warn_once("cannot optimize vmemmap pages because \"struct page\" crosses page boundaries\n");
		static_branch_disable(&hugetlb_optimize_vmemmap_key);
@@ -366,8 +373,10 @@ static __init int hugetlb_vmemmap_sysctls_init(void)
	/*
	 * If "memory_hotplug.memmap_on_memory" is enabled or "struct page"
	 * crosses page boundaries, the vmemmap pages cannot be optimized.
	 * If "dynamic hugetlb" is enabled, the vmemmap pages cannot be
	 * optimized.
	 */
	if (is_power_of_2(sizeof(struct page)))
	if (is_power_of_2(sizeof(struct page)) && !enable_dhugetlb)
		register_sysctl_init("vm", hugetlb_vmemmap_sysctls);

	return 0;