From: Kevin Hao <haokexin@gmail.com>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: linuxppc <linuxppc-dev@lists.ozlabs.org>
Subject: [PATCH v2 3/3] powerpc: use jump label for mmu_has_feature
Date: Mon, 2 Sep 2013 13:45:26 +0800 [thread overview]
Message-ID: <1378100726-32545-4-git-send-email-haokexin@gmail.com> (raw)
In-Reply-To: <1378100726-32545-1-git-send-email-haokexin@gmail.com>
The mmu features are fixed once the probe of mmu features are done.
And the function mmu_has_feature() does be used in some hot path.
The checking of the mmu features for each time of invoking of
mmu_has_feature() seems suboptimal. This tries to reduce this
overhead of this check by using jump label. But we can only use
the jump label for this check only after the execution of
jump_label_init(), so we introduce another jump label to
still do the feature check by default before all the mmu
feature jump labels are initialized.
Signed-off-by: Kevin Hao <haokexin@gmail.com>
---
v2: Include the jump_label.h instead of jump_label_base.h.
arch/powerpc/include/asm/mmu.h | 19 +++++++++++++++++++
arch/powerpc/kernel/cputable.c | 20 ++++++++++++++++++++
2 files changed, 39 insertions(+)
diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
index 691fd8a..b7f049e 100644
--- a/arch/powerpc/include/asm/mmu.h
+++ b/arch/powerpc/include/asm/mmu.h
@@ -121,10 +121,29 @@
DECLARE_PER_CPU(int, next_tlbcam_idx);
#endif
+#ifdef CONFIG_JUMP_LABEL
+#include <linux/jump_label.h>
+
+#define MAX_MMU_FEATURES 32
+
+extern struct static_key mmu_feat_keys[MAX_MMU_FEATURES];
+extern struct static_key mmu_feat_keys_enabled;
+
+static inline int mmu_has_feature(unsigned long feature)
+{
+ if (static_key_false(&mmu_feat_keys_enabled)) {
+ int i = __builtin_ctzl(feature);
+
+ return static_key_false(&mmu_feat_keys[i]);
+ } else
+ return !!(cur_cpu_spec->mmu_features & feature);
+}
+#else
static inline int mmu_has_feature(unsigned long feature)
{
return (cur_cpu_spec->mmu_features & feature);
}
+#endif
static inline void mmu_clear_feature(unsigned long feature)
{
diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index 50bd216..785370b 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -2280,4 +2280,24 @@ static __init int cpu_feat_keys_init(void)
return 0;
}
early_initcall(cpu_feat_keys_init);
+
+struct static_key mmu_feat_keys[MAX_MMU_FEATURES];
+struct static_key mmu_feat_keys_enabled;
+
+static __init int mmu_feat_keys_init(void)
+{
+ int i;
+
+ for (i = 0; i < MAX_MMU_FEATURES; i++) {
+ unsigned long f = 1 << i;
+
+ if (cur_cpu_spec->mmu_features & f)
+ static_key_slow_inc(&mmu_feat_keys[i]);
+ }
+
+ static_key_slow_inc(&mmu_feat_keys_enabled);
+
+ return 0;
+}
+early_initcall(mmu_feat_keys_init);
#endif
--
1.8.3.1
prev parent reply other threads:[~2013-09-02 5:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-02 5:45 [PATCH v2 0/3] powerpc: use jump label for cpu/mmu_has_feature Kevin Hao
2013-09-02 5:45 ` [PATCH v2 1/3] powerpc: move the cpu_has_feature to a separate file Kevin Hao
2013-09-02 5:45 ` [PATCH v2 2/3] powerpc: use the jump label for cpu_has_feature Kevin Hao
2013-11-27 2:45 ` Benjamin Herrenschmidt
2013-12-25 5:58 ` Kevin Hao
2013-09-02 5:45 ` Kevin Hao [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1378100726-32545-4-git-send-email-haokexin@gmail.com \
--to=haokexin@gmail.com \
--cc=benh@kernel.crashing.org \
--cc=linuxppc-dev@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.