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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 56367D0E6F0 for ; Mon, 21 Oct 2024 10:52:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:CC:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=hRiNE6v93otARYRZL+sXA3bhywhQNLiE9rxbcGRWCYM=; b=WNtU729ABgJ8SWTaIEMVY5zRdE H/Jecja2GjJ4W+lM4kWBVlaQw/+B82ODEJeTpLt/KwsCoi2LluA1NMXAaHHFDBPGIA2fJu5U5V3bp tr9GUSWkiUSfBryrXDEBU74pkaAXEz5Zm6PM833derEutXPSjZ5t9zr2Q4NxChldG5teREl0xpZ+w ib+maRyZgXcMKxp8IFSc3sGGzSl81GCwpkRW6q1gNryT6q98tcIS819oLILEHhh4d5CXUu221tKGa 31gXRSiNiAZx7ItIwgc1y12VTXg/lKLBLV/ItZo8LLA2K8oXai8IZsqHvPN/9ns2oOEEPB657rANW lK2UdURw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t2q17-00000006xft-2f9i; Mon, 21 Oct 2024 10:52:05 +0000 Received: from szxga08-in.huawei.com ([45.249.212.255]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t2pui-00000006wF8-13h4 for linux-arm-kernel@lists.infradead.org; Mon, 21 Oct 2024 10:45:30 +0000 Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4XXBjk62slz1T8wt; Mon, 21 Oct 2024 18:43:22 +0800 (CST) Received: from kwepemd200013.china.huawei.com (unknown [7.221.188.133]) by mail.maildlp.com (Postfix) with ESMTPS id DA1F114022E; Mon, 21 Oct 2024 18:45:21 +0800 (CST) Received: from [10.67.110.108] (10.67.110.108) by kwepemd200013.china.huawei.com (7.221.188.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Mon, 21 Oct 2024 18:45:21 +0800 Message-ID: <91d19848-f5f4-4e0e-b3c7-77ac2befae3e@huawei.com> Date: Mon, 21 Oct 2024 18:45:20 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] arm64: insn: Simulate nop instruction for better uprobe performance To: Catalin Marinas , , , , , CC: , , , References: <20240909071114.1150053-1-liaochang1@huawei.com> <172901867521.2735310.14333146229393737694.b4-ty@arm.com> From: "Liao, Chang" In-Reply-To: <172901867521.2735310.14333146229393737694.b4-ty@arm.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.110.108] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemd200013.china.huawei.com (7.221.188.133) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241021_034528_582170_E0B5E4F9 X-CRM114-Status: GOOD ( 13.03 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 在 2024/10/16 2:58, Catalin Marinas 写道: > On Mon, 09 Sep 2024 07:11:14 +0000, Liao Chang wrote: >> v2->v1: >> 1. Remove the simuation of STP and the related bits. >> 2. Use arm64_skip_faulting_instruction for single-stepping or FEAT_BTI >> scenario. >> >> As Andrii pointed out, the uprobe/uretprobe selftest bench run into a >> counterintuitive result that nop and push variants are much slower than >> ret variant [0]. The root cause lies in the arch_probe_analyse_insn(), >> which excludes 'nop' and 'stp' from the emulatable instructions list. >> This force the kernel returns to userspace and execute them out-of-line, >> then trapping back to kernel for running uprobe callback functions. This >> leads to a significant performance overhead compared to 'ret' variant, >> which is already emulated. >> >> [...] > > Applied to arm64 (for-next/probes), thanks! I fixed it up according to > Mark's comments. > > [1/1] arm64: insn: Simulate nop instruction for better uprobe performance > https://git.kernel.org/arm64/c/ac4ad5c09b34 > Mark, Catalin and Andrii, I am just back from a long vacation, thanks for reviewing and involvement for this patch. I've sent a patch [1] that simulates STP at function entry, It maps user stack pages to kernel address space, allowing kernel to use STP directly to push fp/lr onto stack. Unfortunately, the profiling results below show reveals this approach increases the uprobe-push throughput by 29.3% (from 0.868M/s/cpu to 1.1238M/s/cpu) and uretprobe-push by 15.9% (from 0.616M/s/cpu to 0.714M/s/cpu). As Andrii pointed out, this approach is a bit complex and overkill for STP simluation. So I look forward to more input about this patch, is it possible to reach a better result? Or should I pause this work for now and wait for Arm64 to add some instruction for storing pairs of registers to unprivileged memory in privileged exception level? Thanks. xol-stp ------- uprobe-push ( 1 cpus): 0.868 ± 0.001M/s ( 0.868M/s/cpu) uretprobe-push ( 1 cpus): 0.616 ± 0.001M/s ( 0.616M/s/cpu) simulated-stp ------------- uprobe-push ( 1 cpus): 1.128 ± 0.002M/s ( 1.128M/s/cpu) uretprobe-push ( 1 cpus): 0.714 ± 0.001M/s ( 0.714M/s/cpu) [1] https://lore.kernel.org/all/20240910060407.1427716-1-liaochang1@huawei.com/ -- BR Liao, Chang