Re: [PATCH bpf-next v3 5/6] selftests/bpf: Verify decl tags emission in resolve_btfids test

[email protected]
Newsgroups org.kernel.vger.bpf
Message-ID <b394c5635c62edc015cff3a4e75521d190684aca56257f8a55b822bac4f4b704@mail.kernel.org>
> diff --git a/tools/testing/selftests/bpf/prog_tests/resolve_btfids.c b/tools/testing/selftests/bpf/prog_tests/resolve_btfids.c
> index 8482f00046d4c..732cfed35e1c5 100644
> --- a/tools/testing/selftests/bpf/prog_tests/resolve_btfids.c
> +++ b/tools/testing/selftests/bpf/prog_tests/resolve_btfids.c

[ ... ]

> @@ -260,6 +284,22 @@ void test_resolve_btfids(void)
>  	check_kfunc_set(&test_kfunc_set);
>  	check_kfunc_set(&test_kfunc_set_rev);
>
> +	/* Check resolve_btfids emitted a bpf_kfunc decl_tag for each kfunc */
> +	for (i = 0; i < ARRAY_SIZE(kfunc_symbols); i++) {
> +		ASSERT_TRUE(btf_has_decl_tag(btf, DECL_TAG_KFUNC,
> +					     kfunc_symbols[i].id),
> +			    kfunc_symbols[i].name);
> +	}
> +
> +	/* Check resolve_btfids emitted bpf_fastcall for KF_FASTCALL kfuncs */
> +	for (i = 0; i < ARRAY_SIZE(kfunc_symbols); i++) {
> +		if (kfunc_symbols[i].flags & KF_FASTCALL) {
> +			ASSERT_TRUE(btf_has_decl_tag(btf, DECL_TAG_FASTCALL,
> +						     kfunc_symbols[i].id),
> +				    kfunc_symbols[i].name);
> +		}
> +	}

This isn't a bug, but could the bpf_fastcall check use an ASSERT_EQ form
instead of the conditional ASSERT_TRUE?

The arena block below this code uses:

	ASSERT_EQ(is_arena_tagged_ptr(btf, proto->type),
		  !!(fl & KF_ARENA_RET), name);

which checks both directions: flagged functions have the tag, and unflagged
functions don't. As written here, the second loop only verifies that
flagged kfuncs get bpf_fastcall; it doesn't check that kfunc_a, kfunc_c,
and kfunc_d (which lack KF_FASTCALL) are correctly left untagged.

Using the same form as the arena check would fold the two loops into one
and cover the negative case as well.


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/31144437704
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.