Netdev Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH bpf-next 0/2] Allow attaching to bare tracepoints
@ 2021-01-11 18:20 Qais Yousef
  2021-01-11 18:20 ` [PATCH bpf-next 1/2] trace: bpf: Allow bpf to attach " Qais Yousef
  2021-01-11 18:20 ` [PATCH bpf-next 2/2] selftests: bpf: Add a new test for " Qais Yousef
  0 siblings, 2 replies; 14+ messages in thread
From: Qais Yousef @ 2021-01-11 18:20 UTC (permalink / raw)
  To: netdev, bpf
  Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	Steven Rostedt, Peter Zijlstra (Intel),
	linux-kernel, Qais Yousef

Add some missing glue logic to teach bpf about bare tracepoints - tracepoints
without any trace event associated with them.

Bare tracepoints are declare with DECLARE_TRACE(). Full tracepoints are declare
with TRACE_EVENT().

BPF can attach to these tracepoints as RAW_TRACEPOINT() only as there's no
events in tracefs created with them.

Qais Yousef (2):
  trace: bpf: Allow bpf to attach to bare tracepoints
  selftests: bpf: Add a new test for bare tracepoints

 Documentation/bpf/bpf_design_QA.rst                  |  6 ++++++
 include/trace/bpf_probe.h                            | 12 ++++++++++--
 .../selftests/bpf/bpf_testmod/bpf_testmod-events.h   |  6 ++++++
 .../testing/selftests/bpf/bpf_testmod/bpf_testmod.c  |  2 ++
 .../testing/selftests/bpf/prog_tests/module_attach.c |  1 +
 .../testing/selftests/bpf/progs/test_module_attach.c | 10 ++++++++++
 6 files changed, 35 insertions(+), 2 deletions(-)

-- 
2.25.1


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

* [PATCH bpf-next 1/2] trace: bpf: Allow bpf to attach to bare tracepoints
  2021-01-11 18:20 [PATCH bpf-next 0/2] Allow attaching to bare tracepoints Qais Yousef
@ 2021-01-11 18:20 ` Qais Yousef
  2021-01-12 20:19   ` Yonghong Song
                     ` (2 more replies)
  2021-01-11 18:20 ` [PATCH bpf-next 2/2] selftests: bpf: Add a new test for " Qais Yousef
  1 sibling, 3 replies; 14+ messages in thread
From: Qais Yousef @ 2021-01-11 18:20 UTC (permalink / raw)
  To: netdev, bpf
  Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	Steven Rostedt, Peter Zijlstra (Intel),
	linux-kernel, Qais Yousef

Some subsystems only have bare tracepoints (a tracepoint with no
associated trace event) to avoid the problem of trace events being an
ABI that can't be changed.

From bpf presepective, bare tracepoints are what it calls
RAW_TRACEPOINT().

Since bpf assumed there's 1:1 mapping, it relied on hooking to
DEFINE_EVENT() macro to create bpf mapping of the tracepoints. Since
bare tracepoints use DECLARE_TRACE() to create the tracepoint, bpf had
no knowledge about their existence.

By teaching bpf_probe.h to parse DECLARE_TRACE() in a similar fashion to
DEFINE_EVENT(), bpf can find and attach to the new raw tracepoints.

Enabling that comes with the contract that changes to raw tracepoints
don't constitute a regression if they break existing bpf programs.
We need the ability to continue to morph and modify these raw
tracepoints without worrying about any ABI.

Update Documentation/bpf/bpf_design_QA.rst to document this contract.

Signed-off-by: Qais Yousef <qais.yousef@arm.com>
---
 Documentation/bpf/bpf_design_QA.rst |  6 ++++++
 include/trace/bpf_probe.h           | 12 ++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/Documentation/bpf/bpf_design_QA.rst b/Documentation/bpf/bpf_design_QA.rst
index 2df7b067ab93..0e15f9b05c9d 100644
--- a/Documentation/bpf/bpf_design_QA.rst
+++ b/Documentation/bpf/bpf_design_QA.rst
@@ -208,6 +208,12 @@ data structures and compile with kernel internal headers. Both of these
 kernel internals are subject to change and can break with newer kernels
 such that the program needs to be adapted accordingly.
 
+Q: Are tracepoints part of the stable ABI?
+------------------------------------------
+A: NO. Tracepoints are tied to internal implementation details hence they are
+subject to change and can break with newer kernels. BPF programs need to change
+accordingly when this happens.
+
 Q: How much stack space a BPF program uses?
 -------------------------------------------
 A: Currently all program types are limited to 512 bytes of stack
diff --git a/include/trace/bpf_probe.h b/include/trace/bpf_probe.h
index cd74bffed5c6..cf1496b162b1 100644
--- a/include/trace/bpf_probe.h
+++ b/include/trace/bpf_probe.h
@@ -55,8 +55,7 @@
 /* tracepoints with more than 12 arguments will hit build error */
 #define CAST_TO_U64(...) CONCATENATE(__CAST, COUNT_ARGS(__VA_ARGS__))(__VA_ARGS__)
 
-#undef DECLARE_EVENT_CLASS
-#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)	\
+#define __BPF_DECLARE_TRACE(call, proto, args)				\
 static notrace void							\
 __bpf_trace_##call(void *__data, proto)					\
 {									\
@@ -64,6 +63,10 @@ __bpf_trace_##call(void *__data, proto)					\
 	CONCATENATE(bpf_trace_run, COUNT_ARGS(args))(prog, CAST_TO_U64(args));	\
 }
 
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)	\
+	__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))
+
 /*
  * This part is compiled out, it is only here as a build time check
  * to make sure that if the tracepoint handling changes, the
@@ -111,6 +114,11 @@ __DEFINE_EVENT(template, call, PARAMS(proto), PARAMS(args), size)
 #define DEFINE_EVENT_PRINT(template, name, proto, args, print)	\
 	DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
 
+#undef DECLARE_TRACE
+#define DECLARE_TRACE(call, proto, args)				\
+	(__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))		\
+	 __DEFINE_EVENT(call, call, PARAMS(proto), PARAMS(args), 0))
+
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
 
 #undef DEFINE_EVENT_WRITABLE
-- 
2.25.1


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

* [PATCH bpf-next 2/2] selftests: bpf: Add a new test for bare tracepoints
  2021-01-11 18:20 [PATCH bpf-next 0/2] Allow attaching to bare tracepoints Qais Yousef
  2021-01-11 18:20 ` [PATCH bpf-next 1/2] trace: bpf: Allow bpf to attach " Qais Yousef
@ 2021-01-11 18:20 ` Qais Yousef
  2021-01-12  7:26   ` Andrii Nakryiko
  1 sibling, 1 reply; 14+ messages in thread
From: Qais Yousef @ 2021-01-11 18:20 UTC (permalink / raw)
  To: netdev, bpf
  Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	Steven Rostedt, Peter Zijlstra (Intel),
	linux-kernel, Qais Yousef

Reuse module_attach infrastructure to add a new bare tracepoint to check
we can attach to it as a raw tracepoint.

Signed-off-by: Qais Yousef <qais.yousef@arm.com>
---

Andrii

I was getting the error below when I was trying to run the test.
I had to comment out all related fentry* code to be able to test the raw_tp
stuff. Not sure something I've done wrong or it's broken for some reason.
I was on v5.11-rc2.

	$ sudo ./test_progs -v -t module_attach
	bpf_testmod.ko is already unloaded.
	Loading bpf_testmod.ko...
	Successfully loaded bpf_testmod.ko.
	test_module_attach:PASS:skel_open 0 nsec
	test_module_attach:PASS:set_attach_target 0 nsec
	test_module_attach:PASS:skel_load 0 nsec
	libbpf: prog 'handle_fentry': failed to attach: ERROR: strerror_r(-524)=22
	libbpf: failed to auto-attach program 'handle_fentry': -524
	test_module_attach:FAIL:skel_attach skeleton attach failed: -524
	#58 module_attach:FAIL
	Successfully unloaded bpf_testmod.ko.
	Summary: 0/0 PASSED, 0 SKIPPED, 1 FAILED


 .../selftests/bpf/bpf_testmod/bpf_testmod-events.h     |  6 ++++++
 tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c  |  2 ++
 tools/testing/selftests/bpf/prog_tests/module_attach.c |  1 +
 tools/testing/selftests/bpf/progs/test_module_attach.c | 10 ++++++++++
 4 files changed, 19 insertions(+)

diff --git a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod-events.h b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod-events.h
index b83ea448bc79..e1ada753f10c 100644
--- a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod-events.h
+++ b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod-events.h
@@ -28,6 +28,12 @@ TRACE_EVENT(bpf_testmod_test_read,
 		  __entry->pid, __entry->comm, __entry->off, __entry->len)
 );
 
+/* A bare tracepoint with no event associated with it */
+DECLARE_TRACE(bpf_testmod_test_read_bare,
+	TP_PROTO(struct task_struct *task, struct bpf_testmod_test_read_ctx *ctx),
+	TP_ARGS(task, ctx)
+);
+
 #endif /* _BPF_TESTMOD_EVENTS_H */
 
 #undef TRACE_INCLUDE_PATH
