From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DATE_IN_PAST_03_06, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78CBFC4338F for ; Wed, 18 Aug 2021 10:59:49 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4A04C60FBF for ; Wed, 18 Aug 2021 10:59:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4A04C60FBF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=j8H4XGQOApp9y9MfqK3v4+dt7Lme8hgAjvhwlx3StAI=; b=ewpMzWQLaMmboZ 1CfaV3gDrjXLExOPlk8H8Q/Yfz+02PSbx75NxEgDSPi/vpAu/Odr5pM0a3SDElTOy69Jh1u4wor9j vbrMFMNfbsLhNio3m7YBfdhS8jGHcuZ38xKz20ylWTOE89rZSC1qbckfs78v6wd3LlTAvfw/XQqEo 48wbF+KuWz7NOmY7ssqOUeptBntIb4wDXzc5rJjrT/j8Uhlari0UYUMD5n+3u1vFVurFy9uerZZAJ VHvNFZ+oou26MchaDmpRrxhnC6PwUbhBm7lEeNbeOw2LwBwDJXxXV3udvhk9VmpFn4JmNekwqAqqZ hKX3RiY/OHFgNDCQu/ag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGJGN-005FKR-Mf; Wed, 18 Aug 2021 10:57:39 +0000 Received: from szxga03-in.huawei.com ([45.249.212.189]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGJG4-005FDO-G1 for linux-arm-kernel@lists.infradead.org; Wed, 18 Aug 2021 10:57:23 +0000 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4GqPx16M9Zz7yxR; Wed, 18 Aug 2021 18:57:09 +0800 (CST) Received: from dggema757-chm.china.huawei.com (10.1.198.199) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Wed, 18 Aug 2021 18:57:17 +0800 Received: from localhost.localdomain (10.67.165.2) by dggema757-chm.china.huawei.com (10.1.198.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Wed, 18 Aug 2021 18:57:16 +0800 From: Qi Liu To: , , , , , , CC: , , , , , , Subject: [PATCH v4 0/2] arm64: Enable OPTPROBE for arm64 Date: Wed, 18 Aug 2021 15:33:34 +0800 Message-ID: <20210818073336.59678-1-liuqi115@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggema757-chm.china.huawei.com (10.1.198.199) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210818_035720_926634_7C7C5D81 X-CRM114-Status: GOOD ( 11.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch introduce optprobe for ARM64, using a branch instruction to replace probed instruction. The test result on Hip08 platform is shown here, and optprobe could reduce the latency to 1/4 of normal kprobe kprobe before optimized: [280709.846380] do_empty returned 0 and took 1530 ns to execute [280709.852057] do_empty returned 0 and took 550 ns to execute [280709.857631] do_empty returned 0 and took 440 ns to execute [280709.863215] do_empty returned 0 and took 380 ns to execute [280709.868787] do_empty returned 0 and took 360 ns to execute [280709.874362] do_empty returned 0 and took 340 ns to execute [280709.879936] do_empty returned 0 and took 320 ns to execute [280709.885505] do_empty returned 0 and took 300 ns to execute [280709.891075] do_empty returned 0 and took 280 ns to execute [280709.896646] do_empty returned 0 and took 290 ns to execute [280709.902220] do_empty returned 0 and took 290 ns to execute [280709.907807] do_empty returned 0 and took 290 ns to execute optprobe: [ 2965.964572] do_empty returned 0 and took 90 ns to execute [ 2965.969952] do_empty returned 0 and took 80 ns to execute [ 2965.975332] do_empty returned 0 and took 70 ns to execute [ 2965.980714] do_empty returned 0 and took 60 ns to execute [ 2965.986128] do_empty returned 0 and took 80 ns to execute [ 2965.991507] do_empty returned 0 and took 70 ns to execute [ 2965.996884] do_empty returned 0 and took 70 ns to execute [ 2966.002262] do_empty returned 0 and took 80 ns to execute [ 2966.007642] do_empty returned 0 and took 70 ns to execute [ 2966.013020] do_empty returned 0 and took 70 ns to execute [ 2966.018400] do_empty returned 0 and took 70 ns to execute [ 2966.023779] do_empty returned 0 and took 70 ns to execute [ 2966.029158] do_empty returned 0 and took 70 ns to execute Changes since V3: - Address the comments from Masami, reduce the number of aarch64_insn_patch_text in arch_optimize_kprobes() and arch_unoptimize_kprobes(). - Link: https://lore.kernel.org/lkml/20210810055330.18924-1-liuqi115@huawei.com/ Changes since V2: - Address the comments from Masami, prepare another writable buffer in arch_prepare_optimized_kprobe()and build the trampoline code on it. - Address the comments from Amit, move save_all_base_regs and restore_all_base_regs to , as these two macros are reused in optprobe. - Link: https://lore.kernel.org/lkml/20210804060209.95817-1-liuqi115@huawei.com/ Changes since V1: - Address the comments from Masami, checks for all branch instructions, and use aarch64_insn_patch_text_nosync() instead of aarch64_insn_patch_text() in each probe. - Link: https://lore.kernel.org/lkml/20210719122417.10355-1-liuqi115@huawei.com/ Qi Liu (2): Make save_all_base_regs and restore_all_base_regs as common macro arm64: kprobe: Enable OPTPROBE for arm64 arch/arm64/Kconfig | 1 + arch/arm64/include/asm/assembler.h | 52 ++++ arch/arm64/include/asm/kprobes.h | 24 ++ arch/arm64/kernel/probes/Makefile | 2 + arch/arm64/kernel/probes/kprobes.c | 19 +- arch/arm64/kernel/probes/kprobes_trampoline.S | 52 ---- arch/arm64/kernel/probes/opt_arm64.c | 276 ++++++++++++++++++ .../arm64/kernel/probes/optprobe_trampoline.S | 37 +++ 8 files changed, 408 insertions(+), 55 deletions(-) create mode 100644 arch/arm64/kernel/probes/opt_arm64.c create mode 100644 arch/arm64/kernel/probes/optprobe_trampoline.S -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel