linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/8] kallsyms: Optimizes the performance of lookup symbols
@ 2022-09-20  7:13 Zhen Lei
  2022-09-20  7:13 ` [PATCH v4 1/8] scripts/kallsyms: rename build_initial_tok_table() Zhen Lei
                   ` (7 more replies)
  0 siblings, 8 replies; 25+ messages in thread
From: Zhen Lei @ 2022-09-20  7:13 UTC (permalink / raw)
  To: Josh Poimboeuf, Jiri Kosina, Miroslav Benes, Petr Mladek,
	Joe Lawrence, live-patching, linux-kernel, Masahiro Yamada,
	Alexei Starovoitov, Jiri Olsa, Kees Cook, Andrew Morton,
	Luis Chamberlain, linux-modules
  Cc: Zhen Lei

v3 --> v4:
1. Move the declaration of function kallsyms_sym_address() to linux/kallsyms.h,
   fix a build warning.

v2 --> v3:
1. Improve test cases, perform complete functional tests on functions
   kallsyms_lookup_name(), kallsyms_on_each_symbol() and
   kallsyms_on_each_match_symbol().
2. Add patch [PATCH v3 2/8] scripts/kallsyms: ensure that all possible
   combinations are compressed.
3. The symbol type is not compressed regardless of whether
   CONFIG_KALLSYMS_ALL is set or not. The memory overhead is increased
   by less than 20KiB if CONFIG_KALLSYMS_ALL=n.
4. Discard [PATCH v2 3/8] kallsyms: Adjust the types of some local variables

v1 --> v2:
Add self-test facility

v1:
Currently, to search for a symbol, we need to expand the symbols in
'kallsyms_names' one by one, and then use the expanded string for
comparison. This is very slow.

In fact, we can first compress the name being looked up and then use
it for comparison when traversing 'kallsyms_names'.

This patch series optimizes the performance of function kallsyms_lookup_name(),
and function klp_find_object_symbol() in the livepatch module. Based on the
test results, the performance overhead is reduced to 5%. That is, the
performance of these functions is improved by 20 times.

To avoid increasing the kernel size in non-debug mode, the optimization is only
for the case CONFIG_KALLSYMS_ALL=y.


Zhen Lei (8):
  scripts/kallsyms: rename build_initial_tok_table()
  scripts/kallsyms: ensure that all possible combinations are compressed
  scripts/kallsyms: don't compress symbol types
  kallsyms: Improve the performance of kallsyms_lookup_name()
  kallsyms: Add helper kallsyms_on_each_match_symbol()
  livepatch: Use kallsyms_on_each_match_symbol() to improve performance
  livepatch: Improve the search performance of
    module_kallsyms_on_each_symbol()
  kallsyms: Add self-test facility

 include/linux/kallsyms.h   |   9 +
 init/Kconfig               |  13 ++
 kernel/Makefile            |   1 +
 kernel/kallsyms.c          | 106 +++++++++-
 kernel/kallsyms_selftest.c | 423 +++++++++++++++++++++++++++++++++++++
 kernel/livepatch/core.c    |  25 ++-
 kernel/module/kallsyms.c   |  13 +-
 scripts/kallsyms.c         |  24 ++-
 8 files changed, 598 insertions(+), 16 deletions(-)
 create mode 100644 kernel/kallsyms_selftest.c

-- 
2.25.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2022-09-30 11:44 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-20  7:13 [PATCH v4 0/8] kallsyms: Optimizes the performance of lookup symbols Zhen Lei
2022-09-20  7:13 ` [PATCH v4 1/8] scripts/kallsyms: rename build_initial_tok_table() Zhen Lei
2022-09-21  7:47   ` Petr Mladek
2022-09-20  7:13 ` [PATCH v4 2/8] scripts/kallsyms: ensure that all possible combinations are compressed Zhen Lei
2022-09-21  8:00   ` Petr Mladek
2022-09-21  8:31     ` Leizhen (ThunderTown)
2022-09-21 12:46       ` Leizhen (ThunderTown)
2022-09-20  7:13 ` [PATCH v4 3/8] scripts/kallsyms: don't compress symbol types Zhen Lei
2022-09-21  9:00   ` Petr Mladek
2022-09-21 13:13     ` Leizhen (ThunderTown)
2022-09-20  7:13 ` [PATCH v4 4/8] kallsyms: Improve the performance of kallsyms_lookup_name() Zhen Lei
2022-09-21 15:25   ` Petr Mladek
2022-09-22  2:15     ` Leizhen (ThunderTown)
2022-09-22  7:02       ` Petr Mladek
2022-09-22  7:21         ` Leizhen (ThunderTown)
2022-09-22 13:17           ` Petr Mladek
2022-09-28  1:35         ` Leizhen (ThunderTown)
2022-09-30 11:37           ` Leizhen (ThunderTown)
2022-09-22  7:14       ` Leizhen (ThunderTown)
2022-09-20  7:13 ` [PATCH v4 5/8] kallsyms: Add helper kallsyms_on_each_match_symbol() Zhen Lei
2022-09-21 15:30   ` Petr Mladek
2022-09-22  2:16     ` Leizhen (ThunderTown)
2022-09-20  7:13 ` [PATCH v4 6/8] livepatch: Use kallsyms_on_each_match_symbol() to improve performance Zhen Lei
2022-09-20  7:13 ` [PATCH v4 7/8] livepatch: Improve the search performance of module_kallsyms_on_each_symbol() Zhen Lei
2022-09-20  7:13 ` [PATCH v4 8/8] kallsyms: Add self-test facility Zhen Lei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).