Unverified Commit f48341cf authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!9081 v2 arm64: mm: Replace global variable in pbha with static key

parents a1125812 c7e46327
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -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;
}
+8 −5
Original line number Diff line number Diff line
@@ -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;