diff --git a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
index 2df19d73ca49..d63cebdaca44 100644
--- a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
+++ b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
@@ -22,6 +22,8 @@ bpf_testmod_test_read(struct file *file, struct kobject *kobj,
 	};
 
 	trace_bpf_testmod_test_read(current, &ctx);
+	ctx.len++;
+	trace_bpf_testmod_test_read_bare(current, &ctx);
 
 	return -EIO; /* always fail */
 }
diff --git a/tools/testing/selftests/bpf/prog_tests/module_attach.c b/tools/testing/selftests/bpf/prog_tests/module_attach.c
index 50796b651f72..7085a118f38c 100644
--- a/tools/testing/selftests/bpf/prog_tests/module_attach.c
+++ b/tools/testing/selftests/bpf/prog_tests/module_attach.c
@@ -50,6 +50,7 @@ void test_module_attach(void)
 	ASSERT_OK(trigger_module_test_read(READ_SZ), "trigger_read");
 
 	ASSERT_EQ(bss->raw_tp_read_sz, READ_SZ, "raw_tp");
+	ASSERT_EQ(bss->raw_tp_bare_read_sz, READ_SZ+1, "raw_tp_bare");
 	ASSERT_EQ(bss->tp_btf_read_sz, READ_SZ, "tp_btf");
 	ASSERT_EQ(bss->fentry_read_sz, READ_SZ, "fentry");
 	ASSERT_EQ(bss->fentry_manual_read_sz, READ_SZ, "fentry_manual");
diff --git a/tools/testing/selftests/bpf/progs/test_module_attach.c b/tools/testing/selftests/bpf/progs/test_module_attach.c
index efd1e287ac17..08aa157afa1d 100644
--- a/tools/testing/selftests/bpf/progs/test_module_attach.c
+++ b/tools/testing/selftests/bpf/progs/test_module_attach.c
@@ -17,6 +17,16 @@ int BPF_PROG(handle_raw_tp,
 	return 0;
 }
 
+__u32 raw_tp_bare_read_sz = 0;
+
+SEC("raw_tp/bpf_testmod_test_read_bare")
+int BPF_PROG(handle_raw_tp_bare,
+	     struct task_struct *task, struct bpf_testmod_test_read_ctx *read_ctx)
+{
+	raw_tp_bare_read_sz = BPF_CORE_READ(read_ctx, len);
+	return 0;
+}
+
 __u32 tp_btf_read_sz = 0;
 
 SEC("tp_btf/bpf_testmod_test_read")
-- 
2.25.1


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

* Re: [PATCH bpf-next 2/2] selftests: bpf: Add a new test for bare tracepoints
  2021-01-11 18:20 ` [PATCH bpf-next 2/2] selftests: bpf: Add a new test for " Qais Yousef
@ 2021-01-12  7:26   ` Andrii Nakryiko
  2021-01-12 19:27     ` Qais Yousef
  0 siblings, 1 reply; 14+ messages in thread
From: Andrii Nakryiko @ 2021-01-12  7:26 UTC (permalink / raw)
  To: Qais Yousef
  Cc: Networking, bpf, Alexei Starovoitov, Andrii Nakryiko,
	Daniel Borkmann, Steven Rostedt, Peter Zijlstra (Intel),
	open list

On Mon, Jan 11, 2021 at 10:20 AM Qais Yousef <qais.yousef@arm.com> wrote:
>
> Reuse module_attach infrastructure to add a new bare tracepoint to check
> we can attach to it as a raw tracepoint.
>
> Signed-off-by: Qais Yousef <qais.yousef@arm.com>
> ---
>
> Andrii
>
> I was getting the error below when I was trying to run the test.
> I had to comment out all related fentry* code to be able to test the raw_tp
> stuff. Not sure something I've done wrong or it's broken for some reason.
> I was on v5.11-rc2.

Check that you have all the required Kconfig options from
tools/testing/selftests/bpf/config. And also you will need to build
pahole from master, 1.19 doesn't have some fixes that add kernel
module support. I think pahole is the reasons why you have the failure
below.

>
>         $ sudo ./test_progs -v -t module_attach

use -vv when debugging stuff like that with test_progs, it will output
libbpf detailed logs, that often are very helpful

>         bpf_testmod.ko is already unloaded.
>         Loading bpf_testmod.ko...
>         Successfully loaded bpf_testmod.ko.
>         test_module_attach:PASS:skel_open 0 nsec
>         test_module_attach:PASS:set_attach_target 0 nsec
>         test_module_attach:PASS:skel_load 0 nsec
>         libbpf: prog 'handle_fentry': failed to attach: ERROR: strerror_r(-524)=22
>         libbpf: failed to auto-attach program 'handle_fentry': -524
>         test_module_attach:FAIL:skel_attach skeleton attach failed: -524
>         #58 module_attach:FAIL
>         Successfully unloaded bpf_testmod.ko.
>         Summary: 0/0 PASSED, 0 SKIPPED, 1 FAILED
>

But even apart from test failure, there seems to be kernel build
failure. See [0] for what fails in kernel-patches CI.

   [0] https://travis-ci.com/github/kernel-patches/bpf/builds/212730017


>
>  .../selftests/bpf/bpf_testmod/bpf_testmod-events.h     |  6 ++++++
>  tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c  |  2 ++
>  tools/testing/selftests/bpf/prog_tests/module_attach.c |  1 +
>  tools/testing/selftests/bpf/progs/test_module_attach.c | 10 ++++++++++
>  4 files changed, 19 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod-events.h b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod-events.h
> index b83ea448bc79..e1ada753f10c 100644
> --- a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod-events.h
> +++ b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod-events.h
> @@ -28,6 +28,12 @@ TRACE_EVENT(bpf_testmod_test_read,
>                   __entry->pid, __entry->comm, __entry->off, __entry->len)
>  );
>
> +/* A bare tracepoint with no event associated with it */
> +DECLARE_TRACE(bpf_testmod_test_read_bare,
> +       TP_PROTO(struct task_struct *task, struct bpf_testmod_test_read_ctx *ctx),
> +       TP_ARGS(task, ctx)
> +);
> +
>  #endif /* _BPF_TESTMOD_EVENTS_H */
>
>  #undef TRACE_INCLUDE_PATH
> diff --git a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
> index 2df19d73ca49..d63cebdaca44 100644
> --- a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
> +++ b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
> @@ -22,6 +22,8 @@ bpf_testmod_test_read(struct file *file, struct kobject *kobj,
>         };
>
>         trace_bpf_testmod_test_read(current, &ctx);
> +       ctx.len++;
> +       trace_bpf_testmod_test_read_bare(current, &ctx);

It's kind of boring to have two read tracepoints :) Do you mind adding
a write tracepoint and use bare tracepoint there? You won't need this
ctx.len++ hack as well. Feel free to add identical
bpf_testmod_test_write_ctx (renaming it is more of a pain).

>
>         return -EIO; /* always fail */
>  }
> diff --git a/tools/testing/selftests/bpf/prog_tests/module_attach.c b/tools/testing/selftests/bpf/prog_tests/module_attach.c
> index 50796b651f72..7085a118f38c 100644
> --- a/tools/testing/selftests/bpf/prog_tests/module_attach.c
> +++ b/tools/testing/selftests/bpf/prog_tests/module_attach.c
> @@ -50,6 +50,7 @@ void test_module_attach(void)
>         ASSERT_OK(trigger_module_test_read(READ_SZ), "trigger_read");
>
>         ASSERT_EQ(bss->raw_tp_read_sz, READ_SZ, "raw_tp");
> +       ASSERT_EQ(bss->raw_tp_bare_read_sz, READ_SZ+1, "raw_tp_bare");
>         ASSERT_EQ(bss->tp_btf_read_sz, READ_SZ, "tp_btf");
>         ASSERT_EQ(bss->fentry_read_sz, READ_SZ, "fentry");
>         ASSERT_EQ(bss->fentry_manual_read_sz, READ_SZ, "fentry_manual");
> diff --git a/tools/testing/selftests/bpf/progs/test_module_attach.c b/tools/testing/selftests/bpf/progs/test_module_attach.c
> index efd1e287ac17..08aa157afa1d 100644
> --- a/tools/testing/selftests/bpf/progs/test_module_attach.c
> +++ b/tools/testing/selftests/bpf/progs/test_module_attach.c
> @@ -17,6 +17,16 @@ int BPF_PROG(handle_raw_tp,
>         return 0;
>  }
>
> +__u32 raw_tp_bare_read_sz = 0;
> +
> +SEC("raw_tp/bpf_testmod_test_read_bare")
> +int BPF_PROG(handle_raw_tp_bare,
> +            struct task_struct *task, struct bpf_testmod_test_read_ctx *read_ctx)
> +{
> +       raw_tp_bare_read_sz = BPF_CORE_READ(read_ctx, len);
> +       return 0;
> +}
> +
>  __u32 tp_btf_read_sz = 0;
>
>  SEC("tp_btf/bpf_testmod_test_read")
> --
> 2.25.1
>

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

* Re: [PATCH bpf-next 2/2] selftests: bpf: Add a new test for bare tracepoints
  2021-01-12  7:26   ` Andrii Nakryiko
