lkml.org 
[lkml]   [2022]   [Nov]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v9] kallsyms: Add self-test facility
From
Date


On 2022/11/15 16:33, Zhen Lei wrote:
> 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>
> ---
> include/linux/kallsyms.h | 1 +
> init/Kconfig | 13 +
> kernel/Makefile | 1 +
> kernel/kallsyms.c | 2 +-
> kernel/kallsyms_selftest.c | 485 +++++++++++++++++++++++++++++++++++++
> kernel/kallsyms_selftest.h | 13 +
> 6 files changed, 514 insertions(+), 1 deletion(-)
> create mode 100644 kernel/kallsyms_selftest.c
> create mode 100644 kernel/kallsyms_selftest.h

v8 --> v9:
[v8] https://lkml.org/lkml/2022/11/2/225

Adjust the prototype of some callback functions. Because 7/9 and 8/9
in v8 are dropped.

--
Regards,
Zhen Lei

\
 
 \ /
  Last update: 2022-11-15 09:45    [W:0.183 / U:0.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site