提交 20bd30cd 编写于 作者: L Liu Shixin 提交者: Yongqiang Liu

dhugetlb: use enable_dhugetlb to disable huge_memory

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

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

If hugepage_init() is called before hugetlb_init(), dhugetlb_enabled
has not been initialized, we should use enable_dhugetlb instead.
Signed-off-by: NLiu Shixin <liushixin2@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
上级 20f0535e
...@@ -668,6 +668,7 @@ static inline void set_huge_swap_pte_at(struct mm_struct *mm, unsigned long addr ...@@ -668,6 +668,7 @@ static inline void set_huge_swap_pte_at(struct mm_struct *mm, unsigned long addr
/* We don't need to try 5 times, or we can't migrate the pages. */ /* We don't need to try 5 times, or we can't migrate the pages. */
#define HPOOL_RECLAIM_RETRIES 5 #define HPOOL_RECLAIM_RETRIES 5
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))
...@@ -744,7 +745,8 @@ void move_pages_from_smpool_to_hpool(struct dhugetlb_pool *hpool, ...@@ -744,7 +745,8 @@ void move_pages_from_smpool_to_hpool(struct dhugetlb_pool *hpool,
void dhugetlb_reserve_hugepages(struct dhugetlb_pool *hpool, void dhugetlb_reserve_hugepages(struct dhugetlb_pool *hpool,
unsigned long count, bool gigantic); unsigned long count, bool gigantic);
#else #else
#define dhugetlb_enabled 0 #define enable_dhugetlb 0
#define dhugetlb_enabled 0
struct dhugetlb_pool {}; struct dhugetlb_pool {};
static inline struct dhugetlb_pool *get_dhugetlb_pool_from_task( static inline struct dhugetlb_pool *get_dhugetlb_pool_from_task(
struct task_struct *tsk) struct task_struct *tsk)
......
...@@ -404,9 +404,9 @@ static int __init hugepage_init(void) ...@@ -404,9 +404,9 @@ static int __init hugepage_init(void)
* use transparent hugepage in addition. * use transparent hugepage in addition.
* (May result negative optimization) * (May result negative optimization)
*/ */
if (dhugetlb_enabled) { if (enable_dhugetlb) {
transparent_hugepage_flags = 0; 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; return -EINVAL;
} }
......
...@@ -3299,7 +3299,7 @@ static void hugetlb_register_all_nodes(void) { } ...@@ -3299,7 +3299,7 @@ static void hugetlb_register_all_nodes(void) { }
#endif #endif
#ifdef CONFIG_DYNAMIC_HUGETLB #ifdef CONFIG_DYNAMIC_HUGETLB
static bool enable_dhugetlb; bool enable_dhugetlb;
DEFINE_STATIC_KEY_FALSE(dhugetlb_enabled_key); DEFINE_STATIC_KEY_FALSE(dhugetlb_enabled_key);
DEFINE_RWLOCK(dhugetlb_pagelist_rwlock); DEFINE_RWLOCK(dhugetlb_pagelist_rwlock);
struct dhugetlb_pagelist *dhugetlb_pagelist_t; struct dhugetlb_pagelist *dhugetlb_pagelist_t;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册