Thread (49 messages) 49 messages, 3 authors, 2021-12-01

Re: [PATCH bpf-next 09/29] bpf: Add support to load multi func tracing program

From: Jiri Olsa <hidden>
Date: 2021-12-01 21:20:44
Also in: bpf

On Tue, Nov 30, 2021 at 11:17:44PM -0800, Andrii Nakryiko wrote:
On Sun, Nov 28, 2021 at 9:41 AM Jiri Olsa [off-list ref] wrote:
quoted
On Wed, Nov 24, 2021 at 01:51:36PM -0800, Andrii Nakryiko wrote:
quoted
On Mon, Nov 22, 2021 at 12:15 PM Jiri Olsa [off-list ref] wrote:
quoted
On Thu, Nov 18, 2021 at 08:11:59PM -0800, Alexei Starovoitov wrote:
quoted
On Thu, Nov 18, 2021 at 12:24:35PM +0100, Jiri Olsa wrote:
quoted
+
+DEFINE_BPF_MULTI_FUNC(unsigned long a1, unsigned long a2,
+                 unsigned long a3, unsigned long a4,
+                 unsigned long a5, unsigned long a6)
This is probably a bit too x86 specific. May be make add all 12 args?
Or other places would need to be tweaked?
I think si, I'll check
quoted
quoted
+BTF_ID_LIST_SINGLE(bpf_multi_func_btf_id, func, bpf_multi_func)
...
quoted
-   prog->aux->attach_btf_id = attr->attach_btf_id;
+   prog->aux->attach_btf_id = multi_func ? bpf_multi_func_btf_id[0] : attr->attach_btf_id;
Just ignoring that was passed in uattr?
Maybe instead of ignoring dopr BPF_F_MULTI_FUNC and make libbpf
point to that btf_id instead?
Then multi or not can be checked with if (attr->attach_btf_id == bpf_multi_func_btf_id[0]).
nice idea, it might fit better than the flag
Instead of a flag we can also use a different expected_attach_type
(FENTRY vs FENTRY_MULTI, etc).
right, you already asked for that - https://lore.kernel.org/bpf/YS9k26rRcUJVS%2Fvx@krava/ (local)

I still think it'd mean more code while this way we just use
current fentry/fexit code paths with few special handling
for multi programs
I don't see how it makes much difference for kernel implementation.
Checking expected_attach_type vs checking prog_flags is about the same
amount of code. The big advantage of new expected_attach_type (or
prog_type) is that it will be very obvious in all sorts of diagnostics
tooling (think bpftool prog show output, etc). prog_flags are almost
invisible and it will be the last thing that users will think about.
I'd try to minimize the usage of prog_flags overall.
ok, I'll check on that.. I recall adding this new type in
many expected_attach_type switches, which made me think
the new flag will be easier
quoted
quoted
As for attach_btf_id, why can't we just
enforce it as 0?
there's prog->aux->attach_func_proto that needs to be set based
on attach_btf_id, and is checked later in btf_ctx_access
right:

if (attach_btf_id == 0)
    prog->aux->attach_func_proto =
&special_func_model_or_proto_or_whatever_that_does_not_have_to_be_known_to_libbpf_and_outside_world_ever;

;) let's keep implementation details as internal implementation
details, instead of dumping all that to UAPI
ok, we can do that ;-)

thanks,
jirka
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help