public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: yalin.wang2010@gmail.com (yalin wang)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC] arm64:change jump_label to use branch instruction, not use  NOP instr
Date: Fri, 31 Jul 2015 15:41:37 +0800	[thread overview]
Message-ID: <94E2034B-9DE4-4ADF-8B2F-197D38A363CF@gmail.com> (raw)

This change a little arch_static_branch(), use b . + 4 for false
return, why? According to aarch64 TRM, if both source and dest
instr are branch instr, can patch the instr directly, don't need
all cpu to do ISB for sync, this means we can call
aarch64_insn_patch_text_nosync() during patch_text(),
will improve the performance when change a static_key.

Signed-off-by: yalin wang <yalin.wang2010@gmail.com>
---
 arch/arm64/include/asm/jump_label.h |  2 +-
 arch/arm64/kernel/jump_label.c      | 14 ++++++++------
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/arch/arm64/include/asm/jump_label.h b/arch/arm64/include/asm/jump_label.h
index c0e5165..25b1668 100644
--- a/arch/arm64/include/asm/jump_label.h
+++ b/arch/arm64/include/asm/jump_label.h
@@ -28,7 +28,7 @@
 
 static __always_inline bool arch_static_branch(struct static_key *key)
 {
-	asm goto("1: nop\n\t"
+	asm goto("1: b . + " __stringify(AARCH64_INSN_SIZE) "\n\t"
 		 ".pushsection __jump_table,  \"aw\"\n\t"
 		 ".align 3\n\t"
 		 ".quad 1b, %l[l_yes], %c0\n\t"
diff --git a/arch/arm64/kernel/jump_label.c b/arch/arm64/kernel/jump_label.c
index 4f1fec7..eb09868 100644
--- a/arch/arm64/kernel/jump_label.c
+++ b/arch/arm64/kernel/jump_label.c
@@ -28,13 +28,15 @@ void arch_jump_label_transform(struct jump_entry *entry,
 	void *addr = (void *)entry->code;
 	u32 insn;
 
-	if (type == JUMP_LABEL_ENABLE) {
+	if (type == JUMP_LABEL_ENABLE)
 		insn = aarch64_insn_gen_branch_imm(entry->code,
-						   entry->target,
-						   AARCH64_INSN_BRANCH_NOLINK);
-	} else {
-		insn = aarch64_insn_gen_nop();
-	}
+			entry->target,
+			AARCH64_INSN_BRANCH_NOLINK);
+	else
+		insn = aarch64_insn_gen_branch_imm(entry->code,
+			(unsigned long)addr + AARCH64_INSN_SIZE,
+			AARCH64_INSN_BRANCH_NOLINK);
+
 
 	aarch64_insn_patch_text(&addr, &insn, 1);
 }
-- 
1.9.1

             reply	other threads:[~2015-07-31  7:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-31  7:41 yalin wang [this message]
2015-07-31  7:52 ` [RFC] arm64:change jump_label to use branch instruction, not use NOP instr Peter Zijlstra
2015-07-31  9:25   ` yalin wang
2015-07-31  9:33     ` Peter Zijlstra
2015-07-31 10:14       ` Will Deacon
2015-08-01 10:00         ` yalin wang

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=94E2034B-9DE4-4ADF-8B2F-197D38A363CF@gmail.com \
    --to=yalin.wang2010@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox