All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yonghong Song <yonghong.song@linux.dev>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Kernel Team <kernel-team@fb.com>,
	Martin KaFai Lau <martin.lau@kernel.org>
Subject: Re: [PATCH bpf-next 3/4] selftests/bpf: Fix possible ksyms test failure with LTO kernel
Date: Mon, 4 Mar 2024 23:24:36 -0800	[thread overview]
Message-ID: <a6b6765a-6570-48de-8a2a-87fd890c80a0@linux.dev> (raw)
In-Reply-To: <CAADnVQK1RTkyT-87=43WuJk+69mO8eK58AXojRvCYFHKD8V3ow@mail.gmail.com>


On 3/4/24 9:37 PM, Alexei Starovoitov wrote:
> On Sat, Mar 2, 2024 at 8:50 AM Yonghong Song <yonghong.song@linux.dev> 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@linux.dev>
>> ---
>>   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.

Thanks for pointing this out! Let me do some investigation on
how to resolve this.


  reply	other threads:[~2024-03-05  7:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-02 16:50 [PATCH bpf-next 0/4] selftests/bpf: Fix a couple of test failures with LTO kernel Yonghong Song
2024-03-02 16:50 ` [PATCH bpf-next 1/4] selftests/bpf: Replace CHECK with ASSERT macros for ksyms test Yonghong Song
2024-03-05  0:17   ` Andrii Nakryiko
2024-03-05  7:21     ` Yonghong Song
2024-03-02 16:50 ` [PATCH bpf-next 2/4] selftests/bpf: Add check_lto_kernel() helper Yonghong Song
2024-03-02 16:50 ` [PATCH bpf-next 3/4] selftests/bpf: Fix possible ksyms test failure with LTO kernel Yonghong Song
2024-03-05  5:37   ` Alexei Starovoitov
2024-03-05  7:24     ` Yonghong Song [this message]
2024-03-02 16:50 ` [PATCH bpf-next 4/4] selftests/bpf: Fix possible kprobe_multi_bench_attach " Yonghong Song

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a6b6765a-6570-48de-8a2a-87fd890c80a0@linux.dev \
    --to=yonghong.song@linux.dev \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=martin.lau@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.