@ 2021-01-12 19:27     ` Qais Yousef
  2021-01-12 20:07       ` Andrii Nakryiko
  0 siblings, 1 reply; 14+ messages in thread
From: Qais Yousef @ 2021-01-12 19:27 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: Networking, bpf, Alexei Starovoitov, Andrii Nakryiko,
	Daniel Borkmann, Steven Rostedt, Peter Zijlstra (Intel),
	open list

On 01/11/21 23:26, Andrii Nakryiko wrote:
> On Mon, Jan 11, 2021 at 10:20 AM Qais Yousef <qais.yousef@arm.com> wrote:
> >
> > Reuse module_attach infrastructure to add a new bare tracepoint to check
> > we can attach to it as a raw tracepoint.
> >
> > Signed-off-by: Qais Yousef <qais.yousef@arm.com>
> > ---
> >
> > Andrii
> >
> > I was getting the error below when I was trying to run the test.
> > I had to comment out all related fentry* code to be able to test the raw_tp
> > stuff. Not sure something I've done wrong or it's broken for some reason.
> > I was on v5.11-rc2.
> 
> Check that you have all the required Kconfig options from
> tools/testing/selftests/bpf/config. And also you will need to build

Yep I have merged this config snippet using merge_config.sh script.

> pahole from master, 1.19 doesn't have some fixes that add kernel
> module support. I think pahole is the reasons why you have the failure
> below.

I am using pahole 1.19. I have built it from tip of master though.

/trying using v1.19 tag

Still fails the same.

> 
> >
> >         $ sudo ./test_progs -v -t module_attach
> 
> use -vv when debugging stuff like that with test_progs, it will output
> libbpf detailed logs, that often are very helpful

I tried that but it didn't help me. Full output is here

	https://paste.debian.net/1180846

> 
> >         bpf_testmod.ko is already unloaded.
> >         Loading bpf_testmod.ko...
> >         Successfully loaded bpf_testmod.ko.
> >         test_module_attach:PASS:skel_open 0 nsec
> >         test_module_attach:PASS:set_attach_target 0 nsec
> >         test_module_attach:PASS:skel_load 0 nsec
> >         libbpf: prog 'handle_fentry': failed to attach: ERROR: strerror_r(-524)=22
> >         libbpf: failed to auto-attach program 'handle_fentry': -524
> >         test_module_attach:FAIL:skel_attach skeleton attach failed: -524
> >         #58 module_attach:FAIL
> >         Successfully unloaded bpf_testmod.ko.
> >         Summary: 0/0 PASSED, 0 SKIPPED, 1 FAILED
> >
> 
> But even apart from test failure, there seems to be kernel build
> failure. See [0] for what fails in kernel-patches CI.
> 
>    [0] https://travis-ci.com/github/kernel-patches/bpf/builds/212730017

Sorry about that. I did a last minute change because of checkpatch.pl error and
it seems I either forgot to rebuild or missed that the rebuild failed :/

> 
> 
> >
> >  .../selftests/bpf/bpf_testmod/bpf_testmod-events.h     |  6 ++++++
> >  tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c  |  2 ++
> >  tools/testing/selftests/bpf/prog_tests/module_attach.c |  1 +
> >  tools/testing/selftests/bpf/progs/test_module_attach.c | 10 ++++++++++
> >  4 files changed, 19 insertions(+)
> >
> > diff --git a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod-events.h b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod-events.h
> > index b83ea448bc79..e1ada753f10c 100644
> > --- a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod-events.h
> > +++ b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod-events.h
> > @@ -28,6 +28,12 @@ TRACE_EVENT(bpf_testmod_test_read,
> >                   __entry->pid, __entry->comm, __entry->off, __entry->len)
> >  );
> >
> > +/* A bare tracepoint with no event associated with it */
> > +DECLARE_TRACE(bpf_testmod_test_read_bare,
> > +       TP_PROTO(struct task_struct *task, struct bpf_testmod_test_read_ctx *ctx),
> > +       TP_ARGS(task, ctx)
> > +);
> > +
> >  #endif /* _BPF_TESTMOD_EVENTS_H */
> >
> >  #undef TRACE_INCLUDE_PATH
> > diff --git a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
> > index 2df19d73ca49..d63cebdaca44 100644
> > --- a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
> > +++ b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
> > @@ -22,6 +22,8 @@ bpf_testmod_test_read(struct file *file, struct kobject *kobj,
> >         };
> >
> >         trace_bpf_testmod_test_read(current, &ctx);
> > +       ctx.len++;
> > +       trace_bpf_testmod_test_read_bare(current, &ctx);
> 
> It's kind of boring to have two read tracepoints :) Do you mind adding

Hehe boring is good :p

