scripts/kallsyms: decrease expand_symbol() / cleanup_symbol_name() calls
Currently, expand_symbol() is called many times to get the uncompressed
symbol names for sorting, and also for adding comments.
With the output order shuffled in the previous commit, the symbol data
are now written in the following order:
(1) kallsyms_num_syms
(2) kallsyms_names <-- need compressed names
(3) kallsyms_markers
(4) kallsyms_token_table
(5) kallsyms_token_index
(6) kallsyms_addressed / kallsyms_offsets <-- need uncompressed names (for commenting)
(7) kallsyms_relative_base
(8) kallsyms_seq_of_names <-- need uncompressed names (for sorting)
The compressed names are only needed by (2).
Call expand_symbol() between (2) and (3) to restore the original symbol
names. This requires just one expand_symbol() call for each symbol.
Call cleanup_symbol_name() between (7) and (8) instead of during sorting.
It is allowed to overwrite the ->sym field because (8) just outputs the
index instead of the name of each symbol. Again, this requires just one
cleanup_symbol_name() call for each symbol.
This refactoring makes it ~30% faster.
[Before]
$ time scripts/kallsyms --all-symbols --absolute-percpu --base-relative \
.tmp_vmlinux.kallsyms2.syms >/dev/null
real 0m1.027s
user 0m1.010s
sys 0m0.016s
[After]
$ time scripts/kallsyms --all-symbols --absolute-percpu --base-relative \
.tmp_vmlinux.kallsyms2.syms >/dev/null
real 0m0.717s
user 0m0.717s
sys 0m0.000s
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Showing
Please register or sign in to comment