linux/include
Zhen Lei 30f3bb0977 kallsyms: Add self-test facility
Added test cases for basic functions and performance of functions
kallsyms_lookup_name(), kallsyms_on_each_symbol() and
kallsyms_on_each_match_symbol(). It also calculates the compression rate
of the kallsyms compression algorithm for the current symbol set.

The basic functions test begins by testing a set of symbols whose address
values are known. Then, traverse all symbol addresses and find the
corresponding symbol name based on the address. It's impossible to
determine whether these addresses are correct, but we can use the above
three functions along with the addresses to test each other. Due to the
traversal operation of kallsyms_on_each_symbol() is too slow, only 60
symbols can be tested in one second, so let it test on average once
every 128 symbols. The other two functions validate all symbols.

If the basic functions test is passed, print only performance test
results. If the test fails, print error information, but do not perform
subsequent performance tests.

Start self-test automatically after system startup if
CONFIG_KALLSYMS_SELFTEST=y.

Example of output content: (prefix 'kallsyms_selftest:' is omitted
 start
  ---------------------------------------------------------
 | nr_symbols | compressed size | original size | ratio(%) |
 |---------------------------------------------------------|
 |     107543 |       1357912   |      2407433  |  56.40   |
  ---------------------------------------------------------
 kallsyms_lookup_name() looked up 107543 symbols
 The time spent on each symbol is (ns): min=630, max=35295, avg=7353
 kallsyms_on_each_symbol() traverse all: 11782628 ns
 kallsyms_on_each_match_symbol() traverse all: 9261 ns
 finish

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
2022-11-15 00:42:02 -08:00
..
acpi ACPI: APEI: Fix integer overflow in ghes_estatus_pool_init() 2022-10-13 20:40:09 +02:00
asm-generic hyperv-fixes for v6.1-rc5 2022-11-11 09:24:03 -08:00
clocksource
crypto
drm Merge drm/drm-fixes into drm-misc-fixes 2022-10-20 09:09:00 +02:00
dt-bindings These are the pin control changes for the v6.1 kernel cycle: 2022-10-11 10:59:59 -07:00
keys
kunit
kvm
linux kallsyms: Add self-test facility 2022-11-15 00:42:02 -08:00
math-emu
media media fixes for v6.1-rc2 2022-10-22 15:30:15 -07:00
memory
misc
net netlink: introduce bigendian integer types 2022-11-01 21:29:06 -07:00
pcmcia
ras
rdma
rv
scsi
soc RISC-V Patches for the 6.1 Merge Window, Part 2 2022-10-14 11:21:11 -07:00
sound ASoC: Fixes for v6.1 2022-10-27 08:26:32 +02:00
target
trace linux-watchdog 6.1-rc2 tag 2022-10-21 12:25:39 -07:00
uapi dmaengine fixes for v6.1 2022-11-11 09:19:05 -08:00
ufs
vdso
video
xen xen/virtio: enable grant based virtio on x86 2022-10-10 14:31:26 +02:00