Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp357071pxb; Sat, 11 Sep 2021 07:14:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgBV3C9IAECW/Uv4wpiVZMPEX7EOeQaIHEWRz4utGgkJ92tDhrq1901OWwh3rNbbEqsqv0 X-Received: by 2002:a05:6638:2216:: with SMTP id l22mr2347349jas.39.1631369645812; Sat, 11 Sep 2021 07:14:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631369645; cv=none; d=google.com; s=arc-20160816; b=CrvgM66TN0fFPxWVz+CMS9I2yLFpJPDHjrcFt2qH346qwsHb+ed9eJzlDhVboiOazY lOkuLBZKH7P3iNBurCuMBV9bRI0MojOzBtvMooVuy+71jlSC6Rn4vwj+Mnc5cz6mtMuh mYT5KpTitviFhTeHMmVRGJXJ2w+/ZX0ThsnEBbAJAItQkYo56PZcXn37BdHowHeOf55q 8kpyYOdK2VzNH1SzIMFd5eNhusCr28fiBhwHtzPPcrMINHRuOad7PXyU6EaSlXa+T8Hn d317bbqW5RF8SymQEvGaSBD3aF2fWCnSCKb9Mt5gQM4hmeBe1HxV0fgoFd/WBDEMOCm8 4CAg== 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=kMaS6J9mA0wWol+ztJcdAYbABFnIHZL9xwuQFew+/PU=; b=aM7084m2Mjt45/wSpUC2e5B8cTbmzHVpxI1FVb0Xj+TedlAvAIBJPTmkDrbJ/XDcGe a3EdY8jqEzTXO56LuiwOP3u4tPcl12+AOtdh5nWE3HRf1xmVfC9MbJo8I9nhygnjAkRP BswilI8Pb5x6q6aF6lLpNEQWODGRSKqS2WKcAHTP+lANygSlE5Wxk9oc1nU+qg+r1Wxu 2Q6MLRM/fdP8enSu7tlZ3EENzkivI+pK8sokWHARtRU3WB01DYsrP/qamK0SbDkLEewG 721hashtlufTwLNH0EBmJvxDivGjzSi4Se2CX9MKbB5BqXp/aVM/MiVzlSLwqI4y24xT exsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y6si1376362ion.66.2021.09.11.07.13.51; Sat, 11 Sep 2021 07:14:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235809AbhIKOOC (ORCPT + 99 others); Sat, 11 Sep 2021 10:14:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:36614 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235331AbhIKOOC (ORCPT ); Sat, 11 Sep 2021 10:14:02 -0400 Received: from rorschach.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DC711611CC; Sat, 11 Sep 2021 14:12:48 +0000 (UTC) Date: Sat, 11 Sep 2021 10:12:47 -0400 From: Steven Rostedt To: Yinan Liu Cc: mark-pk.tsai@mediatek.com, peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] scripts: ftrace - move the nop-processing in ftrace_init to compile time Message-ID: <20210911101247.4a37ec51@rorschach.local.home> In-Reply-To: <20210911135043.16014-3-yinan@linux.alibaba.com> References: <20210911135043.16014-1-yinan@linux.alibaba.com> <20210911135043.16014-3-yinan@linux.alibaba.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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 11 Sep 2021 21:50:43 +0800 Yinan Liu wrote: > When ftrace is enabled, ftrace_init will consume a period of > time, usually around 15~20ms. Approximately 60% of the time is > consumed by nop-processing. Moving the nop-processing to the > compile time can speed up the kernel boot process. > > performance test: > env: Intel(R) Xeon(R) CPU E5-2682 v4 @ 2.50GHz > method: before and after patching, compare the > total time of ftrace_init(), and verify > the functionality of ftrace. > > avg_time of ftrace_init: > with patch: 7.114ms > without patch: 15.763ms What compiler are you using? Because by default, gcc should already do this for you. In fact, recordmcount isn't even called with the latest gcc, as gcc creates mcount_loc and inserts nops. This was implemented before, but because we use to have "ideal nops" that was determined at run time, because the different CPUs had different efficiency on what nop was used, we had to do it at run time. But that is no longer the case today, so we can revisit this. > > Signed-off-by: Yinan Liu > --- > kernel/trace/ftrace.c | 4 ++++ > scripts/recordmcount.h | 14 ++++++++++++++ > 2 files changed, 18 insertions(+) > > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c > index c236da868990..ae3fba331179 100644 > --- a/kernel/trace/ftrace.c > +++ b/kernel/trace/ftrace.c > @@ -6261,6 +6261,10 @@ static int ftrace_process_locs(struct module *mod, > * until we are finished with it, and there's no > * reason to cause large interrupt latencies while we do it. > */ > +#if defined CONFIG_X86 || defined CONFIG_X86_64 || defined CONFIG_ARM || defined CONFIG_ARM64 We don't list archs in generic files. The above needs to be something like: #ifdef ARCH_HAS_MCOUNT_NOP or some name like that, and then that macro gets defined by the arch header (include/asm/ftrace.h) > + ret = 0; > + goto out; > +#endif space should be here. > if (!mod) > local_irq_save(flags); > ftrace_update_code(mod, start_pg); -- Steve