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

mm/huge_memory: disable THP when dynamic hugetlb is enabled

hulk inclusion
category: feature
bugzilla: 46904, https://gitee.com/openeuler/kernel/issues/I4QSHG
CVE: NA

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

When THP is enabled, the allocation of a page(order=0) may be converted to
an allocation of pages(order>0). In this case, the allocation will skip the
dhugetlb_pool. When we want to use dynamic hugetlb feature, we have to
disable THP for now.
Signed-off-by: NLiu Shixin <liushixin2@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 7278ccd6
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#ifdef CONFIG_DYNAMIC_HUGETLB #ifdef CONFIG_DYNAMIC_HUGETLB
extern bool enable_dhugetlb;
extern struct static_key_false dhugetlb_enabled_key; extern struct static_key_false dhugetlb_enabled_key;
#define dhugetlb_enabled (static_branch_unlikely(&dhugetlb_enabled_key)) #define dhugetlb_enabled (static_branch_unlikely(&dhugetlb_enabled_key))
...@@ -106,6 +107,7 @@ void free_huge_page_to_dhugetlb_pool(struct page *page, bool restore_reserve); ...@@ -106,6 +107,7 @@ void free_huge_page_to_dhugetlb_pool(struct page *page, bool restore_reserve);
#else #else
#define enable_dhugetlb 0
#define dhugetlb_enabled 0 #define dhugetlb_enabled 0
struct dhugetlb_pool {}; struct dhugetlb_pool {};
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <trace/events/dynamic_hugetlb.h> #include <trace/events/dynamic_hugetlb.h>
#endif #endif
static bool enable_dhugetlb = false; bool enable_dhugetlb = false;
DEFINE_STATIC_KEY_FALSE(dhugetlb_enabled_key); DEFINE_STATIC_KEY_FALSE(dhugetlb_enabled_key);
#define hugepage_index(pfn) ((pfn) >> (PUD_SHIFT - PAGE_SHIFT)) #define hugepage_index(pfn) ((pfn) >> (PUD_SHIFT - PAGE_SHIFT))
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <linux/oom.h> #include <linux/oom.h>
#include <linux/numa.h> #include <linux/numa.h>
#include <linux/page_owner.h> #include <linux/page_owner.h>
#include <linux/dynamic_hugetlb.h>
#include <asm/tlb.h> #include <asm/tlb.h>
#include <asm/pgalloc.h> #include <asm/pgalloc.h>
...@@ -392,6 +393,18 @@ static int __init hugepage_init(void) ...@@ -392,6 +393,18 @@ static int __init hugepage_init(void)
return -EINVAL; return -EINVAL;
} }
/*
* When we alloc some pages(order = 0), system may help us to alloc a page(order > 0)
* due to transparent hugepage. This result dynamic hugetlb to be skipped.
* Actually, using dynamic hugetlb means we have already optimized the program, so we
* should not use transparent hugepage in addition. (May result negative optimization)
*/
if (enable_dhugetlb) {
transparent_hugepage_flags = 0;
pr_info("transparent hugepage is disabled due to confilct with dynamic hugetlb\n");
return -EINVAL;
}
/* /*
* hugepages can't be allocated by the buddy allocator * hugepages can't be allocated by the buddy allocator
*/ */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册