Re: [PATCH v9] kallsyms: Add self-test facility
From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: 2022-12-15 14:43:25
Also in:
linux-m68k, live-patching, lkml
Hi Zhen, On Thu, Dec 15, 2022 at 2:58 PM Leizhen (ThunderTown) [off-list ref] wrote:
On 2022/12/15 21:24, Geert Uytterhoeven wrote:quoted
On Thu, Dec 15, 2022 at 1:34 PM Leizhen (ThunderTown) [off-list ref] wrote:quoted
On 2022/12/15 17:39, Geert Uytterhoeven wrote:quoted
On Thu, Dec 15, 2022 at 10:16 AM Leizhen (ThunderTown) [off-list ref] wrote:quoted
On 2022/12/15 16:50, Geert Uytterhoeven wrote:quoted
On Tue, Nov 15, 2022 at 9:41 AM Zhen Lei [off-list ref] wrote:quoted
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 <redacted>Thanks for your patch, which is now commit 30f3bb09778de64e ("kallsyms: Add self-test facility") in linus/master. I gave this a try on m68k (atari_defconfig + CONFIG_KALLSYMS_SELFTEST=y), but it failed: start kallsyms_lookup_name() for kallsyms_test_func_static failed: addr=0, expect 60ab0 kallsyms_lookup_name() for kallsyms_test_func failed: addr=0, expect 60ac0 kallsyms_lookup_name() for kallsyms_test_func_weak failed: addr=0, expect 60ac2 kallsyms_lookup_name() for vmalloc failed: addr=0, expect c272a kallsyms_lookup_name() for vfree failed: addr=0, expect c2142 kallsyms_on_each_match_symbol() for kallsyms_test_func_static failed: count=0, addr=0, expect 60ab0 kallsyms_on_each_match_symbol() for kallsyms_test_func failed: count=0, addr=0, expect 60ac0 kallsyms_on_each_match_symbol() for kallsyms_test_func_weak failed: count=0, addr=0, expect 60ac2 kallsyms_on_each_match_symbol() for vmalloc failed: count=0, addr=0, expect c272a kallsyms_on_each_match_symbol() for vfree failed: count=0, addr=0, expect c2142 abort
Oh, maybe you can "git reset --hard 30f3bb09778de64" and try again. 30f3bb09778de64 kallsyms: Add self-test facility But the latest kernel is OK on x86. So other patches are unlikely to affect this function.
On 30f3bb09778de64 it fails the same way:
start
kallsyms_lookup_name() for kallsyms_test_func_static failed:
addr=8dbc, expect 60308
kallsyms_lookup_name() for kallsyms_test_func failed: addr=8dbc,
expect 60318
kallsyms_lookup_name() for kallsyms_test_func_weak failed:
addr=8dbc, expect 6031a
kallsyms_lookup_name() for vmalloc failed: addr=8dbc, expect bdc88
kallsyms_lookup_name() for vfree failed: addr=8dbc, expect bd6de
kallsyms_on_each_match_symbol() for kallsyms_test_func_static
failed: count=24890, addr=1ee870, expect 60308
kallsyms_on_each_match_symbol() for kallsyms_test_func failed:
count=24890, addr=1ee870, expect 60318
kallsyms_on_each_match_symbol() for kallsyms_test_func_weak
failed: count=24890, addr=1ee870, expect 6031a
kallsyms_on_each_match_symbol() for vmalloc failed: count=24890,
addr=1ee870, expect bdc88
kallsyms_on_each_match_symbol() for vfree failed: count=24890,
addr=1ee870, expect bd6de
abort
Is m68k big-endian?
Yes it is. And 32-bit values are aligned to only 2 bytes.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds