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 A59C4C433FE for ; Thu, 21 Apr 2022 14:07:51 +0000 (UTC) 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:References:In-Reply-To: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=eS8hSJkzy0KJKnQMy16sZh5XevOok0ayKQamAczBHks=; b=Y9RbMazrc3vkDb ZZhH1yWA62ba+IzYRUR2KWw9w8sSRnRHGVknEm51RIg1oG2jsIT0FQmCP9CTH/3qCHpQJcLURdZse HgKoZL9/7X0zREQldQOeIUbtTevNCiW8LwlFONiFPc0uXJS/PSvU5R0KAuM5zE4b0fxI9YqWqFAKu WtNEWPWm4OivlrjgMbs8Tn+ZZFRIltZltPsdIlSAH4M1SRpPABptbxy2ayYtlQtajrp2TuyBecegC 5cgd09FYN8k6GkOqMJweyK4VsHEizdT9t7kBA0ojc1Jof9nORYNp49jhRCLXUPqIvRsYzJ1Qe+HSq C9675ezqEIix45rXtNhg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhXSL-00DgNG-FY; Thu, 21 Apr 2022 14:06:49 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhXSH-00DgM4-Kq for linux-arm-kernel@lists.infradead.org; Thu, 21 Apr 2022 14:06:47 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4641CB824F6; Thu, 21 Apr 2022 14:06:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0D01C385A5; Thu, 21 Apr 2022 14:06:41 +0000 (UTC) Date: Thu, 21 Apr 2022 10:06:39 -0400 From: Steven Rostedt To: Mark Rutland Cc: Wang ShaoBo , cj.chengjian@huawei.com, huawei.libin@huawei.com, xiexiuqi@huawei.com, liwei391@huawei.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will@kernel.org, zengshun.wu@outlook.com Subject: Re: [RFC PATCH -next v2 3/4] arm64/ftrace: support dynamically allocated trampolines Message-ID: <20220421100639.03c0d123@gandalf.local.home> In-Reply-To: References: <20220316100132.244849-1-bobo.shaobowang@huawei.com> <20220316100132.244849-4-bobo.shaobowang@huawei.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220421_070645_921304_7FE4029E X-CRM114-Status: GOOD ( 18.13 ) 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 On Thu, 21 Apr 2022 14:10:04 +0100 Mark Rutland wrote: > On Wed, Mar 16, 2022 at 06:01:31PM +0800, Wang ShaoBo wrote: > > From: Cheng Jian > > > > When tracing multiple functions customly, a list function is called > > in ftrace_(regs)_caller, which makes all the other traced functions > > recheck the hash of the ftrace_ops when tracing happend, apparently > > it is inefficient. > > ... and when does that actually matter? Who does this and why? I don't think it was explained properly. What dynamically allocated trampolines give you is this. Let's say you have 10 ftrace_ops registered (with bpf and kprobes this can be quite common). But each of these ftrace_ops traces a function (or functions) that are not being traced by the other ftrace_ops. That is, each ftrace_ops has its own unique function(s) that they are tracing. One could be tracing schedule, the other could be tracing ksoftirqd_should_run (whatever). Without this change, because the arch does not support dynamically allocated trampolines, it means that all these ftrace_ops will be registered to the same trampoline. That means, for every function that is traced, it will loop through all 10 of theses ftrace_ops and check their hashes to see if their callback should be called or not. With dynamically allocated trampolines, each ftrace_ops will have their own trampoline, and that trampoline will be called directly if the function is only being traced by the one ftrace_ops. This is much more efficient. If a function is traced by more than one ftrace_ops, then it falls back to the loop. -- Steve _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel