bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] selftests/bpf: add btf dedup test covering module BTF dedup
@ 2025-04-30 13:42 Alan Maguire
  2025-04-30 21:30 ` Eduard Zingerman
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Alan Maguire @ 2025-04-30 13:42 UTC (permalink / raw)
  To: ast, andrii
  Cc: daniel, martin.lau, eddyz87, song, yonghong.song, john.fastabend,
	kpsingh, sdf, haoluo, jolsa, mykolal, bpf, Alan Maguire

Recently issues were observed with module BTF deduplication failures
[1].  Add a dedup selftest that ensures that core kernel types are
referenced from split BTF as base BTF types.  To do this use bpf_testmod
functions which utilize core kernel types, specifically

ssize_t
bpf_testmod_test_write(struct file *file, struct kobject *kobj,
                       struct bin_attribute *bin_attr,
                       char *buf, loff_t off, size_t len);

__bpf_kfunc struct sock *bpf_kfunc_call_test3(struct sock *sk);

__bpf_kfunc void bpf_kfunc_call_test_pass_ctx(struct __sk_buff *skb);

For each of these ensure that the types they reference -
struct file, struct kobject, struct bin_attr etc - are in base BTF.
Note that because bpf_testmod.ko is built with distilled base BTF
the associated reference types - i.e. the PTR that points at a
"struct file" - will be in split BTF.  As a result the test resolves
typedef and pointer references and verifies the pointed-at or
typedef'ed type is in base BTF.  Because we use BTF from
/sys/kernel/btf/bpf_testmod relocation has occurred for the
referenced types and they will be base - not distilled base - types.

For large-scale dedup issues, we see such types appear in split BTF and
as a result this test fails.  Hence it is proposed as a test which will
fail when large-scale dedup issues have occurred.

[1] https://lore.kernel.org/dwarves/CAADnVQL+-LiJGXwxD3jEUrOonO-fX0SZC8496dVzUXvfkB7gYQ@mail.gmail.com/

Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
---
 .../bpf/prog_tests/btf_dedup_split.c          | 101 ++++++++++++++++++
 1 file changed, 101 insertions(+)

diff --git a/tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c b/tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c
index d9024c7a892a..5bc15bb6b7ce 100644
--- a/tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c
+++ b/tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c
@@ -440,6 +440,105 @@ static void test_split_dup_struct_in_cu()
 	btf__free(btf1);
 }
 
+/* Ensure module split BTF dedup worked correctly; when dedup fails badly
+ * core kernel types are in split BTF also, so ensure that references to
+ * such types point at base - not split - BTF.
+ *
+ * bpf_testmod_test_write() has multiple core kernel type parameters;
+ *
+ * ssize_t
+ * bpf_testmod_test_write(struct file *file, struct kobject *kobj,
+ *                        struct bin_attribute *bin_attr,
+ *                        char *buf, loff_t off, size_t len);
+ *
+ * Ensure each of the FUNC_PROTO params is a core kernel type.
+ *
+ * Do the same for
+ *
+ * __bpf_kfunc struct sock *bpf_kfunc_call_test3(struct sock *sk);
+ *
+ * ...and
+ *
+ * __bpf_kfunc void bpf_kfunc_call_test_pass_ctx(struct __sk_buff *skb);
+ *
+ */
+const char *mod_funcs[] = {
+	"bpf_testmod_test_write",
+	"bpf_kfunc_call_test3",
+	"bpf_kfunc_call_test_pass_ctx"
+};
+
+static void test_split_module(void)
+{
+	struct btf *vmlinux_btf, *btf1 = NULL;
+	int i, nr_base_types;
+
+	vmlinux_btf = btf__load_vmlinux_btf();
+	if (!ASSERT_OK_PTR(vmlinux_btf, "vmlinux_btf"))
+		return;
+	nr_base_types = btf__type_cnt(vmlinux_btf);
+	if (!ASSERT_GT(nr_base_types, 0, "nr_base_types"))
+		goto cleanup;
+
+	btf1 = btf__parse_split("/sys/kernel/btf/bpf_testmod", vmlinux_btf);
+	if (!ASSERT_OK_PTR(btf1, "split_btf"))
+		return;
+
+	for (i = 0; i < ARRAY_SIZE(mod_funcs); i++) {
+		const struct btf_param *p;
+		const struct btf_type *t;
+		__u16 vlen;
+		__u32 id;
+		int j;
+
+		id = btf__find_by_name_kind(btf1, mod_funcs[i], BTF_KIND_FUNC);
+		if (!ASSERT_GE(id, nr_base_types, "func_id"))
+			goto cleanup;
+		t = btf__type_by_id(btf1, id);
+		if (!ASSERT_OK_PTR(t, "func_id_type"))
+			goto cleanup;
+		t = btf__type_by_id(btf1, t->type);
+		if (!ASSERT_OK_PTR(t, "func_proto_id_type"))
+			goto cleanup;
+		if (!ASSERT_EQ(btf_is_func_proto(t), true, "is_func_proto"))
+			goto cleanup;
+		vlen = btf_vlen(t);
+
+		for (j = 0, p = btf_params(t); j < vlen; j++, p++) {
+			/* bpf_testmod uses resilient split BTF, so any
+			 * reference types will be added to split BTF and their
+			 * associated targets will be base BTF types; for example
+			 * for a "struct sock *" the PTR will be in split BTF
+			 * while the "struct sock" will be in base.
+			 *
+			 * In some cases like loff_t we have to resolve
+			 * multiple typedefs hence the while() loop below.
+			 *
+			 * Note that resilient split BTF generation depends
+			 * on pahole version, so we do not assert that
+			 * reference types are in split BTF, as if pahole
+			 * does not support resilient split BTF they will
+			 * also be base BTF types.
+			 */
+			id = p->type;
+			do {
+				t = btf__type_by_id(btf1, id);
+				if (!ASSERT_OK_PTR(t, "param_ref_type"))
+					goto cleanup;
+				if (!btf_is_mod(t) && !btf_is_ptr(t) && !btf_is_typedef(t))
+					break;
+				id = t->type;
+			} while (true);
+
+			if (!ASSERT_LT(id, nr_base_types, "verify_base_type"))
+				goto cleanup;
+		}
+	}
+cleanup:
+	btf__free(btf1);
+	btf__free(vmlinux_btf);
+}
+
 void test_btf_dedup_split()
 {
 	if (test__start_subtest("split_simple"))
@@ -450,4 +549,6 @@ void test_btf_dedup_split()
 		test_split_fwd_resolve();
 	if (test__start_subtest("split_dup_struct_in_cu"))
 		test_split_dup_struct_in_cu();
+	if (test__start_subtest("split_module"))
+		test_split_module();
 }
-- 
2.39.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next] selftests/bpf: add btf dedup test covering module BTF dedup
  2025-04-30 13:42 [PATCH bpf-next] selftests/bpf: add btf dedup test covering module BTF dedup Alan Maguire
@ 2025-04-30 21:30 ` Eduard Zingerman
  2025-05-01 21:10 ` patchwork-bot+netdevbpf
  2025-06-20 13:34 ` Jiri Olsa
  2 siblings, 0 replies; 7+ messages in thread
