Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2823557pxb; Sun, 3 Oct 2021 06:44:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyl+J8yQ+hTIRCHl102vlqiVZWXAOcifiGTal7oG29js8D5xwc4bV2w18a1iM0qUMWdpUvz X-Received: by 2002:a05:6402:510b:: with SMTP id m11mr11821252edd.82.1633268691278; Sun, 03 Oct 2021 06:44:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633268691; cv=none; d=google.com; s=arc-20160816; b=Yh45pY0Ou29QVQJp65OwCILLT0vvA/ZTtb51QQexQgQz9CdiYTr7bjc9vuT3qTkSDJ WJCCT+atTZoO3QXgxr54pCMMIbJ6h2S2V1jrYJY1Dr5FWEy8au59jI3AEU/t4CKUxGYp dMw3VVONa3VCpAGQ6AawP3+IWpYAVVki/I68YoIPvbizWbCg1BsA1WkZrABqeuTrQmlm rrEd9lFazwJ10Bc7d/tCroLrNLx4CLJqCijq8EqiziCFNT9GGRvGjSfx6TZ99LuVqlFI 6FpUpq4hFSXSGEqaY+IsQjrzS2Lg4iGghmgHf9UC8ELU3rzn07O+2Ig2SVp4+hkIkOt2 92Xw== 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=cvyoU5l4NIyE6N0u7Lbcam7mcCk9LVubdIpG0Fd9rkU=; b=LQmm9Nb7yHi1Hm40hPyvCfcwNWGZns3FalyDDUOwWvcqIMoK/5W76XN6kWduqHqVJS rjUacsYugfxpro444v+3LYf22EqAi3djbKQlMZ8rgV37luYo3VJiJ9jZZSukJfClwnRZ gQgguBDN5W3gGIW6zVIaV/6Ll3Zw02ORaXXsDf6J8V7EAFKDhez2MpmsiB/t1VvxO0Zt CU5DmozVSPtAg6ASBpk1zB4KueTnss10eLyRi+u2JyaziLKurbEJD896aFlw/dt3t6x/ 60BgdwnGjcvGg8mRhVxo6EydzkPAoN5958CkAqBwz/D1QUlj7WIzBPKaDA/wkcPYVJK8 +n8Q== 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 6si15825182ejl.543.2021.10.03.06.44.25; Sun, 03 Oct 2021 06:44:51 -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 S230356AbhJCNoB (ORCPT + 99 others); Sun, 3 Oct 2021 09:44:01 -0400 Received: from out30-131.freemail.mail.aliyun.com ([115.124.30.131]:51404 "EHLO out30-131.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230350AbhJCNoA (ORCPT ); Sun, 3 Oct 2021 09:44:00 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R331e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04357;MF=yinan@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0UqNYrt8_1633268530; Received: from 192.168.31.237(mailfrom:yinan@linux.alibaba.com fp:SMTPD_---0UqNYrt8_1633268530) by smtp.aliyun-inc.com(127.0.0.1); Sun, 03 Oct 2021 21:42:11 +0800 Message-ID: <0b783c9e-c129-6907-0637-5c7638158a65@linux.alibaba.com> Date: Sun, 3 Oct 2021 21:42:10 +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.1 Subject: Re: [PATCH 1/2] scripts: ftrace - move the sort-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-2-yinan@linux.alibaba.com> <20210911095937.5a298619@rorschach.local.home> From: Yinan Liu In-Reply-To: <20210911095937.5a298619@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 在 2021/9/11 下午9:59, Steven Rostedt 写道: > On Sat, 11 Sep 2021 21:50:42 +0800 > Yinan Liu wrote: > >> When ftrace is enabled, ftrace_init will consume a period of >> time, usually around 15~20 ms. Approximately 40% of the time is >> consumed by sort-processing. Moving the sort-processing to the >> compile time can speed up the kernel boot process. >> > Nice. I like the idea of sorting at compile time. Thanks ! >> 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: 8.352 ms >> without patch: 15.763 ms >> >> Signed-off-by: Yinan Liu >> --- >> kernel/trace/ftrace.c | 5 ++- >> scripts/link-vmlinux.sh | 6 +-- >> scripts/sorttable.c | 2 + >> scripts/sorttable.h | 109 +++++++++++++++++++++++++++++++++++++++++++++++- >> 4 files changed, 115 insertions(+), 7 deletions(-) >> >> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c >> index 7efbc8aaf7f6..c236da868990 100644 >> --- a/kernel/trace/ftrace.c >> +++ b/kernel/trace/ftrace.c >> @@ -6189,8 +6189,9 @@ static int ftrace_process_locs(struct module *mod, >> if (!count) >> return 0; >> >> - sort(start, count, sizeof(*start), >> - ftrace_cmp_ips, NULL); >> + if (mod) > Why can't we enforce modules to be sorted too? hi, Sorry for my slow progress . I have encountered some problems with the sorting of the module's mcount in compile time. The .ko file will be relocated after insmod or modprobe, most of the mcount relocation is based on .text section, but there are also a small part of mcount relocation based on .init.text section such as module_init(). The loading position of .init.text and .text does not seem to be in a definite order. For example, when I insmod ip_tables.ko twice, the front and back positions of init.text and .text are different, so we cannot sort the mcounts in the two sections, which makes the mcount sorting in the module meaningless. What is your opinion on this? >> + sort(start, count, sizeof(*start), >> + ftrace_cmp_ips, NULL); > Best regards! > ---Yinan liu