Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp884638pxb; Fri, 22 Apr 2022 13:24:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdD+05aVT2mVxoSqI26f0166+2V2JihTk1CeXMgvhXxGTAuCs/HYAYOGf5BtKr0EKWz1e2 X-Received: by 2002:a05:6a00:1893:b0:50a:9b07:20bd with SMTP id x19-20020a056a00189300b0050a9b0720bdmr6525706pfh.66.1650659076810; Fri, 22 Apr 2022 13:24:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650659076; cv=none; d=google.com; s=arc-20160816; b=MZVQqlDg/ZzHxxit31h5xHzYMKairPGC8Xo6p6jUBp+g2fQBiqV3sqgscozURAuvOk xy+7PrBLxXKFoDFHZ7wEM9KZKcFe3jkhA2H6a3chjXvYroL/5ip9R/Hn/02WL1OcGp8h iGC9fPnLrIAD4Ce3ItHHbiJmJJ5XxCBVKu1z2IFuK7wh4eAxWB+Scr3CY74eybLM4ssQ vkn+TiWXugl9R7aDKwfegXxdC6mSlop4eB1WRr7I6fnsXWG21sYE79Z78fcaxvOZdkLN Vkgim8cR9ZJre8LPbK3VjObRR1brAA337LI3Ue9VSYWEU7/yyBNpyPukBblgQFw7XFP7 uQCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=OdrVJfnSPnHmyQ9znYGAwgPNP+B+L1Yb610mgaZ1uhM=; b=lBt7y9vk2U0Ztc3GNUtSx8bGOapegBAEcxsuAYuud1pp8NJevyT1bSLcEAf9EHNEPJ PpX26886WI2MsRgKIspo9ow6G2pqSXeD/ylAcPzIp4HvPbZY+YpKvJBMJYtf/9Vst/To ZK0887c3HJ/W40he+V/+S3u8YrdXynSOSxEwuHIbIIjeTtY7S+ls7NATl9unp61WRmhA fQ0x2BE7XCSFCZmPNwmpam0rMk5LMB0hY0ARGiL2nN2T5R+9yuATMxXQpHRYLYwcEQaS mUM/xRYivoWU9kd8aG94Cdm84zUXfu51UtioAGqG3RYj7tNy+JU8tcCQyW+gqpufcNrn Zy0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id o6-20020a170902d4c600b001567d82c09asi10273372plg.174.2022.04.22.13.24.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 13:24:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 11D2D26B583; Fri, 22 Apr 2022 12:12:04 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376713AbiDUOJf (ORCPT + 99 others); Thu, 21 Apr 2022 10:09:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358063AbiDUOJd (ORCPT ); Thu, 21 Apr 2022 10:09:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24D1F2C3 for ; Thu, 21 Apr 2022 07:06:44 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id A711D61D4D for ; Thu, 21 Apr 2022 14:06:43 +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 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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