From: Eduard Zingerman @ 2025-04-30 21:30 UTC (permalink / raw)
  To: Alan Maguire
  Cc: ast, andrii, daniel, martin.lau, song, yonghong.song,
	john.fastabend, kpsingh, sdf, haoluo, jolsa, mykolal, bpf

Alan Maguire <alan.maguire@oracle.com> writes:

> Recently issues were observed with module BTF deduplication failures
> [1].  Add a dedup selftest that ensures that core kernel types are
> referenced from split BTF as base BTF types.  To do this use bpf_testmod
> functions which utilize core kernel types, specifically
>
> ssize_t
> bpf_testmod_test_write(struct file *file, struct kobject *kobj,
>                        struct bin_attribute *bin_attr,
>                        char *buf, loff_t off, size_t len);
>
> __bpf_kfunc struct sock *bpf_kfunc_call_test3(struct sock *sk);
>
> __bpf_kfunc void bpf_kfunc_call_test_pass_ctx(struct __sk_buff *skb);
>
> For each of these ensure that the types they reference -
> struct file, struct kobject, struct bin_attr etc - are in base BTF.
> Note that because bpf_testmod.ko is built with distilled base BTF
> the associated reference types - i.e. the PTR that points at a
> "struct file" - will be in split BTF.  As a result the test resolves
> typedef and pointer references and verifies the pointed-at or
> typedef'ed type is in base BTF.  Because we use BTF from
> /sys/kernel/btf/bpf_testmod relocation has occurred for the
> referenced types and they will be base - not distilled base - types.
>
> For large-scale dedup issues, we see such types appear in split BTF and
> as a result this test fails.  Hence it is proposed as a test which will
> fail when large-scale dedup issues have occurred.
>
> [1] https://lore.kernel.org/dwarves/CAADnVQL+-LiJGXwxD3jEUrOonO-fX0SZC8496dVzUXvfkB7gYQ@mail.gmail.com/
>
> Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
> ---

The test passes for LLVM and fails for gcc 14, when using pahole w/o
fixes discussed in [1].

Acked-by: Eduard Zingerman <eddyz87@gmail.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next] selftests/bpf: add btf dedup test covering module BTF dedup
  2025-04-30 13:42 [PATCH bpf-next] selftests/bpf: add btf dedup test covering module BTF dedup Alan Maguire
  2025-04-30 21:30 ` Eduard Zingerman
@ 2025-05-01 21:10 ` patchwork-bot+netdevbpf
  2025-06-20 13:34 ` Jiri Olsa
  2 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-05-01 21:10 UTC (permalink / raw)
  To: Alan Maguire
  Cc: ast, andrii, daniel, martin.lau, eddyz87, song, yonghong.song,
	john.fastabend, kpsingh, sdf, haoluo, jolsa, mykolal, bpf

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Wed, 30 Apr 2025 14:42:49 +0100 you wrote:
> Recently issues were observed with module BTF deduplication failures
> [1].  Add a dedup selftest that ensures that core kernel types are
> referenced from split BTF as base BTF types.  To do this use bpf_testmod
> functions which utilize core kernel types, specifically
> 
> ssize_t
> bpf_testmod_test_write(struct file *file, struct kobject *kobj,
>                        struct bin_attribute *bin_attr,
>                        char *buf, loff_t off, size_t len);
> 
> [...]

Here is the summary with links:
  - [bpf-next] selftests/bpf: add btf dedup test covering module BTF dedup
    https://git.kernel.org/bpf/bpf-next/c/f263336a41da

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next] selftests/bpf: add btf dedup test covering module BTF dedup
  2025-04-30 13:42 [PATCH bpf-next] selftests/bpf: add btf dedup test covering module BTF dedup Alan Maguire
  2025-04-30 21:30 ` Eduard Zingerman
  2025-05-01 21:10 ` patchwork-bot+netdevbpf
@ 2025-06-20 13:34 ` Jiri Olsa
  2025-06-20 13:51   ` Jiri Olsa
  2 siblings, 1 reply; 7+ messages in thread
From: Jiri Olsa @ 2025-06-20 13:34 UTC (permalink / raw)
  To: Alan Maguire
  Cc: ast, andrii, daniel, martin.lau, eddyz87, song, yonghong.song,
	john.fastabend, kpsingh, sdf, haoluo, mykolal, bpf

On Wed, Apr 30, 2025 at 02:42:49PM +0100, Alan Maguire wrote:
> Recently issues were observed with module BTF deduplication failures
> [1].  Add a dedup selftest that ensures that core kernel types are
> referenced from split BTF as base BTF types.  To do this use bpf_testmod
> functions which utilize core kernel types, specifically
> 
> ssize_t
> bpf_testmod_test_write(struct file *file, struct kobject *kobj,
>                        struct bin_attribute *bin_attr,
>                        char *buf, loff_t off, size_t len);
> 
> __bpf_kfunc struct sock *bpf_kfunc_call_test3(struct sock *sk);
> 
> __bpf_kfunc void bpf_kfunc_call_test_pass_ctx(struct __sk_buff *skb);
> 
> For each of these ensure that the types they reference -
> struct file, struct kobject, struct bin_attr etc - are in base BTF.
> Note that because bpf_testmod.ko is built with distilled base BTF
> the associated reference types - i.e. the PTR that points at a
> "struct file" - will be in split BTF.  As a result the test resolves
> typedef and pointer references and verifies the pointed-at or
> typedef'ed type is in base BTF.  Because we use BTF from
> /sys/kernel/btf/bpf_testmod relocation has occurred for the
> referenced types and they will be base - not distilled base - types.
> 
> For large-scale dedup issues, we see such types appear in split BTF and
> as a result this test fails.  Hence it is proposed as a test which will
> fail when large-scale dedup issues have occurred.
> 
> [1] https://lore.kernel.org/dwarves/CAADnVQL+-LiJGXwxD3jEUrOonO-fX0SZC8496dVzUXvfkB7gYQ@mail.gmail.com/
> 
> Signed-off-by: Alan Maguire <alan.maguire@oracle.com>

hi Alan,
this one started to fail in my tests.. it's likely some screw up in
my environment, but I haven't found the cause yet, I'm using the
pahole 1.30 .. just cheking if it's known issue already ;-)

thanks,
jirka


test_split_module:PASS:vmlinux_btf 0 nsec
test_split_module:PASS:nr_base_types 0 nsec
test_split_module:PASS:split_btf 0 nsec
test_split_module:PASS:func_id 0 nsec
test_split_module:PASS:func_id_type 0 nsec
test_split_module:PASS:func_proto_id_type 0 nsec
test_split_module:PASS:is_func_proto 0 nsec
test_split_module:PASS:param_ref_type 0 nsec
test_split_module:PASS:param_ref_type 0 nsec
test_split_module:FAIL:verify_base_type unexpected verify_base_type: actual 183322 >= expected 183225
#33/5    btf_dedup_split/split_module:FAIL
#33      btf_dedup_split:FAIL


> ---
>  .../bpf/prog_tests/btf_dedup_split.c          | 101 ++++++++++++++++++
>  1 file changed, 101 insertions(+)
> 
> diff --git a/tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c b/tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c
> index d9024c7a892a..5bc15bb6b7ce 100644
> --- a/tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c
> +++ b/tools/testing/selftests/bpf/prog_tests/btf_dedup_split.c
> @@ -440,6 +440,105 @@ static void test_split_dup_struct_in_cu()
>  	btf__free(btf1);
>  }
>  
> +/* Ensure module split BTF dedup worked correctly; when dedup fails badly
> + * core kernel types are in split BTF also, so ensure that references to
> + * such types point at base - not split - BTF.
> + *
> + * bpf_testmod_test_write() has multiple core kernel type parameters;
> + *
> + * ssize_t
> + * bpf_testmod_test_write(struct file *file, struct kobject *kobj,
> + *                        struct bin_attribute *bin_attr,
> + *                        char *buf, loff_t off, size_t len);
> + *
> + * Ensure each of the FUNC_PROTO params is a core kernel type.
> + *
> + * Do the same for
> + *
> + * __bpf_kfunc struct sock *bpf_kfunc_call_test3(struct sock *sk);
> + *
> + * ...and
> + *
> + * __bpf_kfunc void bpf_kfunc_call_test_pass_ctx(struct __sk_buff *skb);
> + *
> + */
> +const char *mod_funcs[] = {
> +	"bpf_testmod_test_write",
> +	"bpf_kfunc_call_test3",
> +	"bpf_kfunc_call_test_pass_ctx"
> +};
> +
> +static void test_split_module(void)
> +{
> +	struct btf *vmlinux_btf, *btf1 = NULL;
> +	int i, nr_base_types;
> +
> +	vmlinux_btf = btf__load_vmlinux_btf();
> +	if (!ASSERT_OK_PTR(vmlinux_btf, "vmlinux_btf"))
> +		return;
> +	nr_base_types = btf__type_cnt(vmlinux_btf);
> +	if (!ASSERT_GT(nr_base_types, 0, "nr_base_types"))
> +		goto cleanup;
> +
> +	btf1 = btf__parse_split("/sys/kernel/btf/bpf_testmod", vmlinux_btf);
> +	if (!ASSERT_OK_PTR(btf1, "split_btf"))
> +		return;
> +
> +	for (i = 0; i < ARRAY_SIZE(mod_funcs); i++) {
> +		const struct btf_param *p;
> +		const struct btf_type *t;
> +		__u16 vlen;
> +		__u32 id;
> +		int j;
> +
> +		id = btf__find_by_name_kind(btf1, mod_funcs[i], BTF_KIND_FUNC);
> +		if (!ASSERT_GE(id, nr_base_types, "func_id"))
> +			goto cleanup;
> +		t = btf__type_by_id(btf1, id);
> +		if (!ASSERT_OK_PTR(t, "func_id_type"))
> +			goto cleanup;
> +		t = btf__type_by_id(btf1, t->type);
> +		if (!ASSERT_OK_PTR(t, "func_proto_id_type"))
> +			goto cleanup;
> +		if (!ASSERT_EQ(btf_is_func_proto(t), true, "is_func_proto"))
> +			goto cleanup;
> +		vlen = btf_vlen(t);
> +
> +		for (j = 0, p = btf_params(t); j < vlen; j++, p++) {
> +			/* bpf_testmod uses resilient split BTF, so any
> +			 * reference types will be added to split BTF and their
> +			 * associated targets will be base BTF types; for example
> +			 * for a "struct sock *" the PTR will be in split BTF
> +			 * while the "struct sock" will be in base.
> +			 *
> +			 * In some cases like loff_t we have to resolve
> +			 * multiple typedefs hence the while() loop below.
> +			 *
> +			 * Note that resilient split BTF generation depends
> +			 * on pahole version, so we do not assert that
> +			 * reference types are in split BTF, as if pahole
> +			 * does not support resilient split BTF they will
> +			 * also be base BTF types.
> +			 */
> +			id = p->type;
> +			do {
> +				t = btf__type_by_id(btf1, id);
> +				if (!ASSERT_OK_PTR(t, "param_ref_type"))
> +					goto cleanup;
> +				if (!btf_is_mod(t) && !btf_is_ptr(t) && !btf_is_typedef(t))
> +					break;
> +				id = t->type;
> +			} while (true);
> +
> +			if (!ASSERT_LT(id, nr_base_types, "verify_base_type"))
> +				goto cleanup;
> +		}
> +	}
> +cleanup:
> +	btf__free(btf1);
> +	btf__free(vmlinux_btf);
> +}
> +
>  void test_btf_dedup_split()
>  {
>  	if (test__start_subtest("split_simple"))
> @@ -450,4 +549,6 @@ void test_btf_dedup_split()
>  		test_split_fwd_resolve();
>  	if (test__start_subtest("split_dup_struct_in_cu"))
>  		test_split_dup_struct_in_cu();
> +	if (test__start_subtest("split_module"))
> +		test_split_module();
>  }
> -- 
> 2.39.3
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next] selftests/bpf: add btf dedup test covering module BTF dedup
  2025-06-20 13:34 ` Jiri Olsa
@ 2025-06-20 13:51   ` Jiri Olsa
  2025-06-20 15:41     ` Alan Maguire
  0 siblings, 1 reply; 7+ messages in thread
From: Jiri Olsa @ 2025-06-20 13:51 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Alan Maguire, ast, andrii, daniel, martin.lau, eddyz87, song,
	yonghong.song, john.fastabend, kpsingh, sdf, haoluo, mykolal, bpf

On Fri, Jun 20, 2025 at 03:34:14PM +0200, Jiri Olsa wrote:
> On Wed, Apr 30, 2025 at 02:42:49PM +0100, Alan Maguire wrote:
> > Recently issues were observed with module BTF deduplication failures
> > [1].  Add a dedup selftest that ensures that core kernel types are
> > referenced from split BTF as base BTF types.  To do this use bpf_testmod
> > functions which utilize core kernel types, specifically
> > 
> > ssize_t
> > bpf_testmod_test_write(struct file *file, struct kobject *kobj,
> >                        struct bin_attribute *bin_attr,
> >                        char *buf, loff_t off, size_t len);
> > 
> > __bpf_kfunc struct sock *bpf_kfunc_call_test3(struct sock *sk);
> > 
> > __bpf_kfunc void bpf_kfunc_call_test_pass_ctx(struct __sk_buff *skb);
> > 
> > For each of these ensure that the types they reference -
> > struct file, struct kobject, struct bin_attr etc - are in base BTF.
> > Note that because bpf_testmod.ko is built with distilled base BTF
> > the associated reference types - i.e. the PTR that points at a
> > "struct file" - will be in split BTF.  As a result the test resolves
> > typedef and pointer references and verifies the pointed-at or
> > typedef'ed type is in base BTF.  Because we use BTF from
> > /sys/kernel/btf/bpf_testmod relocation has occurred for the
> > referenced types and they will be base - not distilled base - types.
> > 
> > For large-scale dedup issues, we see such types appear in split BTF and
> > as a result this test fails.  Hence it is proposed as a test which will
> > fail when large-scale dedup issues have occurred.
> > 
> > [1] https://lore.kernel.org/dwarves/CAADnVQL+-LiJGXwxD3jEUrOonO-fX0SZC8496dVzUXvfkB7gYQ@mail.gmail.com/
> > 
> > Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
> 
> hi Alan,
> this one started to fail in my tests.. it's likely some screw up in
> my environment, but I haven't found the cause yet, I'm using the
> pahole 1.30 .. just cheking if it's known issue already ;-)

hum, it might be my gcc-14 .. will upgrade

jirka

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next] selftests/bpf: add btf dedup test covering module BTF dedup
  2025-06-20 13:51   ` Jiri Olsa
@ 2025-06-20 15:41     ` Alan Maguire
  2025-06-24 11:48       ` Jiri Olsa
  0 siblings, 1 reply; 7+ messages in thread
From: Alan Maguire @ 2025-06-20 15:41 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: ast, andrii, daniel, martin.lau, eddyz87, song, yonghong.song,
	john.fastabend, kpsingh, sdf, haoluo, mykolal, bpf

On 20/06/2025 14:51, Jiri Olsa wrote:
> On Fri, Jun 20, 2025 at 03:34:14PM +0200, Jiri Olsa wrote:
>> On Wed, Apr 30, 2025 at 02:42:49PM +0100, Alan Maguire wrote:
>>> Recently issues were observed with module BTF deduplication failures
>>> [1].  Add a dedup selftest that ensures that core kernel types are
>>> referenced from split BTF as base BTF types.  To do this use bpf_testmod
>>> functions which utilize core kernel types, specifically
>>>
>>> ssize_t
>>> bpf_testmod_test_write(struct file *file, struct kobject *kobj,
>>>                        struct bin_attribute *bin_attr,
>>>                        char *buf, loff_t off, size_t len);
>>>
>>> __bpf_kfunc struct sock *bpf_kfunc_call_test3(struct sock *sk);
>>>
>>> __bpf_kfunc void bpf_kfunc_call_test_pass_ctx(struct __sk_buff *skb);
>>>
>>> For each of these ensure that the types they reference -
>>> struct file, struct kobject, struct bin_attr etc - are in base BTF.
>>> Note that because bpf_testmod.ko is built with distilled base BTF
>>> the associated reference types - i.e. the PTR that points at a
>>> "struct file" - will be in split BTF.  As a result the test resolves
>>> typedef and pointer references and verifies the pointed-at or
>>> typedef'ed type is in base BTF.  Because we use BTF from
>>> /sys/kernel/btf/bpf_testmod relocation has occurred for the
>>> referenced types and they will be base - not distilled base - types.
>>>
>>> For large-scale dedup issues, we see such types appear in split BTF and
>>> as a result this test fails.  Hence it is proposed as a test which will
>>> fail when large-scale dedup issues have occurred.
>>>
>>> [1] https://lore.kernel.org/dwarves/CAADnVQL+-LiJGXwxD3jEUrOonO-fX0SZC8496dVzUXvfkB7gYQ@mail.gmail.com/
>>>
>>> Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
>>
>> hi Alan,
>> this one started to fail in my tests.. it's likely some screw up in
>> my environment, but I haven't found the cause yet, I'm using the
>> pahole 1.30 .. just cheking if it's known issue already ;-)
> 
> hum, it might be my gcc-14 .. will upgrade
>

hi Jiri, is it possible you were using the pre-dedup-fix pahole, i.e.
the official 1.30, or a version without

commit 6362d1f1657e3381e3e622d70364145f72804504
Author: Alan Maguire <alan.maguire@oracle.com>
Date:   Tue Apr 29 20:49:05 2025 +0100

    pahole: Sync with libbpf mainline

    To pull in dedup fix in

    commit 8e64c387c942 ("libbpf: Add identical pointer detection to
btf_dedup_is_equiv()")

    sync with latest libbpf.

? That would mean you would hit the module dedup failure and the test
would fail as a result. If that's the case, if you could try syncing to
the "next" branch of pahole and see if it recurs, that would be great!
Thanks!

Alan

> jirka


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next] selftests/bpf: add btf dedup test covering module BTF dedup
  2025-06-20 15:41     ` Alan Maguire
