Re: [PATCH bpf-next 3/4] selftests/bpf: Fix possible ksyms test failure with LTO kernel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Mar 2, 2024 at 8:50 AM Yonghong Song <yonghong.song@xxxxxxxxx> wrote:
>
> In my locally build clang LTO kernel (enabling CONFIG_LTO and
> CONFIG_LTO_CLANG_THIN), ksyms test failed like:
>   test_ksyms:PASS:kallsyms_fopen 0 nsec
>   test_ksyms:FAIL:ksym_find symbol 'bpf_link_fops' not found
>   #118     ksyms:FAIL
>
> The reason is that 'bpf_link_fops' is renamed to
>   bpf_link_fops.llvm.8325593422554671469
> Due to cross-file inlining, the static variable 'bpf_link_fops'
> in syscall.c is used by a function in another file. To avoid
> potential duplicated names, the llvm added suffix '.llvm.<hash>'.
>
> To fix the failure, we can skip this test with LTO kernel
> if the symbol 'bpf_link_fops' is not found in kallsyms.
>
> After this patch, with the same LTO kernel:
>   #118     ksyms:SKIP
>
> Signed-off-by: Yonghong Song <yonghong.song@xxxxxxxxx>
> ---
>  tools/testing/selftests/bpf/prog_tests/ksyms.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/ksyms.c b/tools/testing/selftests/bpf/prog_tests/ksyms.c
> index e081f8bf3f17..cd81f190c5d7 100644
> --- a/tools/testing/selftests/bpf/prog_tests/ksyms.c
> +++ b/tools/testing/selftests/bpf/prog_tests/ksyms.c
> @@ -21,7 +21,11 @@ void test_ksyms(void)
>                 return;
>         }
>         if (err == -ENOENT) {
> -               ASSERT_TRUE(false, "ksym_find for bpf_link_fops");
> +               /* bpf_link_fops might be renamed to bpf_link_fops.llvm.<hash> in LTO kernel. */
> +               if (check_lto_kernel() == 1)
> +                       test__skip();
> +               else
> +                       ASSERT_TRUE(false, "ksym_find for bpf_link_fops");

I'm afraid LTO breakage is bigger than this.
pid_iter program as part of bpftool is using bpf_link_fops too.
I suspect that part of bpftool feature is broken on LTO kernel.
We need to find a solution instead of 'skip' a selftest.





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux