BPF List
 help / color / mirror / Atom feed
From: Jiri Olsa <olsajiri@gmail.com>
To: Fuyu Zhao <zhaofuyu@vivo.com>
Cc: bpf@vger.kernel.org, eddyz87@gmail.com,
	andrii.nakryiko@gmail.com, alan.maguire@oracle.com
Subject: Re: [PATCH bpf-next v7 2/2] selftests/bpf: add tests for selective module BTF loading
Date: Mon, 7 Sep 2026 10:34:09 +0200	[thread overview]
Message-ID: <ap53Ac6p_DVybHi0@krava> (raw)
In-Reply-To: <20260907053847.1115-3-zhaofuyu@vivo.com>

On Mon, Sep 07, 2026 at 01:38:47PM +0800, Fuyu Zhao wrote:

SNIP

> +static void btf_module_allowlist_default(void)
> +{
> +	struct btf_module_allowlist *skel;
> +	int ret;
> +	LIBBPF_OPTS(bpf_object_open_opts, opts);
> +
> +	skel = btf_module_allowlist__open();
> +	if (!ASSERT_OK_PTR(skel, "btf_module_allowlist__open"))
> +		return;
> +
> +	ret = btf_module_allowlist__load(skel);
> +	ASSERT_OK(ret, "btf_module_allowlist__load");
> +
> +	btf_module_allowlist__destroy(skel);
> +	skel = NULL;
> +
> +	skel = btf_module_allowlist__open_opts(&opts);
> +	if (!ASSERT_OK_PTR(skel, "btf_module_allowlist__open_opts"))
> +		return;
> +
> +	ret = btf_module_allowlist__load(skel);
> +	ASSERT_OK(ret, "btf_module_allowlist__load opts");
> +
> +	btf_module_allowlist__destroy(skel);

^^^ seems redundant, I don't think we need to test that

SNIP

> +void test_btf_module_allowlist(void)
> +{
> +	struct btf *vmlinux_btf = NULL;
> +	struct btf *module_btf = NULL;
> +
> +	if (!env.has_testmod) {
> +		printf("%s:SKIP: bpf_testmod is not available\n", __func__);
> +		test__skip();
> +		return;
> +	}
> +
> +	vmlinux_btf = btf__load_vmlinux_btf();
> +	if (libbpf_get_error(vmlinux_btf)) {
> +		printf("%s:SKIP: vmlinux_btf is not available\n", __func__);
> +		test__skip();
> +		return;
> +	}
> +
> +	/* Ensure bpf_testmod BTF is available. */
> +	module_btf = btf__load_module_btf("bpf_testmod", vmlinux_btf);
> +	if (libbpf_get_error(module_btf)) {
> +		printf("%s:SKIP: bpf_testmod's BTF is not available\n", __func__);
> +		btf__free(vmlinux_btf);
> +		test__skip();
> +		return;
> +	}
> +
> +	btf__free(module_btf);
> +	btf__free(vmlinux_btf);
> +
> +	if (test__start_subtest("default"))
> +		btf_module_allowlist_default();
> +
> +	if (test__start_subtest("allowlist"))
> +		btf_module_allowlist_allow();
> +
> +	if (test__start_subtest("skip_unlisted"))
> +		btf_module_allowlist_skip();
> +
> +	if (test__start_subtest("emptylist"))
> +		btf_module_allowlist_empty();
> +
> +	if (test__start_subtest("invalid_input"))
> +		btf_module_allowlist_invalid();

could you add test that verifies the module's BTF did not get
load because of the allow list setup, something like:

  bpf_program__set_attach_target(prog, 0, "bpf_testmod:bpf_fentry_test1")

would fail, or some other way that uses obj->btf_modules

thanks,
jirka

  parent reply	other threads:[~2026-09-07  8:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-07  5:38 [PATCH bpf-next v7 0/2] libbpf: improve BPF load performance by selectively loading module BTFs Fuyu Zhao
2026-09-07  5:38 ` [PATCH bpf-next v7 1/2] libbpf: support selective kernel module BTF loading via bpf_object_open_opts Fuyu Zhao
2026-09-07  5:49   ` sashiko-bot
2026-09-09 14:08     ` Fuyu Zhao
2026-09-07  8:33   ` Jiri Olsa
2026-09-09 14:08     ` Fuyu Zhao
2026-09-07  5:38 ` [PATCH bpf-next v7 2/2] selftests/bpf: add tests for selective module BTF loading Fuyu Zhao
2026-09-07  5:51   ` sashiko-bot
2026-09-09 14:08     ` Fuyu Zhao
2026-09-07  8:34   ` Jiri Olsa [this message]
2026-09-09 14:13     ` Fuyu Zhao
2026-09-08 16:03   ` bot+bpf-ci
2026-09-09 14:13     ` Fuyu Zhao

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=ap53Ac6p_DVybHi0@krava \
    --to=olsajiri@gmail.com \
    --cc=alan.maguire@oracle.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=eddyz87@gmail.com \
    --cc=zhaofuyu@vivo.com \
    /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