@ 2025-06-24 11:48       ` Jiri Olsa
  0 siblings, 0 replies; 7+ messages in thread
From: Jiri Olsa @ 2025-06-24 11:48 UTC (permalink / raw)
  To: Alan Maguire
  Cc: Jiri Olsa, ast, andrii, daniel, martin.lau, eddyz87, song,
	yonghong.song, john.fastabend, kpsingh, sdf, haoluo, mykolal, bpf

On Fri, Jun 20, 2025 at 04:41:48PM +0100, Alan Maguire wrote:
> On 20/06/2025 14:51, Jiri Olsa wrote:
> > On Fri, Jun 20, 2025 at 03:34:14PM +0200, Jiri Olsa wrote:
> >> On Wed, Apr 30, 2025 at 02:42:49PM +0100, Alan Maguire wrote:
> >>> Recently issues were observed with module BTF deduplication failures
> >>> [1].  Add a dedup selftest that ensures that core kernel types are
> >>> referenced from split BTF as base BTF types.  To do this use bpf_testmod
> >>> functions which utilize core kernel types, specifically
> >>>
> >>> ssize_t
> >>> bpf_testmod_test_write(struct file *file, struct kobject *kobj,
> >>>                        struct bin_attribute *bin_attr,
> >>>                        char *buf, loff_t off, size_t len);
> >>>
> >>> __bpf_kfunc struct sock *bpf_kfunc_call_test3(struct sock *sk);
> >>>
> >>> __bpf_kfunc void bpf_kfunc_call_test_pass_ctx(struct __sk_buff *skb);
> >>>
> >>> For each of these ensure that the types they reference -
> >>> struct file, struct kobject, struct bin_attr etc - are in base BTF.
> >>> Note that because bpf_testmod.ko is built with distilled base BTF
> >>> the associated reference types - i.e. the PTR that points at a
> >>> "struct file" - will be in split BTF.  As a result the test resolves
> >>> typedef and pointer references and verifies the pointed-at or
> >>> typedef'ed type is in base BTF.  Because we use BTF from
> >>> /sys/kernel/btf/bpf_testmod relocation has occurred for the
> >>> referenced types and they will be base - not distilled base - types.
> >>>
> >>> For large-scale dedup issues, we see such types appear in split BTF and
> >>> as a result this test fails.  Hence it is proposed as a test which will
> >>> fail when large-scale dedup issues have occurred.
> >>>
> >>> [1] https://lore.kernel.org/dwarves/CAADnVQL+-LiJGXwxD3jEUrOonO-fX0SZC8496dVzUXvfkB7gYQ@mail.gmail.com/
> >>>
> >>> Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
> >>
> >> hi Alan,
> >> this one started to fail in my tests.. it's likely some screw up in
> >> my environment, but I haven't found the cause yet, I'm using the
> >> pahole 1.30 .. just cheking if it's known issue already ;-)
> > 
> > hum, it might be my gcc-14 .. will upgrade
> >
> 
> hi Jiri, is it possible you were using the pre-dedup-fix pahole, i.e.
> the official 1.30, or a version without
> 
> commit 6362d1f1657e3381e3e622d70364145f72804504
> Author: Alan Maguire <alan.maguire@oracle.com>
> Date:   Tue Apr 29 20:49:05 2025 +0100
> 
>     pahole: Sync with libbpf mainline
> 
>     To pull in dedup fix in
> 
>     commit 8e64c387c942 ("libbpf: Add identical pointer detection to
> btf_dedup_is_equiv()")
> 
>     sync with latest libbpf.
> 
> ? That would mean you would hit the module dedup failure and the test
> would fail as a result. If that's the case, if you could try syncing to
> the "next" branch of pahole and see if it recurs, that would be great!
> Thanks!

yep, that helped, thank you

jirka

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-06-24 11:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-30 13:42 [PATCH bpf-next] selftests/bpf: add btf dedup test covering module BTF dedup Alan Maguire
2025-04-30 21:30 ` Eduard Zingerman
2025-05-01 21:10 ` patchwork-bot+netdevbpf
2025-06-20 13:34 ` Jiri Olsa
2025-06-20 13:51   ` Jiri Olsa
2025-06-20 15:41     ` Alan Maguire
2025-06-24 11:48       ` Jiri Olsa

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).