On 2026/2/5 21:45, Jiri Olsa wrote: > On Thu, Feb 05, 2026 at 05:16:49PM +0800, Menglong Dong wrote: > > 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 > > ;) > > heya, thanks ;-) > > > > > 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. > > I tried to describe it in commit [2] changelog: > > At the moment we can enable this only on x86 arch, because arm relies > on ftrace_ops object representing just single trampoline image (stored > in ftrace_ops::direct_call). Archs that do not support this will continue > to use *_ftrace_direct api.
Ah, I didn't notice this part before. Thanks for the explain ;) > > > > > 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 :/ > > yes, it seems to be difficult atm, Mark commented on that in [1], > I don't know arm that good to be of much help in here, cc-ing Mark > > jirka > > > [1] https://lore.kernel.org/bpf/aIyNOd18TRLu8EpY@J2N7QTR9R3/ > [2] 424f6a361096 ("bpf,x86: Use single ftrace_ops for direct calls") > > > > > Thanks! > > Menglong Dong > > > > > + > > > +struct fentry_multi_data { > > > + struct ftrace_hash *unreg; > > > + struct ftrace_hash *modify; > > > + struct ftrace_hash *reg; > > > +}; > > > + > > [...] > > > > > > > > > > > > > > > > > >
