From: Fuyu Zhao <zhaofuyu@vivo.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Eduard Zingerman <eddyz87@gmail.com>,
bpf@vger.kernel.org, alan.maguire@oracle.com, andrii@kernel.org,
ast@kernel.org, daniel@iogearbox.net, memxor@gmail.com,
martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev,
jolsa@kernel.org, emil@etsalapatis.com, ihor.solodrai@linux.dev,
shuah@kernel.org, yatsenko@meta.com,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [RFC PATCH bpf-next v3 2/2] selftests/bpf: add tests for selective kmod BTF loading
Date: Sat, 22 Aug 2026 19:57:37 +0800 [thread overview]
Message-ID: <bed1b548-7695-49b5-b2bd-84a218d1bcbf@vivo.com> (raw)
In-Reply-To: <CAEf4BzYkFPK37zaW10RBX04un5xuWs42gJ2pAtE0_iy2+X=58g@mail.gmail.com>
On 8/22/2026 2:55 AM, Andrii Nakryiko wrote:
> On Thu, Aug 20, 2026 at 8:51 PM Fuyu Zhao <zhaofuyu@vivo.com> wrote:
>>
>>
>>
>> On 8/21/2026 8:10 AM, Eduard Zingerman wrote:
>>> On Wed, 2026-08-19 at 17:04 +0800, Fuyu Zhao wrote:
>>>
>>> ...
>>>
>>>> +++ b/tools/testing/selftests/bpf/prog_tests/kmod_btfs.c
>>>> @@ -0,0 +1,196 @@
>>>> +// SPDX-License-Identifier: GPL-2.0
>>>> +#include <test_progs.h>
>>>> +#include "kmod_btfs.skel.h"
>>>> +
>>>> +static bool btf_skipped;
>>>> +static bool dup_ignored;
>>>> +
>>>> +static const char btf_skip_fmt[] =
>>>> + "libbpf: skipping module BTF '%s', not in kmod_btf_names\n";
>>>> +static const char dup_ignore_fmt[] =
>>>> + "libbpf: duplicate kmod BTF name '%s' ignored\n";
>>>> +
>>>> +static int libbpf_print_cb(enum libbpf_print_level level, const char *fmt,
>>>> + va_list args)
>>>> +{
>>>> + if (!strcmp(fmt, btf_skip_fmt)) {
>>>> + if (!strcmp(va_arg(args, char *), "bpf_test_no_cfi"))
>>>> + btf_skipped = true;
>>>> + } else if (!strcmp(fmt, dup_ignore_fmt)) {
>>>> + if (!strcmp(va_arg(args, char *), "bpf_testmod"))
>>>> + dup_ignored = true;
>>>> + }
>>>> +
>>>> + return 0;
>>>> +}
>>>
>>> Idk what Andrii would say about this, but I'd rather add an internal
>>> function akin to:
>>>
>>> size_t bpf_object_btf_module_cnt(const struct bpf_object *obj);
>>>
>>> in libbpf.c and expose it via libbpf_internal.h (*not* via API),
>>> instead of intercepting log messages.
>>>
>>> ...
>>
>> I think your suggestion is better. It also addresses the issue raised by
>> the bot about potentially hiding other libbpf logs. I'll wait for Andrii's
>> feedback on this.
>>
>
> I would do neither and just not validate explicitly that we skipped
> (or not) some module. Instead, I'd see if it's simple and maintainable
> to do a functional test: try to attach to a func or have relocation
> fail against a type of a test module you explicitly do not allow to
> load. If that succeeds, bad. Also have positive and negative tests to
> show this custom kernel module list makes a difference as promised.
>
> And try to keep the boilerplate to a minimum with all this, don't go overboard.
>
Ah, this looks like a better approach. I'll follow your suggestion while
keeping the tests minimal.
Thanks,
Fuyu
>> Thanks,
>> Fuyu
>>
prev parent reply other threads:[~2026-08-22 11:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 9:04 [RFC PATCH bpf-next v3 0/2] libbpf: Improve BPF load performance by selectively loading kmod BTFs Fuyu Zhao
2026-08-19 9:04 ` [RFC PATCH bpf-next v3 1/2] libbpf: support selective kernel module BTF loading via bpf_object_open_opts Fuyu Zhao
2026-08-19 9:35 ` bot+bpf-ci
2026-08-20 23:58 ` Eduard Zingerman
2026-08-21 3:51 ` Fuyu Zhao
2026-08-21 18:51 ` Andrii Nakryiko
2026-08-22 11:57 ` Fuyu Zhao
2026-08-19 9:04 ` [RFC PATCH bpf-next v3 2/2] selftests/bpf: add tests for selective kmod BTF loading Fuyu Zhao
2026-08-19 9:50 ` bot+bpf-ci
2026-08-21 0:10 ` Eduard Zingerman
2026-08-21 3:51 ` Fuyu Zhao
2026-08-21 18:55 ` Andrii Nakryiko
2026-08-22 11:57 ` Fuyu Zhao [this message]
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=bed1b548-7695-49b5-b2bd-84a218d1bcbf@vivo.com \
--to=zhaofuyu@vivo.com \
--cc=alan.maguire@oracle.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yatsenko@meta.com \
--cc=yonghong.song@linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®