From: Ma Wupeng mawupeng1@huawei.com
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IA5L01
--------------------------------
During the lmbench test, it was observed that bw_mem experienced a degradation of 8% or more. To solve this issue, replacing the global variables with a static key.
Fixes: 0d65528c8526 ("arm64: mm: Detect and enable PBHA bit0 at early startup") Signed-off-by: Ma Wupeng mawupeng1@huawei.com --- Changelog since v1: - add fix tag for bugfix --- drivers/soc/hisilicon/pbha.c | 17 +++++++++-------- include/linux/pbha.h | 13 ++++++++----- 2 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/drivers/soc/hisilicon/pbha.c b/drivers/soc/hisilicon/pbha.c index 57daa5c338b5..9e385c93bab5 100644 --- a/drivers/soc/hisilicon/pbha.c +++ b/drivers/soc/hisilicon/pbha.c @@ -17,8 +17,9 @@
#define HBM_MODE_CACHE 1
-bool __ro_after_init pbha_bit0_enabled; -bool __ro_after_init pbha_bit0_kernel_enabled; +__ro_after_init DEFINE_STATIC_KEY_FALSE(pbha_bit0_enabled); +__ro_after_init DEFINE_STATIC_KEY_FALSE(pbha_bit0_kernel_enabled); + static bool pbha_enabled_phase_1;
void __init early_pbha_bit0_init(void) @@ -191,15 +192,15 @@ static int __init setup_pbha(char *str) return 0;
if (strcmp(str, "enable") == 0) { - pbha_bit0_enabled = true; - pbha_bit0_kernel_enabled = true; + static_branch_enable(&pbha_bit0_enabled); + static_branch_enable(&pbha_bit0_kernel_enabled); } else if (strcmp(str, "user") == 0) { - pbha_bit0_enabled = true; + static_branch_enable(&pbha_bit0_enabled); }
- if (pbha_bit0_enabled) - pr_info("pbha bit_0 enabled, kernel: %d\n", - pbha_bit0_kernel_enabled); + if (static_branch_likely(&pbha_bit0_enabled)) + pr_info("pbha bit_0 enabled, kernel: %ld\n", + static_branch_likely(&pbha_bit0_kernel_enabled));
return 0; } diff --git a/include/linux/pbha.h b/include/linux/pbha.h index 45a4b07778bf..a8ac441628bd 100644 --- a/include/linux/pbha.h +++ b/include/linux/pbha.h @@ -20,20 +20,22 @@ #define HBM_MODE_CACHE 1
#ifdef CONFIG_ARM64_PBHA -extern bool __ro_after_init pbha_bit0_enabled; -extern bool __ro_after_init pbha_bit0_kernel_enabled; +DECLARE_STATIC_KEY_FALSE(pbha_bit0_enabled); +DECLARE_STATIC_KEY_FALSE(pbha_bit0_kernel_enabled); + extern struct mm_walk_ops pbha_bit0_walk_ops; extern void __init early_pbha_bit0_init(void); extern int pbha_bit0_update_vma(struct mm_struct *mm, int val);
static inline bool system_support_pbha_bit0(void) { - return pbha_bit0_enabled; + return static_branch_unlikely(&pbha_bit0_enabled); }
static inline pgprot_t pgprot_pbha_bit0(pgprot_t prot) { - if (!system_support_pbha_bit0() || !pbha_bit0_kernel_enabled) + if (!system_support_pbha_bit0() || + !static_branch_unlikely(&pbha_bit0_kernel_enabled)) return prot;
return pgprot_pbha(prot, PBHA_VAL_BIT0); @@ -45,7 +47,8 @@ static inline pte_t maybe_mk_pbha_bit0(pte_t pte, struct vm_area_struct *vma) return pte;
/* global init task will update pbha bit0 iff kernel can do this */ - if (unlikely(is_global_init(current)) && pbha_bit0_kernel_enabled && + if (unlikely(is_global_init(current)) && + static_branch_unlikely(&pbha_bit0_kernel_enabled) && !(vma->vm_flags & VM_PBHA_BIT0)) vma->vm_flags |= VM_PBHA_BIT0;
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/9082 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/J...
FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/9082 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/J...