From patchwork Fri Jul 31 07:41:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yalin wang X-Patchwork-Id: 6908741 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1B4B19F39D for ; Fri, 31 Jul 2015 07:44:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2B12C205DE for ; Fri, 31 Jul 2015 07:44:09 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5203320520 for ; Fri, 31 Jul 2015 07:44:08 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZL4xE-0007Bb-7L; Fri, 31 Jul 2015 07:42:08 +0000 Received: from mail-pa0-x22c.google.com ([2607:f8b0:400e:c03::22c]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZL4xC-00077e-8a for linux-arm-kernel@lists.infradead.org; Fri, 31 Jul 2015 07:42:06 +0000 Received: by pachj5 with SMTP id hj5so36690772pac.3 for ; Fri, 31 Jul 2015 00:41:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:content-transfer-encoding:subject:message-id:date :to:mime-version; bh=epBx/ThJiSn6uTczbOswMD3jLJlECVZ3uLP2DeYtOow=; b=DhLLX2EZnTZp0Ft8Mbwu687R40LqnwmZ3aW1tO1ayJ5nQvBd0KvuKvLJa10sqE1bgg SP6f95JolsOy5HUekpN4kbOephbhN8ehaKKr5EGPQo3v0pt6QuaDXd8tdko9UStbG3KK pKJhp2H/0Z3MSbSymQFSUZ96Cpl/q94KpMr+n+eH1ooyRSCWlIBB18dKW5zEkePuG8/5 ms/u+d4kluDmaVK4xXVP1g1qnY9rC9TpTpkVUJILZTqhat528yCr+HsTFBMXkAIgCtUt 92AODh+AH/gM/6GcyageodEizKNMqB4BWHuN55+UOgRpnpByFTNI7GUUiKtmNG/NFJ0I ZzGA== X-Received: by 10.66.158.3 with SMTP id wq3mr4030112pab.38.1438328504212; Fri, 31 Jul 2015 00:41:44 -0700 (PDT) Received: from [17.87.29.199] ([17.87.29.199]) by smtp.gmail.com with ESMTPSA id w10sm5923789pds.49.2015.07.31.00.41.40 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 31 Jul 2015 00:41:43 -0700 (PDT) From: yalin wang 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) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150731_004206_335936_57F06645 X-CRM114-Status: GOOD ( 14.17 ) X-Spam-Score: -2.5 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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); }