> a write tracepoint and use bare tracepoint there? You won't need this
> ctx.len++ hack as well. Feel free to add identical
> bpf_testmod_test_write_ctx (renaming it is more of a pain).

It was easy to get this done. So I think it should be easy to make it a write
too :)

Thanks

--
Qais Yousef

> 
> >
> >         return -EIO; /* always fail */
> >  }
> > diff --git a/tools/testing/selftests/bpf/prog_tests/module_attach.c b/tools/testing/selftests/bpf/prog_tests/module_attach.c
> > index 50796b651f72..7085a118f38c 100644
> > --- a/tools/testing/selftests/bpf/prog_tests/module_attach.c
> > +++ b/tools/testing/selftests/bpf/prog_tests/module_attach.c
> > @@ -50,6 +50,7 @@ void test_module_attach(void)
> >         ASSERT_OK(trigger_module_test_read(READ_SZ), "trigger_read");
> >
> >         ASSERT_EQ(bss->raw_tp_read_sz, READ_SZ, "raw_tp");
> > +       ASSERT_EQ(bss->raw_tp_bare_read_sz, READ_SZ+1, "raw_tp_bare");
> >         ASSERT_EQ(bss->tp_btf_read_sz, READ_SZ, "tp_btf");
> >         ASSERT_EQ(bss->fentry_read_sz, READ_SZ, "fentry");
> >         ASSERT_EQ(bss->fentry_manual_read_sz, READ_SZ, "fentry_manual");
> > diff --git a/tools/testing/selftests/bpf/progs/test_module_attach.c b/tools/testing/selftests/bpf/progs/test_module_attach.c
> > index efd1e287ac17..08aa157afa1d 100644
> > --- a/tools/testing/selftests/bpf/progs/test_module_attach.c
> > +++ b/tools/testing/selftests/bpf/progs/test_module_attach.c
> > @@ -17,6 +17,16 @@ int BPF_PROG(handle_raw_tp,
> >         return 0;
> >  }
> >
> > +__u32 raw_tp_bare_read_sz = 0;
> > +
> > +SEC("raw_tp/bpf_testmod_test_read_bare")
> > +int BPF_PROG(handle_raw_tp_bare,
> > +            struct task_struct *task, struct bpf_testmod_test_read_ctx *read_ctx)
> > +{
> > +       raw_tp_bare_read_sz = BPF_CORE_READ(read_ctx, len);
> > +       return 0;
> > +}
> > +
> >  __u32 tp_btf_read_sz = 0;
> >
> >  SEC("tp_btf/bpf_testmod_test_read")
> > --
> > 2.25.1
> >

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

* Re: [PATCH bpf-next 2/2] selftests: bpf: Add a new test for bare tracepoints
  2021-01-12 19:27     ` Qais Yousef
@ 2021-01-12 20:07       ` Andrii Nakryiko
  2021-01-13 10:21         ` Qais Yousef
  0 siblings, 1 reply; 14+ messages in thread
From: Andrii Nakryiko @ 2021-01-12 20:07 UTC (permalink / raw)
  To: Qais Yousef
  Cc: Networking, bpf, Alexei Starovoitov, Andrii Nakryiko,
	Daniel Borkmann, Steven Rostedt, Peter Zijlstra (Intel),
	open list

On Tue, Jan 12, 2021 at 11:27 AM Qais Yousef <qais.yousef@arm.com> wrote:
>
> On 01/11/21 23:26, Andrii Nakryiko wrote:
> > On Mon, Jan 11, 2021 at 10:20 AM Qais Yousef <qais.yousef@arm.com> wrote:
> > >
> > > Reuse module_attach infrastructure to add a new bare tracepoint to check
> > > we can attach to it as a raw tracepoint.
> > >
> > > Signed-off-by: Qais Yousef <qais.yousef@arm.com>
> > > ---
> > >
> > > Andrii
> > >
> > > I was getting the error below when I was trying to run the test.
> > > I had to comment out all related fentry* code to be able to test the raw_tp
> > > stuff. Not sure something I've done wrong or it's broken for some reason.
> > > I was on v5.11-rc2.
> >
> > Check that you have all the required Kconfig options from
> > tools/testing/selftests/bpf/config. And also you will need to build
>
> Yep I have merged this config snippet using merge_config.sh script.
>
> > pahole from master, 1.19 doesn't have some fixes that add kernel
> > module support. I think pahole is the reasons why you have the failure
> > below.
>
> I am using pahole 1.19. I have built it from tip of master though.
>
> /trying using v1.19 tag
>
> Still fails the same.
>
> >
> > >
> > >         $ sudo ./test_progs -v -t module_attach
> >
> > use -vv when debugging stuff like that with test_progs, it will output
> > libbpf detailed logs, that often are very helpful
>
> I tried that but it didn't help me. Full output is here
>
>         https://paste.debian.net/1180846
>

It did help a bit for me to make sure that you have bpf_testmod
properly loaded and its BTF was found, so the problem is somewhere
else. Also, given load succeeded and attach failed with OPNOTSUPP, I
suspect you are missing some of FTRACE configs, which seems to be
missing from selftests's config as well. Check that you have
CONFIG_FTRACE=y and CONFIG_DYNAMIC_FTRACE=y, and you might need some
more. See [0] for a real config we are using to run all tests in
libbpf CI. If you figure out what you were missing, please also
contribute a patch to selftests' config.

  [0] https://github.com/libbpf/libbpf/blob/master/travis-ci/vmtest/configs/latest.config

> >
> > >         bpf_testmod.ko is already unloaded.
> > >         Loading bpf_testmod.ko...
> > >         Successfully loaded bpf_testmod.ko.
> > >         test_module_attach:PASS:skel_open 0 nsec
> > >         test_module_attach:PASS:set_attach_target 0 nsec
> > >         test_module_attach:PASS:skel_load 0 nsec
> > >         libbpf: prog 'handle_fentry': failed to attach: ERROR: strerror_r(-524)=22
> > >         libbpf: failed to auto-attach program 'handle_fentry': -524
> > >         test_module_attach:FAIL:skel_attach skeleton attach failed: -524
> > >         #58 module_attach:FAIL
> > >         Successfully unloaded bpf_testmod.ko.
> > >         Summary: 0/0 PASSED, 0 SKIPPED, 1 FAILED
> > >
> >
> > But even apart from test failure, there seems to be kernel build
> > failure. See [0] for what fails in kernel-patches CI.
> >
> >    [0] https://travis-ci.com/github/kernel-patches/bpf/builds/212730017
>
> Sorry about that. I did a last minute change because of checkpatch.pl error and
> it seems I either forgot to rebuild or missed that the rebuild failed :/
>

no worries, just fix and re-submit. Good that we have CI that caught
this early on.

> >
> >
> > >
> > >  .../selftests/bpf/bpf_testmod/bpf_testmod-events.h     |  6 ++++++
> > >  tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c  |  2 ++
> > >  tools/testing/selftests/bpf/prog_tests/module_attach.c |  1 +
> > >  tools/testing/selftests/bpf/progs/test_module_attach.c | 10 ++++++++++
> > >  4 files changed, 19 insertions(+)
> > >
> > > diff --git a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod-events.h b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod-events.h
> > > index b83ea448bc79..e1ada753f10c 100644
> > > --- a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod-events.h
> > > +++ b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod-events.h
> > > @@ -28,6 +28,12 @@ TRACE_EVENT(bpf_testmod_test_read,
> > >                   __entry->pid, __entry->comm, __entry->off, __entry->len)
> > >  );
> > >
> > > +/* A bare tracepoint with no event associated with it */
> > > +DECLARE_TRACE(bpf_testmod_test_read_bare,
> > > +       TP_PROTO(struct task_struct *task, struct bpf_testmod_test_read_ctx *ctx),
> > > +       TP_ARGS(task, ctx)
> > > +);
> > > +
> > >  #endif /* _BPF_TESTMOD_EVENTS_H */
> > >
> > >  #undef TRACE_INCLUDE_PATH
> > > diff --git a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
> > > index 2df19d73ca49..d63cebdaca44 100644
> > > --- a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
> > > +++ b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
> > > @@ -22,6 +22,8 @@ bpf_testmod_test_read(struct file *file, struct kobject *kobj,
> > >         };
> > >
> > >         trace_bpf_testmod_test_read(current, &ctx);
> > > +       ctx.len++;
> > > +       trace_bpf_testmod_test_read_bare(current, &ctx);
> >
> > It's kind of boring to have two read tracepoints :) Do you mind adding
>
> Hehe boring is good :p
>
> > a write tracepoint and use bare tracepoint there? You won't need this
> > ctx.len++ hack as well. Feel free to add identical
> > bpf_testmod_test_write_ctx (renaming it is more of a pain).
>
> It was easy to get this done. So I think it should be easy to make it a write
> too :)

yep, having two tracepoints allow more flexibility over longer term,
so I think it's good to do (regardless of boring or not ;) )

>
> Thanks
>
> --
> Qais Yousef
>
> >
> > >
> > >         return -EIO; /* always fail */
> > >  }
> > > diff --git a/tools/testing/selftests/bpf/prog_tests/module_attach.c b/tools/testing/selftests/bpf/prog_tests/module_attach.c
> > > index 50796b651f72..7085a118f38c 100644
> > > --- a/tools/testing/selftests/bpf/prog_tests/module_attach.c
> > > +++ b/tools/testing/selftests/bpf/prog_tests/module_attach.c
> > > @@ -50,6 +50,7 @@ void test_module_attach(void)
> > >         ASSERT_OK(trigger_module_test_read(READ_SZ), "trigger_read");
> > >
> > >         ASSERT_EQ(bss->raw_tp_read_sz, READ_SZ, "raw_tp");
> > > +       ASSERT_EQ(bss->raw_tp_bare_read_sz, READ_SZ+1, "raw_tp_bare");
> > >         ASSERT_EQ(bss->tp_btf_read_sz, READ_SZ, "tp_btf");
> > >         ASSERT_EQ(bss->fentry_read_sz, READ_SZ, "fentry");
> > >         ASSERT_EQ(bss->fentry_manual_read_sz, READ_SZ, "fentry_manual");
> > > diff --git a/tools/testing/selftests/bpf/progs/test_module_attach.c b/tools/testing/selftests/bpf/progs/test_module_attach.c
> > > index efd1e287ac17..08aa157afa1d 100644
> > > --- a/tools/testing/selftests/bpf/progs/test_module_attach.c
> > > +++ b/tools/testing/selftests/bpf/progs/test_module_attach.c
> > > @@ -17,6 +17,16 @@ int BPF_PROG(handle_raw_tp,
> > >         return 0;
> > >  }
> > >
> > > +__u32 raw_tp_bare_read_sz = 0;
> > > +
> > > +SEC("raw_tp/bpf_testmod_test_read_bare")
> > > +int BPF_PROG(handle_raw_tp_bare,
> > > +            struct task_struct *task, struct bpf_testmod_test_read_ctx *read_ctx)
> > > +{
> > > +       raw_tp_bare_read_sz = BPF_CORE_READ(read_ctx, len);
> > > +       return 0;
> > > +}
> > > +
> > >  __u32 tp_btf_read_sz = 0;
> > >
> > >  SEC("tp_btf/bpf_testmod_test_read")
> > > --
> > > 2.25.1
> > >

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

* Re: [PATCH bpf-next 1/2] trace: bpf: Allow bpf to attach to bare tracepoints
  2021-01-11 18:20 ` [PATCH bpf-next 1/2] trace: bpf: Allow bpf to attach " Qais Yousef
