Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752476AbbGaHlq (ORCPT ); Fri, 31 Jul 2015 03:41:46 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:36649 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752376AbbGaHlo convert rfc822-to-8bit (ORCPT ); Fri, 31 Jul 2015 03:41:44 -0400 From: yalin wang Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8BIT Subject: [RFC] arm64:change jump_label to use branch instruction, not use NOP instr Message-Id: <94E2034B-9DE4-4ADF-8B2F-197D38A363CF@gmail.com> Date: Fri, 31 Jul 2015 15:41:37 +0800 To: Catalin Marinas , Will Deacon , Ingo Molnar , anton@samba.org, peterz@infradead.org, yalin.wang2010@gmail.com, mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org, open list , jbaron@akamai.com Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2098\)) X-Mailer: Apple Mail (2.2098) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2079 Lines: 60 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 --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/