On 2026/2/3 17:38 Jiri Olsa <[email protected]> write:
> Adding bpf_trampoline_multi_attach/detach functions that allows
> to attach/detach multi tracing trampoline.
>
> The attachment is defined with bpf_program and array of BTF ids
> of functions to attach the bpf program to.
>
[...]
> @@ -367,7 +367,11 @@ static struct bpf_trampoline *bpf_trampoline_lookup(u64
> key, unsigned long ip)
> head = &trampoline_ip_table[hash_64(tr->ip, TRAMPOLINE_HASH_BITS)];
> hlist_add_head(&tr->hlist_ip, head);
> refcount_set(&tr->refcnt, 1);
> +#ifdef CONFIG_LOCKDEP
> + mutex_init_with_key(&tr->mutex, &__lockdep_no_track__);
> +#else
> mutex_init(&tr->mutex);
> +#endif
> for (i = 0; i < BPF_TRAMP_MAX; i++)
> INIT_HLIST_HEAD(&tr->progs_hlist[i]);
> out:
> @@ -1400,6 +1404,188 @@ int __weak arch_bpf_trampoline_size(const struct
> btf_func_model *m, u32 flags,
> return -ENOTSUPP;
> }
>
> +#if defined(CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS) &&
> defined(CONFIG_HAVE_SINGLE_FTRACE_DIRECT_OPS)
Hi, Jiri. It's great to see your tracing_multi link finally. It looks great ;)
After analyzing a little deeper on the SINGLE_FTRACE_DIRECT_OPS, I
understand why it is only supported on x86_64 for now. It seems that
it's a little hard to implement it in the other arch, as we need to
restructure the implement of ftrace direct call.
So do we need some more ftrace API here to make the tracing multi-link
independent from SINGLE_FTRACE_DIRECT_OPS? Otherwise, we can only
use it on x86_64.
Have you ever tried to implement the SINGLE_FTRACE_DIRECT_OPS on arm64?
The direct call on arm64 is so complex, and I didn't work it out :/
Thanks!
Menglong Dong
> +
> +struct fentry_multi_data {
> + struct ftrace_hash *unreg;
> + struct ftrace_hash *modify;
> + struct ftrace_hash *reg;
> +};
> +
[...]
>
>
>