Thread (40 messages) 40 messages, 5 authors, 2016-08-08

Re: [PATCH v3 19/21] powerpc: Add option to use jump label for mmu_has_feature()

From: Nicholas Piggin <npiggin@gmail.com>
Date: 2016-07-28 07:53:04

On Thu, 28 Jul 2016 00:18:15 +1000
Michael Ellerman [off-list ref] wrote:
quoted hunk ↗ jump to hunk
From: Kevin Hao <redacted>

As we just did for CPU features.

Signed-off-by: Kevin Hao <redacted>
Signed-off-by: Aneesh Kumar K.V <redacted>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/include/asm/mmu.h    | 36
++++++++++++++++++++++++++++++++++++
arch/powerpc/kernel/cputable.c    | 17 +++++++++++++++++
arch/powerpc/lib/feature-fixups.c |  1 + 3 files changed, 54
insertions(+)

v3: Rename to mmu_feature_keys, and NUM_MMU_FTR_KEYS.
    Use the kconfig.
diff --git a/arch/powerpc/include/asm/mmu.h
b/arch/powerpc/include/asm/mmu.h index e3eff365e55d..3900cb7fe7cf
100644 --- a/arch/powerpc/include/asm/mmu.h
+++ b/arch/powerpc/include/asm/mmu.h
@@ -140,6 +140,41 @@ static inline bool __mmu_has_feature(unsigned
long feature) return !!(MMU_FTRS_POSSIBLE &
cur_cpu_spec->mmu_features & feature); }
 
+#ifdef CONFIG_JUMP_LABEL_FEATURE_CHECKS
+#include <linux/jump_label.h>
+
+#define NUM_MMU_FTR_KEYS	32
+
+extern struct static_key_true mmu_feature_keys[NUM_MMU_FTR_KEYS];
+
+extern void mmu_feature_keys_init(void);
+
+static __always_inline bool mmu_has_feature(unsigned long feature)
+{
+	int i;
+
+	if (!(MMU_FTRS_POSSIBLE & feature))
+		return false;
+
+	i = __builtin_ctzl(feature);
+	return static_branch_likely(&mmu_feature_keys[i]);
+}
And here.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help