On Wed, May 10, 2023 at 1:18 AM Alexei Starovoitov <alexei.starovoitov@xxxxxxxxx> wrote: > > On Tue, May 9, 2023 at 8:36 AM Yafang Shao <laoar.shao@xxxxxxxxx> wrote: > > > > On Tue, May 2, 2023 at 11:40 AM Alexei Starovoitov > > <alexei.starovoitov@xxxxxxxxx> wrote: > > > > > > Alan, > > > > > > wdyt on below? > > > > > > > Hi Alexei, > > > > Per my understanding, not only does pahole have issues, but also there > > are issues in the kernel. > > This panic is caused by the inconsistency between BTF and kallsyms as such: > > bpf_check_attach_target > > tname = btf_name_by_offset(btf, t->name_off); // btf > > addr = kallsyms_lookup_name(tname); // kallsyms > > > > So if the function displayed in /proc/sys/btf/vmlinux is not the same > > with the function displayed in /proc/kallsyms, we will get a wrong > > addr. I think it is not proper to rely wholly on the userspace tools > > to make them the same. The kernel should also imrpve the verifier to > > make sure they are really the same function. WDYT? > > Are you saying it's not proper to rely on compilers > and linkers to build the kernel? > pahole, resolved_btfid, kallsym gen, objtool are part of the > compilation process. > The bugs in them are discovered from time to time and > have to be fixed. Just like compiler and linker bugs. I was wondering if it is possible to add BTF_ID into kallsyms or to add function address into BTF. Because the function name is not unique, while the function ID is unique. So with the function ID we can always get what we want. For example, $ cat /proc/kallsyms | awk '{if ($2=="t"||$2=="T") {print $3}}' | sort| uniq -c | sort -n -r | less 56 __pfx_cleanup_module 56 cleanup_module 47 __pfx_cpumask_weight.constprop.0 47 cpumask_weight.constprop.0 21 __pfx_jhash 21 __pfx_cpumask_weight 21 jhash 21 cpumask_weight 17 type_show 17 __pfx_type_show 14 __rhashtable_insert_fast.constprop.0 14 __pfx___rhashtable_insert_fast.constprop.0 12 __rhashtable_remove_fast_one.cold 12 __rhashtable_remove_fast_one 12 __pfx___rhashtable_remove_fast_one 11 __xfrm_policy_check2.constprop.0 11 __pfx___xfrm_policy_check2.constprop.0 11 __pfx_modalias_show 11 modalias_show 10 rht_key_get_hash.isra.0 10 __pfx_rht_key_get_hash.isra.0 10 __pfx_name_show 10 __pfx_init_once 10 name_show 10 init_once 9 __pfx_event_show 9 event_show 8 __pfx_dst_output 8 dst_output 7 state_show 7 size_show 7 __pfx_state_show 7 __pfx_size_show kallsyms_lookup_name() always returns the first function and ignores the others, so it is impossible to trace the other functions with the same name AFAIK. -- Regards Yafang