From: Eduard Zingerman <eddyz87@gmail.com>
To: Donglin Peng <dolinux.peng@gmail.com>, ast@kernel.org
Cc: linux-kernel@vger.kernel.org, bpf@vger.kernel.org,
Andrii Nakryiko <andrii.nakryiko@gmail.com>,
Alan Maguire <alan.maguire@oracle.com>,
Song Liu <song@kernel.org>, pengdonglin <pengdonglin@xiaomi.com>
Subject: Re: [RFC PATCH v3 2/3] selftests/bpf: add tests for BTF type permutation
Date: Mon, 27 Oct 2025 11:53:07 -0700 [thread overview]
Message-ID: <c3f1b8ce39335ea0061a8b75a943f12638da6a9c.camel@gmail.com> (raw)
In-Reply-To: <20251027135423.3098490-3-dolinux.peng@gmail.com>
On Mon, 2025-10-27 at 21:54 +0800, Donglin Peng wrote:
> Verify that BTF type permutation functionality works correctly.
>
> Cc: Eduard Zingerman <eddyz87@gmail.com>
> Cc: Alexei Starovoitov <ast@kernel.org>
> Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
> Cc: Alan Maguire <alan.maguire@oracle.com>
> Cc: Song Liu <song@kernel.org>
> Signed-off-by: pengdonglin <pengdonglin@xiaomi.com>
> Signed-off-by: Donglin Peng <dolinux.peng@gmail.com>
> ---
Do we need a test case for split btf?
We probably do, as there is index arithmetic etc.
[...]
> @@ -8022,6 +8026,72 @@ static struct btf_dedup_test dedup_tests[] = {
> BTF_STR_SEC("\0foo\0x\0y\0foo_ptr"),
> },
> },
> +{
> + .descr = "permute: func/func_param/struct/struct_member tags",
> + .input = {
> + .raw_types = {
> + /* int */
> + BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [1] */
> + /* void f(int a1, int a2) */
> + BTF_FUNC_PROTO_ENC(0, 2), /* [2] */
> + BTF_FUNC_PROTO_ARG_ENC(NAME_NTH(1), 1),
> + BTF_FUNC_PROTO_ARG_ENC(NAME_NTH(2), 1),
> + BTF_FUNC_ENC(NAME_NTH(3), 2), /* [3] */
> + /* struct t {int m1; int m2;} */
> + BTF_STRUCT_ENC(NAME_NTH(4), 2, 8), /* [4] */
> + BTF_MEMBER_ENC(NAME_NTH(5), 1, 0),
> + BTF_MEMBER_ENC(NAME_NTH(6), 1, 32),
> + /* tag -> f: tag1, tag2, tag3 */
> + BTF_DECL_TAG_ENC(NAME_NTH(7), 3, -1), /* [5] */
> + BTF_DECL_TAG_ENC(NAME_NTH(8), 3, -1), /* [6] */
> + BTF_DECL_TAG_ENC(NAME_NTH(9), 3, -1), /* [7] */
> + /* tag -> f/a2: tag1, tag2, tag3 */
> + BTF_DECL_TAG_ENC(NAME_NTH(7), 3, 1), /* [8] */
> + BTF_DECL_TAG_ENC(NAME_NTH(8), 3, 1), /* [9] */
> + BTF_DECL_TAG_ENC(NAME_NTH(9), 3, 1), /* [10] */
> + /* tag -> t: tag1, tag2, tag3 */
> + BTF_DECL_TAG_ENC(NAME_NTH(7), 4, -1), /* [11] */
> + BTF_DECL_TAG_ENC(NAME_NTH(8), 4, -1), /* [12] */
> + BTF_DECL_TAG_ENC(NAME_NTH(9), 4, -1), /* [13] */
> + /* tag -> t/m2: tag1, tag3 */
> + BTF_DECL_TAG_ENC(NAME_NTH(7), 4, 1), /* [14] */
> + BTF_DECL_TAG_ENC(NAME_NTH(8), 4, 1), /* [15] */
> + BTF_DECL_TAG_ENC(NAME_NTH(9), 4, 1), /* [16] */
> + BTF_END_RAW,
> + },
> + BTF_STR_SEC("\0a1\0a2\0f\0t\0m1\0m2\0tag1\0tag2\0tag3"),
> + },
Nit: I think that this test is a bit too large.
Having fewer decl_tags would still test what we want to test.
> + .expect = {
> + .raw_types = {
> + BTF_FUNC_ENC(NAME_NTH(3), 16), /* [1] */
> + BTF_STRUCT_ENC(NAME_NTH(4), 2, 8), /* [2] */
> + BTF_MEMBER_ENC(NAME_NTH(5), 15, 0),
> + BTF_MEMBER_ENC(NAME_NTH(6), 15, 32),
> + BTF_DECL_TAG_ENC(NAME_NTH(7), 1, -1), /* [3] */
> + BTF_DECL_TAG_ENC(NAME_NTH(7), 1, 1), /* [4] */
> + BTF_DECL_TAG_ENC(NAME_NTH(7), 2, -1), /* [5] */
> + BTF_DECL_TAG_ENC(NAME_NTH(7), 2, 1), /* [6] */
> + BTF_DECL_TAG_ENC(NAME_NTH(8), 1, -1), /* [7] */
> + BTF_DECL_TAG_ENC(NAME_NTH(8), 1, 1), /* [8] */
> + BTF_DECL_TAG_ENC(NAME_NTH(8), 2, -1), /* [9] */
> + BTF_DECL_TAG_ENC(NAME_NTH(8), 2, 1), /* [10] */
> + BTF_DECL_TAG_ENC(NAME_NTH(9), 1, -1), /* [11] */
> + BTF_DECL_TAG_ENC(NAME_NTH(9), 1, 1), /* [12] */
> + BTF_DECL_TAG_ENC(NAME_NTH(9), 2, -1), /* [13] */
> + BTF_DECL_TAG_ENC(NAME_NTH(9), 2, 1), /* [14] */
> + BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), /* [15] */
> + BTF_FUNC_PROTO_ENC(0, 2), /* [16] */
> + BTF_FUNC_PROTO_ARG_ENC(NAME_NTH(1), 15),
> + BTF_FUNC_PROTO_ARG_ENC(NAME_NTH(2), 15),
> + BTF_END_RAW,
> + },
> + BTF_STR_SEC("\0a1\0a2\0f\0t\0m1\0m2\0tag1\0tag2\0tag3"),
> + },
> + .permute = true,
> + .permute_opts = {
> + .ids = permute_ids_sort_by_kind_name,
> + },
> +},
> };
[...]
next prev parent reply other threads:[~2025-10-27 18:53 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-27 13:54 [RFC PATCH v3 0/3] Significantly Improve BTF Type Lookup Performance Donglin Peng
2025-10-27 13:54 ` [RFC PATCH v3 1/3] btf: implement BTF type sorting for accelerated lookups Donglin Peng
2025-10-27 14:20 ` bot+bpf-ci
2025-10-27 18:40 ` Eduard Zingerman
2025-10-28 2:15 ` Donglin Peng
2025-10-27 19:06 ` Eduard Zingerman
2025-10-28 2:18 ` Donglin Peng
2025-10-28 18:15 ` Andrii Nakryiko
2025-10-28 18:38 ` Andrii Nakryiko
2025-10-29 5:04 ` Donglin Peng
2025-10-27 13:54 ` [RFC PATCH v3 2/3] selftests/bpf: add tests for BTF type permutation Donglin Peng
2025-10-27 18:53 ` Eduard Zingerman [this message]
2025-10-28 2:23 ` Donglin Peng
2025-10-27 13:54 ` [RFC PATCH v3 3/3] btf: Reuse libbpf code for BTF type sorting verification and binary search Donglin Peng
2025-10-27 19:55 ` Alexei Starovoitov
2025-10-29 1:57 ` Donglin Peng
2025-10-28 18:40 ` Andrii Nakryiko
2025-10-29 2:03 ` Donglin Peng
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=c3f1b8ce39335ea0061a8b75a943f12638da6a9c.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=alan.maguire@oracle.com \
--cc=andrii.nakryiko@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=dolinux.peng@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pengdonglin@xiaomi.com \
--cc=song@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).