Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp400529pxb; Sat, 11 Sep 2021 08:30:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy25pGW/lBUAgvosTsiIuTUGLj6JO5NADN7q3GHB5+t6ZMz+8H9j8DyPxOfMOd/qkdY6nwx X-Received: by 2002:a17:906:2cd5:: with SMTP id r21mr3394746ejr.435.1631374218291; Sat, 11 Sep 2021 08:30:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631374218; cv=none; d=google.com; s=arc-20160816; b=Qof48MtlVhUGzCGVkBpFoWnX6E2PpLsSxvallSnpuMYoInDmAMc0p90pWH2cjiDgQp cYfjW+2ZzQ7muwtfdvQWxbC4ZdCTBkGE2Zesu8wdvjOh6updOV2cfVJf5P0m5pay9L90 DZUzwl0fkAljiizMceP/q6xWH7fqlscMrw+Aew6HBYjvUpIyKBGDzhNjx6ZO5HsNRk9D 9BKrqGYspvuKYpeyV7K3qE6gxz8afcamdak4japm6cflzJyrSUYxzIsHVwQaVSwJ8Kz2 dv82/sMLG1pUay5BI88tPFn9N9b+ZznbQSm1Cqg/FENsp/ojmsWgB/tEfs4LqxclbScj VwjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=Ft88jdyA4cPkwYqIMHpQhlQIHuhUIhCVB6uw3Cw2ZyU=; b=dNgaZM1t+dKi1StHoSHn+RaccrxlxsaWeUrOsTxAqlNNQJmTJxmGKqY2wYNxsba0Al xAYuLYuCUb+x3bihGEKap6N3t2ZSAlb7bf/k6K4MGrXE5Gt7i02CKirwDAvCawQ7PuJn OFDaPG1Gare9q7biFO+4jMpZqPbW3SrzGnLHYKdxuk62IplW0+3O7LxD2puP3/akEUJI V4KdNulu8oatjmeOcYj+1AbhLI6lMekJasmZ9ViIA+Nhe4RvnyJzjWoi1HGPGgXFP6lm nAHOUUqekmiqAZGgJxorcLIrvNsw+KtNSpwfYhs1ncaNt+dZdsaLmUd4WiITcIs7xeDi yiJw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h93si2648033edd.376.2021.09.11.08.29.54; Sat, 11 Sep 2021 08:30:18 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232110AbhIKP3t (ORCPT + 99 others); Sat, 11 Sep 2021 11:29:49 -0400 Received: from out30-54.freemail.mail.aliyun.com ([115.124.30.54]:34018 "EHLO out30-54.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230472AbhIKP3s (ORCPT ); Sat, 11 Sep 2021 11:29:48 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R111e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04395;MF=yinan@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0Uo.7xZj_1631374113; Received: from 30.30.120.103(mailfrom:yinan@linux.alibaba.com fp:SMTPD_---0Uo.7xZj_1631374113) by smtp.aliyun-inc.com(127.0.0.1); Sat, 11 Sep 2021 23:28:33 +0800 Message-ID: Date: Sat, 11 Sep 2021 23:28:32 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: [PATCH 2/2] scripts: ftrace - move the nop-processing in ftrace_init to compile time To: Steven Rostedt Cc: mark-pk.tsai@mediatek.com, peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org References: <20210911135043.16014-1-yinan@linux.alibaba.com> <20210911135043.16014-3-yinan@linux.alibaba.com> <20210911101247.4a37ec51@rorschach.local.home> From: Yinan Liu In-Reply-To: <20210911101247.4a37ec51@rorschach.local.home> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is my GCC version: GCC version 4.8.5 20150623 (red hat 4.8.5-44) (GCC) . In fact, I see the make_nop processing in recordmcount. I'm still confused why this part can be directly replaced? 在 2021/9/11 下午10:12, Steven Rostedt 写道: > 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