On Sat, 11 Sep 2021 21:50:42 +0800Thanks !
Yinan Liu <yinan@xxxxxxxxxxxxxxxxx> wrote:
When ftrace is enabled, ftrace_init will consume a period ofNice. I like the idea of sorting at compile time.
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.
performance test:Why can't we enforce modules to be sorted too?
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 <yinan@xxxxxxxxxxxxxxxxx>
---
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)
+ sort(start, count, sizeof(*start),
+ ftrace_cmp_ips, NULL);
Best regards! ---Yinan liu