@ 2021-01-12 20:19   ` Yonghong Song
  2021-01-13 10:16     ` Qais Yousef
  2021-01-14  2:59   ` kernel test robot
  2021-01-14  3:46   ` kernel test robot
  2 siblings, 1 reply; 14+ messages in thread
From: Yonghong Song @ 2021-01-12 20:19 UTC (permalink / raw)
  To: Qais Yousef, netdev, bpf
  Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	Steven Rostedt, Peter Zijlstra (Intel),
	linux-kernel



On 1/11/21 10:20 AM, Qais Yousef wrote:
> Some subsystems only have bare tracepoints (a tracepoint with no
> associated trace event) to avoid the problem of trace events being an
> ABI that can't be changed.
> 
>  From bpf presepective, bare tracepoints are what it calls
> RAW_TRACEPOINT().
> 
> Since bpf assumed there's 1:1 mapping, it relied on hooking to
> DEFINE_EVENT() macro to create bpf mapping of the tracepoints. Since
> bare tracepoints use DECLARE_TRACE() to create the tracepoint, bpf had
> no knowledge about their existence.
> 
> By teaching bpf_probe.h to parse DECLARE_TRACE() in a similar fashion to
> DEFINE_EVENT(), bpf can find and attach to the new raw tracepoints.
> 
> Enabling that comes with the contract that changes to raw tracepoints
> don't constitute a regression if they break existing bpf programs.
> We need the ability to continue to morph and modify these raw
> tracepoints without worrying about any ABI.
> 
> Update Documentation/bpf/bpf_design_QA.rst to document this contract.
> 
> Signed-off-by: Qais Yousef <qais.yousef@arm.com>
> ---
>   Documentation/bpf/bpf_design_QA.rst |  6 ++++++
>   include/trace/bpf_probe.h           | 12 ++++++++++--
>   2 files changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/bpf/bpf_design_QA.rst b/Documentation/bpf/bpf_design_QA.rst
> index 2df7b067ab93..0e15f9b05c9d 100644
> --- a/Documentation/bpf/bpf_design_QA.rst
> +++ b/Documentation/bpf/bpf_design_QA.rst
> @@ -208,6 +208,12 @@ data structures and compile with kernel internal headers. Both of these
>   kernel internals are subject to change and can break with newer kernels
>   such that the program needs to be adapted accordingly.
>   
> +Q: Are tracepoints part of the stable ABI?
> +------------------------------------------
> +A: NO. Tracepoints are tied to internal implementation details hence they are
> +subject to change and can break with newer kernels. BPF programs need to change
> +accordingly when this happens.
> +
>   Q: How much stack space a BPF program uses?
>   -------------------------------------------
>   A: Currently all program types are limited to 512 bytes of stack
> diff --git a/include/trace/bpf_probe.h b/include/trace/bpf_probe.h
> index cd74bffed5c6..cf1496b162b1 100644
> --- a/include/trace/bpf_probe.h
> +++ b/include/trace/bpf_probe.h
> @@ -55,8 +55,7 @@
>   /* tracepoints with more than 12 arguments will hit build error */
>   #define CAST_TO_U64(...) CONCATENATE(__CAST, COUNT_ARGS(__VA_ARGS__))(__VA_ARGS__)
>   
> -#undef DECLARE_EVENT_CLASS
> -#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)	\
> +#define __BPF_DECLARE_TRACE(call, proto, args)				\
>   static notrace void							\
>   __bpf_trace_##call(void *__data, proto)					\
>   {									\
> @@ -64,6 +63,10 @@ __bpf_trace_##call(void *__data, proto)					\
>   	CONCATENATE(bpf_trace_run, COUNT_ARGS(args))(prog, CAST_TO_U64(args));	\
>   }
>   
> +#undef DECLARE_EVENT_CLASS
> +#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print)	\
> +	__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))
> +
>   /*
>    * This part is compiled out, it is only here as a build time check
>    * to make sure that if the tracepoint handling changes, the
> @@ -111,6 +114,11 @@ __DEFINE_EVENT(template, call, PARAMS(proto), PARAMS(args), size)
>   #define DEFINE_EVENT_PRINT(template, name, proto, args, print)	\
>   	DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
>   
> +#undef DECLARE_TRACE
> +#define DECLARE_TRACE(call, proto, args)				\
> +	(__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))		\
> +	 __DEFINE_EVENT(call, call, PARAMS(proto), PARAMS(args), 0))

I applied the patch to my local bpf-next repo, and got the following
compilation error:

In file included from 
/data/users/yhs/work/net-next/include/trace/define_trace.h:104, 

                  from 
/data/users/yhs/work/net-next/include/trace/events/sched.h:740, 

                  from 
/data/users/yhs/work/net-next/kernel/sched/core.c:10: 

/data/users/yhs/work/net-next/include/trace/bpf_probe.h:59:1: error: 
expected identifier or ‘(’ before ‘static’
  static notrace void       \ 

  ^~~~~~ 

/data/users/yhs/work/net-next/include/trace/bpf_probe.h:119:3: note: in 
expansion of macro ‘__BPF_DECLARE_TRACE’
   (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \ 

    ^~~~~~~~~~~~~~~~~~~ 

/data/users/yhs/work/net-next/include/trace/events/sched.h:693:1: note: 
in expansion of macro ‘DECLARE_TRACE’
  DECLARE_TRACE(pelt_cfs_tp, 

  ^~~~~~~~~~~~~ 

/data/users/yhs/work/net-next/include/trace/bpf_probe.h:59:1: error: 
expected identifier or ‘(’ before ‘static’
  static notrace void       \ 

  ^~~~~~ 

/data/users/yhs/work/net-next/include/trace/bpf_probe.h:119:3: note: in 
expansion of macro ‘__BPF_DECLARE_TRACE’
   (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \ 

    ^~~~~~~~~~~~~~~~~~~ 

/data/users/yhs/work/net-next/include/trace/events/sched.h:697:1: note: 
in expansion of macro ‘DECLARE_TRACE’
  DECLARE_TRACE(pelt_rt_tp, 

  ^~~~~~~~~~~~~
/data/users/yhs/work/net-next/include/trace/bpf_probe.h:59:1: error: 
expected identifier or ‘(’ before ‘static’
  static notrace void       \

I dumped preprecessor result but after macro expansion, the code
becomes really complex and I have not figured out why it failed.
Do you know what is the possible reason?

> +
>   #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
>   
>   #undef DEFINE_EVENT_WRITABLE
> 

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

* Re: [PATCH bpf-next 1/2] trace: bpf: Allow bpf to attach to bare tracepoints
  2021-01-12 20:19   ` Yonghong Song
@ 2021-01-13 10:16     ` Qais Yousef
  2021-01-13 16:06       ` Yonghong Song
  0 siblings, 1 reply; 14+ messages in thread
From: Qais Yousef @ 2021-01-13 10:16 UTC (permalink / raw)
  To: Yonghong Song
  Cc: netdev, bpf, Alexei Starovoitov, Andrii Nakryiko,
	Daniel Borkmann, Steven Rostedt, Peter Zijlstra (Intel),
	linux-kernel

On 01/12/21 12:19, Yonghong Song wrote:
> I applied the patch to my local bpf-next repo, and got the following
> compilation error:

[...]

> 
> I dumped preprecessor result but after macro expansion, the code
> becomes really complex and I have not figured out why it failed.
> Do you know what is the possible reason?

Yeah I did a last minute fix to address a checkpatch.pl error and my
verification of the change wasn't good enough obviously.

If you're keen to try out I can send you a patch with the fix. I should send v2
by the weekend too.

Thanks for having a look.

Cheers

--
Qais Yousef

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

* Re: [PATCH bpf-next 2/2] selftests: bpf: Add a new test for bare tracepoints
  2021-01-12 20:07       ` Andrii Nakryiko
@ 2021-01-13 10:21         ` Qais Yousef
  2021-01-13 16:40           ` Jean-Philippe Brucker
  0 siblings, 1 reply; 14+ messages in thread
From: Qais Yousef @ 2021-01-13 10:21 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: Networking, bpf, Alexei Starovoitov, Andrii Nakryiko,
	Daniel Borkmann, Steven Rostedt, Peter Zijlstra (Intel),
	open list

On 01/12/21 12:07, Andrii Nakryiko wrote:
> > > >         $ sudo ./test_progs -v -t module_attach
> > >
> > > use -vv when debugging stuff like that with test_progs, it will output
> > > libbpf detailed logs, that often are very helpful
> >
> > I tried that but it didn't help me. Full output is here
> >
> >         https://paste.debian.net/1180846
> >
> 
> It did help a bit for me to make sure that you have bpf_testmod
> properly loaded and its BTF was found, so the problem is somewhere
> else. Also, given load succeeded and attach failed with OPNOTSUPP, I
> suspect you are missing some of FTRACE configs, which seems to be
> missing from selftests's config as well. Check that you have
> CONFIG_FTRACE=y and CONFIG_DYNAMIC_FTRACE=y, and you might need some
> more. See [0] for a real config we are using to run all tests in
> libbpf CI. If you figure out what you were missing, please also
> contribute a patch to selftests' config.
> 
>   [0] https://github.com/libbpf/libbpf/blob/master/travis-ci/vmtest/configs/latest.config

Yeah that occurred to me too. I do have all necessary FTRACE options enabled,
including DYNAMIC_FTRACE. I think I did try enabling fault injection too just
in case. I have CONFIG_FAULT_INJECTION=y and CONFIG_FUNCTION_ERROR_INJECTION=y.

I will look at the CI config and see if I can figure it out.

I will likely get a chance to look at all of this and send v2  over the
weekend.

Thanks

--
Qais Yousef

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

* Re: [PATCH bpf-next 1/2] trace: bpf: Allow bpf to attach to bare tracepoints
  2021-01-13 10:16     ` Qais Yousef
@ 2021-01-13 16:06       ` Yonghong Song
  0 siblings, 0 replies; 14+ messages in thread
From: Yonghong Song @ 2021-01-13 16:06 UTC (permalink / raw)
  To: Qais Yousef
  Cc: netdev, bpf, Alexei Starovoitov, Andrii Nakryiko,
	Daniel Borkmann, Steven Rostedt, Peter Zijlstra (Intel),
	linux-kernel



On 1/13/21 2:16 AM, Qais Yousef wrote:
> On 01/12/21 12:19, Yonghong Song wrote:
>> I applied the patch to my local bpf-next repo, and got the following
>> compilation error:
> 
> [...]
> 
>>
>> I dumped preprecessor result but after macro expansion, the code
>> becomes really complex and I have not figured out why it failed.
>> Do you know what is the possible reason?
> 
> Yeah I did a last minute fix to address a checkpatch.pl error and my
> verification of the change wasn't good enough obviously.
> 
> If you're keen to try out I can send you a patch with the fix. I should send v2
> by the weekend too.

Thanks. I can wait and will check v2 once it is available.

> 
> Thanks for having a look.
> 
> Cheers
> 
> --
> Qais Yousef
> 

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

* Re: [PATCH bpf-next 2/2] selftests: bpf: Add a new test for bare tracepoints
  2021-01-13 10:21         ` Qais Yousef
@ 2021-01-13 16:40           ` Jean-Philippe Brucker
  2021-01-14 12:58             ` Qais Yousef
  0 siblings, 1 reply; 14+ messages in thread
From: Jean-Philippe Brucker @ 2021-01-13 16:40 UTC (permalink / raw)
  To: Qais Yousef
  Cc: Andrii Nakryiko, Networking, bpf, Alexei Starovoitov,
	Andrii Nakryiko, Daniel Borkmann, Steven Rostedt,
	Peter Zijlstra (Intel),
	open list

On Wed, Jan 13, 2021 at 10:21:31AM +0000, Qais Yousef wrote:
> On 01/12/21 12:07, Andrii Nakryiko wrote:
> > > > >         $ sudo ./test_progs -v -t module_attach
> > > >
> > > > use -vv when debugging stuff like that with test_progs, it will output
> > > > libbpf detailed logs, that often are very helpful
> > >
> > > I tried that but it didn't help me. Full output is here
> > >
> > >         https://paste.debian.net/1180846
> > >
> > 
> > It did help a bit for me to make sure that you have bpf_testmod
> > properly loaded and its BTF was found, so the problem is somewhere
> > else. Also, given load succeeded and attach failed with OPNOTSUPP, I
> > suspect you are missing some of FTRACE configs, which seems to be
> > missing from selftests's config as well. Check that you have
> > CONFIG_FTRACE=y and CONFIG_DYNAMIC_FTRACE=y, and you might need some
> > more. See [0] for a real config we are using to run all tests in
> > libbpf CI. If you figure out what you were missing, please also
> > contribute a patch to selftests' config.
> > 
> >   [0] https://github.com/libbpf/libbpf/blob/master/travis-ci/vmtest/configs/latest.config
> 
> Yeah that occurred to me too. I do have all necessary FTRACE options enabled,
> including DYNAMIC_FTRACE. I think I did try enabling fault injection too just
> in case. I have CONFIG_FAULT_INJECTION=y and CONFIG_FUNCTION_ERROR_INJECTION=y.

Could it come from lack of fentry support on arm64 (or are you testing on
x86?) Since the arm64 JIT doesn't have trampoline support at the moment, a
lot of bpf selftests fail with ENOTSUPP.

Thanks,
Jean

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

* Re: [PATCH bpf-next 1/2] trace: bpf: Allow bpf to attach to bare tracepoints
  2021-01-11 18:20 ` [PATCH bpf-next 1/2] trace: bpf: Allow bpf to attach " Qais Yousef
  2021-01-12 20:19   ` Yonghong Song
@ 2021-01-14  2:59   ` kernel test robot
  2021-01-14  3:46   ` kernel test robot
  2 siblings, 0 replies; 14+ messages in thread
From: kernel test robot @ 2021-01-14  2:59 UTC (permalink / raw)
  To: Qais Yousef, netdev, bpf
  Cc: kbuild-all, Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	Steven Rostedt, Peter Zijlstra (Intel),
	linux-kernel, Qais Yousef


[-- Attachment #1: Type: text/plain, Size: 7770 bytes --]

Hi Qais,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on bpf-next/master]

url:    https://github.com/0day-ci/linux/commits/Qais-Yousef/Allow-attaching-to-bare-tracepoints/20210112-022350
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
config: x86_64-rhel-7.6-kselftests (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/8f02e2ee2ac949ce6b4fd3cfd323f2e513a2cac6
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Qais-Yousef/Allow-attaching-to-bare-tracepoints/20210112-022350
        git checkout 8f02e2ee2ac949ce6b4fd3cfd323f2e513a2cac6
        # save the attached .config to linux build tree
        make W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from include/trace/define_trace.h:104,
                    from include/trace/events/sched.h:740,
                    from kernel/sched/core.c:10:
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:693:1: note: in expansion of macro 'DECLARE_TRACE'
     693 | DECLARE_TRACE(pelt_cfs_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:697:1: note: in expansion of macro 'DECLARE_TRACE'
     697 | DECLARE_TRACE(pelt_rt_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:701:1: note: in expansion of macro 'DECLARE_TRACE'
     701 | DECLARE_TRACE(pelt_dl_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:705:1: note: in expansion of macro 'DECLARE_TRACE'
     705 | DECLARE_TRACE(pelt_thermal_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:709:1: note: in expansion of macro 'DECLARE_TRACE'
     709 | DECLARE_TRACE(pelt_irq_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:713:1: note: in expansion of macro 'DECLARE_TRACE'
     713 | DECLARE_TRACE(pelt_se_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:717:1: note: in expansion of macro 'DECLARE_TRACE'
     717 | DECLARE_TRACE(sched_cpu_capacity_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:721:1: note: in expansion of macro 'DECLARE_TRACE'
     721 | DECLARE_TRACE(sched_overutilized_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:725:1: note: in expansion of macro 'DECLARE_TRACE'
     725 | DECLARE_TRACE(sched_util_est_cfs_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:729:1: note: in expansion of macro 'DECLARE_TRACE'
     729 | DECLARE_TRACE(sched_util_est_se_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:733:1: note: in expansion of macro 'DECLARE_TRACE'
     733 | DECLARE_TRACE(sched_update_nr_running_tp,
         | ^~~~~~~~~~~~~
   kernel/sched/core.c:2828:6: warning: no previous prototype for 'sched_set_stop_task' [-Wmissing-prototypes]
    2828 | void sched_set_stop_task(int cpu, struct task_struct *stop)
         |      ^~~~~~~~~~~~~~~~~~~
   kernel/sched/core.c: In function 'schedule_tail':
   kernel/sched/core.c:4238:13: warning: variable 'rq' set but not used [-Wunused-but-set-variable]
    4238 |  struct rq *rq;
         |             ^~


vim +59 include/trace/bpf_probe.h

c4f6699dfcb8558d Alexei Starovoitov 2018-03-28  57  
8f02e2ee2ac949ce Qais Yousef        2021-01-11  58  #define __BPF_DECLARE_TRACE(call, proto, args)				\
c4f6699dfcb8558d Alexei Starovoitov 2018-03-28 @59  static notrace void							\
c4f6699dfcb8558d Alexei Starovoitov 2018-03-28  60  __bpf_trace_##call(void *__data, proto)					\
c4f6699dfcb8558d Alexei Starovoitov 2018-03-28  61  {									\
c4f6699dfcb8558d Alexei Starovoitov 2018-03-28  62  	struct bpf_prog *prog = __data;					\
c4f6699dfcb8558d Alexei Starovoitov 2018-03-28  63  	CONCATENATE(bpf_trace_run, COUNT_ARGS(args))(prog, CAST_TO_U64(args));	\
c4f6699dfcb8558d Alexei Starovoitov 2018-03-28  64  }
c4f6699dfcb8558d Alexei Starovoitov 2018-03-28  65  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 50543 bytes --]

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

* Re: [PATCH bpf-next 1/2] trace: bpf: Allow bpf to attach to bare tracepoints
  2021-01-11 18:20 ` [PATCH bpf-next 1/2] trace: bpf: Allow bpf to attach " Qais Yousef
  2021-01-12 20:19   ` Yonghong Song
  2021-01-14  2:59   ` kernel test robot
@ 2021-01-14  3:46   ` kernel test robot
  2 siblings, 0 replies; 14+ messages in thread
From: kernel test robot @ 2021-01-14  3:46 UTC (permalink / raw)
  To: Qais Yousef, netdev, bpf
  Cc: kbuild-all, Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	Steven Rostedt, Peter Zijlstra (Intel),
	linux-kernel, Qais Yousef


[-- Attachment #1: Type: text/plain, Size: 7741 bytes --]

Hi Qais,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on bpf-next/master]

url:    https://github.com/0day-ci/linux/commits/Qais-Yousef/Allow-attaching-to-bare-tracepoints/20210112-022350
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
config: x86_64-rhel-8.3 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/8f02e2ee2ac949ce6b4fd3cfd323f2e513a2cac6
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Qais-Yousef/Allow-attaching-to-bare-tracepoints/20210112-022350
        git checkout 8f02e2ee2ac949ce6b4fd3cfd323f2e513a2cac6
        # save the attached .config to linux build tree
        make W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from include/trace/define_trace.h:104,
                    from include/trace/events/sched.h:740,
                    from kernel/sched/core.c:10:
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:693:1: note: in expansion of macro 'DECLARE_TRACE'
     693 | DECLARE_TRACE(pelt_cfs_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:697:1: note: in expansion of macro 'DECLARE_TRACE'
     697 | DECLARE_TRACE(pelt_rt_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:701:1: note: in expansion of macro 'DECLARE_TRACE'
     701 | DECLARE_TRACE(pelt_dl_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:705:1: note: in expansion of macro 'DECLARE_TRACE'
     705 | DECLARE_TRACE(pelt_thermal_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:709:1: note: in expansion of macro 'DECLARE_TRACE'
     709 | DECLARE_TRACE(pelt_irq_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:713:1: note: in expansion of macro 'DECLARE_TRACE'
     713 | DECLARE_TRACE(pelt_se_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:717:1: note: in expansion of macro 'DECLARE_TRACE'
     717 | DECLARE_TRACE(sched_cpu_capacity_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:721:1: note: in expansion of macro 'DECLARE_TRACE'
     721 | DECLARE_TRACE(sched_overutilized_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:725:1: note: in expansion of macro 'DECLARE_TRACE'
     725 | DECLARE_TRACE(sched_util_est_cfs_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:729:1: note: in expansion of macro 'DECLARE_TRACE'
     729 | DECLARE_TRACE(sched_util_est_se_tp,
         | ^~~~~~~~~~~~~
>> include/trace/bpf_probe.h:59:1: error: expected identifier or '(' before 'static'
      59 | static notrace void       \
         | ^~~~~~
   include/trace/bpf_probe.h:119:3: note: in expansion of macro '__BPF_DECLARE_TRACE'
     119 |  (__BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))  \
         |   ^~~~~~~~~~~~~~~~~~~
   include/trace/events/sched.h:733:1: note: in expansion of macro 'DECLARE_TRACE'
     733 | DECLARE_TRACE(sched_update_nr_running_tp,
         | ^~~~~~~~~~~~~
   kernel/sched/core.c:2828:6: warning: no previous prototype for 'sched_set_stop_task' [-Wmissing-prototypes]
    2828 | void sched_set_stop_task(int cpu, struct task_struct *stop)
         |      ^~~~~~~~~~~~~~~~~~~
   kernel/sched/core.c: In function 'schedule_tail':
   kernel/sched/core.c:4238:13: warning: variable 'rq' set but not used [-Wunused-but-set-variable]
    4238 |  struct rq *rq;
         |             ^~


vim +59 include/trace/bpf_probe.h

c4f6699dfcb855 Alexei Starovoitov 2018-03-28  57  
8f02e2ee2ac949 Qais Yousef        2021-01-11  58  #define __BPF_DECLARE_TRACE(call, proto, args)				\
c4f6699dfcb855 Alexei Starovoitov 2018-03-28 @59  static notrace void							\
c4f6699dfcb855 Alexei Starovoitov 2018-03-28  60  __bpf_trace_##call(void *__data, proto)					\
c4f6699dfcb855 Alexei Starovoitov 2018-03-28  61  {									\
c4f6699dfcb855 Alexei Starovoitov 2018-03-28  62  	struct bpf_prog *prog = __data;					\
c4f6699dfcb855 Alexei Starovoitov 2018-03-28  63  	CONCATENATE(bpf_trace_run, COUNT_ARGS(args))(prog, CAST_TO_U64(args));	\
c4f6699dfcb855 Alexei Starovoitov 2018-03-28  64  }
c4f6699dfcb855 Alexei Starovoitov 2018-03-28  65  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 41087 bytes --]

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

* Re: [PATCH bpf-next 2/2] selftests: bpf: Add a new test for bare tracepoints
  2021-01-13 16:40           ` Jean-Philippe Brucker
@ 2021-01-14 12:58             ` Qais Yousef
  0 siblings, 0 replies; 14+ messages in thread
From: Qais Yousef @ 2021-01-14 12:58 UTC (permalink / raw)
  To: Jean-Philippe Brucker
  Cc: Andrii Nakryiko, Networking, bpf, Alexei Starovoitov,
	Andrii Nakryiko, Daniel Borkmann, Steven Rostedt,
	Peter Zijlstra (Intel),
	open list

On 01/13/21 17:40, Jean-Philippe Brucker wrote:
> On Wed, Jan 13, 2021 at 10:21:31AM +0000, Qais Yousef wrote:
> > On 01/12/21 12:07, Andrii Nakryiko wrote:
> > > > > >         $ sudo ./test_progs -v -t module_attach
> > > > >
> > > > > use -vv when debugging stuff like that with test_progs, it will output
> > > > > libbpf detailed logs, that often are very helpful
> > > >
> > > > I tried that but it didn't help me. Full output is here
> > > >
> > > >         https://paste.debian.net/1180846
> > > >
> > > 
> > > It did help a bit for me to make sure that you have bpf_testmod
> > > properly loaded and its BTF was found, so the problem is somewhere
> > > else. Also, given load succeeded and attach failed with OPNOTSUPP, I
> > > suspect you are missing some of FTRACE configs, which seems to be
> > > missing from selftests's config as well. Check that you have
> > > CONFIG_FTRACE=y and CONFIG_DYNAMIC_FTRACE=y, and you might need some
> > > more. See [0] for a real config we are using to run all tests in
> > > libbpf CI. If you figure out what you were missing, please also
> > > contribute a patch to selftests' config.
> > > 
> > >   [0] https://github.com/libbpf/libbpf/blob/master/travis-ci/vmtest/configs/latest.config
> > 
> > Yeah that occurred to me too. I do have all necessary FTRACE options enabled,
> > including DYNAMIC_FTRACE. I think I did try enabling fault injection too just
> > in case. I have CONFIG_FAULT_INJECTION=y and CONFIG_FUNCTION_ERROR_INJECTION=y.
> 
> Could it come from lack of fentry support on arm64 (or are you testing on
> x86?) Since the arm64 JIT doesn't have trampoline support at the moment, a
> lot of bpf selftests fail with ENOTSUPP.

I am on arm64. I honestly have no clue about this. I'll try to dig out.

Thanks

--
Qais Yousef

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

end of thread, back to index

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-11 18:20 [PATCH bpf-next 0/2] Allow attaching to bare tracepoints Qais Yousef
2021-01-11 18:20 ` [PATCH bpf-next 1/2] trace: bpf: Allow bpf to attach " Qais Yousef
2021-01-12 20:19   ` Yonghong Song
2021-01-13 10:16     ` Qais Yousef
2021-01-13 16:06       ` Yonghong Song
2021-01-14  2:59   ` kernel test robot
2021-01-14  3:46   ` kernel test robot
2021-01-11 18:20 ` [PATCH bpf-next 2/2] selftests: bpf: Add a new test for " Qais Yousef
2021-01-12  7:26   ` Andrii Nakryiko
2021-01-12 19:27     ` Qais Yousef
2021-01-12 20:07       ` Andrii Nakryiko
2021-01-13 10:21         ` Qais Yousef
2021-01-13 16:40           ` Jean-Philippe Brucker
2021-01-14 12:58             ` Qais Yousef

Netdev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/netdev/0 netdev/git/0.git
	git clone --mirror https://lore.kernel.org/netdev/1 netdev/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netdev netdev/ https://lore.kernel.org/netdev \
		netdev@vger.kernel.org
	public-inbox-index netdev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.netdev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git