dwarf_loader: handle subprogram ret type with abstract_origin properly
PATCH 1/1 dwarf_loader: handle subprogram ret type with abstract_origin properly
With latest bpf-next built with clang lto (thin or full), I hit one test failures:
$ ./test_progs -t tcp ... libbpf: extern (func ksym) 'tcp_slow_start': func_proto [23] incompatible with kernel [115303] libbpf: failed to load object 'bpf_cubic' libbpf: failed to load BPF skeleton 'bpf_cubic': -22 test_cubic:FAIL:bpf_cubic__open_and_load failed #9/2 cubic:FAIL ...
The reason of the failure is due to bpf program 'tcp_slow_start' func signature is different from vmlinux BTF. bpf program uses the following signature:
extern __u32 tcp_slow_start(struct tcp_sock *tp, __u32 acked);
which is identical to the kernel definition in linux:include/net/tcp.h:
u32 tcp_slow_start(struct tcp_sock *tp, u32 acked);
While vmlinux BTF definition like:
[115303] FUNC_PROTO '(anon)' ret_type_id=0 vlen=2
'tp' type_id=39373
'acked' type_id=18 [115304] FUNC 'tcp_slow_start' type_id=115303 linkage=static
The above is dumped with bpftool btf dump file vmlinux. You can see the ret_type_id is 0 and this caused the problem.
Looking at dwarf, we have:
0x11f2ec67: DW_TAG_subprogram
DW_AT_low_pc (0xffffffff81ed2330)
DW_AT_high_pc (0xffffffff81ed235c)
DW_AT_frame_base ()
DW_AT_GNU_all_call_sites (true)
DW_AT_abstract_origin (0x11f2ed66 "tcp_slow_start")
...
0x11f2ed66: DW_TAG_subprogram
DW_AT_name ("tcp_slow_start")
DW_AT_decl_file ("/home/yhs/work/bpf-next/net/ipv4/tcp_cong.c")
DW_AT_decl_line (392)
DW_AT_prototyped (true)
DW_AT_type (0x11f130c2 "u32")
DW_AT_external (true)
DW_AT_inline (DW_INL_inlined)We have a subprogram which has an abstract_origin pointing to the subprogram prototype with return type. Current one pass recoding cannot easily resolve this easily since
at the time recoding for 0x11f2ec67, the return type in 0x11f2ed66 has not been resolved.
To simplify implementation, I just added another pass to go through all functions after recoding pass. This should resolve the above issue.
With this patch, among total 250999 functions in vmlinux, 4821 functions needs return type adjustment from type id 0 to correct values. The above failed bpf selftest passed too.
--- dwarf_loader.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
Arnaldo, this is the last known pahole bug in my hand w.r.t. clang LTO. With this, all self tests are passed except ones due to global function inlining, static variable promotion etc, which are not related to pahole.
dwarf_loader.c +46 -0
@@ -2198,6 +2198,42 @@ out:return 0 ; } +static int cu__resolve_func_ret_types (struct cu *cu) +{ +struct ptr_table *pt = &cu->functions_table; +uint32_t i; + +for (i =0 ; i < pt->nr_entries; ++i) { +struct tag *tag = pt->entries[i]; + +if (tag ==NULL || tag->type !=0 ) +continue ; + +struct function *fn =tag__function (tag); +if (!fn->abstract_origin) +continue ; + +struct dwarf_tag *dtag = tag->priv; +struct dwarf_tag *dfunc; + dfunc =dwarf_cu__find_tag_by_ref (cu->priv, &dtag->abstract_origin); +if (dfunc ==NULL ) { +tag__print_abstract_origin_not_found (tag); +return -1 ; + } + +/* +* Based on what I see it should be a subprogram, +* but double check anyway to ensure I won't mess up +* now and in the future. +*/ +if (dfunc->tag->tag != DW_TAG_subprogram) +continue ; + + tag->type = dfunc->tag->type; + } +return 0 ; +} +static int cu__recode_dwarf_types_table (struct cu *cu,struct ptr_table *pt,uint32_t i)
@@ -2637,6 +2673,16 @@ static int cus__merge_and_process_cu(struct cus *cus, struct conf_load *conf,/* process merged cu */ if (cu__recode_dwarf_types (cu) !=LSK__KEEPIT )return DWARF_CB_ABORT ; + +/* +* for lto build, the function return type may not be +* resolved due to the return type of a subprogram is +* encoded in another subprogram through abstract_origin +* tag. Let us visit all subprograms again to resolve this. +*/ +if (cu__resolve_func_ret_types (cu) !=LSK__KEEPIT ) +return DWARF_CB_ABORT ; +if (finalize_cu_immediately (cus, cu, dcu, conf) ==LSK__STOP_LOADING )return DWARF_CB_ABORT ;
Signature · 1 line
2.30.2
Quoted 28 lines · Yonghong Song
With latest bpf-next built with clang lto (thin or full), I hit one test failures:
$ ./test_progs -t tcp ... libbpf: extern (func ksym) 'tcp_slow_start': func_proto [23] incompatible with kernel [115303] libbpf: failed to load object 'bpf_cubic' libbpf: failed to load BPF skeleton 'bpf_cubic': -22 test_cubic:FAIL:bpf_cubic__open_and_load failed #9/2 cubic:FAIL ...The reason of the failure is due to bpf program '
tcp_slow_start' func signature is different from vmlinux BTF. bpf program uses the following signature:extern __u32 tcp_slow_start(struct tcp_sock *tp, __u32 acked); which is identical to the kernel definition in linux:include/net/tcp.h: u32 tcp_slow_start(struct tcp_sock *tp, u32 acked); While vmlinux BTF definition like: [115303] FUNC_PROTO '(anon)' ret_type_id=0 vlen=2 'tp' type_id=39373 'acked' type_id=18 [115304] FUNC 'tcp_slow_start' type_id=115303 linkage=staticThe above is dumped with
bpftool btf dump file vmlinux. You can see theret_type_idis 0 and this caused the problem.Looking at dwarf, we have:
0x11f2ec67:DW_TAG_subprogram
Quoted 14 lines
DW_AT_low_pc (0xffffffff81ed2330)
DW_AT_high_pc (0xffffffff81ed235c)
DW_AT_frame_base ()
DW_AT_GNU_all_call_sites (true)
DW_AT_abstract_origin (0x11f2ed66 "tcp_slow_start")
...
0x11f2ed66: DW_TAG_subprogram
DW_AT_name ("tcp_slow_start")
DW_AT_decl_file ("/home/yhs/work/bpf-next/net/ipv4/tcp_cong.c")
DW_AT_decl_line (392)
DW_AT_prototyped (true)
DW_AT_type (0x11f130c2 "u32")
DW_AT_external (true)
DW_AT_inline (DW_INL_inlined)David,
Could you help confirm whether DW_AT_abstract_origin at a DW_TAG_subprogram always points to another DW_TAG_subprogram, or there are possible other cases?
Thanks,
Quoted 90 lines
We have a subprogram which has an
abstract_originpointing to the subprogram prototype with return type. Current one pass recoding cannot easily resolve this easily since
at the time recoding for0x11f2ec67, the return type in0x11f2ed66has not been resolved.To simplify implementation, I just added another pass to go through all functions after recoding pass. This should resolve the above issue.
With this patch, among total 250999 functions in vmlinux, 4821 functions needs return type adjustment from type id 0 to correct values. The above failed bpf selftest passed too.
Signed-off-by Yonghong Song <[email protected]>--- dwarf_loader.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)Arnaldo, this is the last known pahole bug in my hand w.r.t. clang LTO. With this, all self tests are passed except ones due to global function inlining, static variable promotion etc, which are not related to pahole.
dwarf_loader.c +46
-0@@ -2198,6 +2198,42 @@ out:return 0 ; } +static int cu__resolve_func_ret_types (struct cu *cu) +{ +struct ptr_table *pt = &cu->functions_table; +uint32_t i; + +for (i =0 ; i < pt->nr_entries; ++i) { +struct tag *tag = pt->entries[i]; + +if (tag ==NULL || tag->type !=0 ) +continue ; + +struct function *fn =tag__function (tag); +if (!fn->abstract_origin) +continue ; + +struct dwarf_tag *dtag = tag->priv; +struct dwarf_tag *dfunc; + dfunc =dwarf_cu__find_tag_by_ref (cu->priv, &dtag->abstract_origin); +if (dfunc ==NULL ) { +tag__print_abstract_origin_not_found (tag); +return -1 ; + } + +/* +* Based on what I see it should be a subprogram, +* but double check anyway to ensure I won't mess up +* now and in the future. +*/ +if (dfunc->tag->tag != DW_TAG_subprogram) +continue ; + + tag->type = dfunc->tag->type; + } +return 0 ; +} +static int cu__recode_dwarf_types_table (struct cu *cu,struct ptr_table *pt,uint32_t i)@@ -2637,6 +2673,16 @@ static int cus__merge_and_process_cu(struct cus *cus, struct conf_load *conf,/* process merged cu */ if (cu__recode_dwarf_types (cu) !=LSK__KEEPIT )return DWARF_CB_ABORT ; + +/* +* for lto build, the function return type may not be +* resolved due to the return type of a subprogram is +* encoded in another subprogram through abstract_origin +* tag. Let us visit all subprograms again to resolve this. +*/ +if (cu__resolve_func_ret_types (cu) !=LSK__KEEPIT ) +return DWARF_CB_ABORT ; +if (finalize_cu_immediately (cus, cu, dcu, conf) ==LSK__STOP_LOADING )return DWARF_CB_ABORT ;
Quoted 47 lines · Yonghong Song
Quoted 28 lines · Yonghong Song
With latest bpf-next built with clang lto (thin or full), I hit one test failures:
$ ./test_progs -t tcp ... libbpf: extern (func ksym) 'tcp_slow_start': func_proto [23] incompatible with kernel [115303] libbpf: failed to load object 'bpf_cubic' libbpf: failed to load BPF skeleton 'bpf_cubic': -22 test_cubic:FAIL:bpf_cubic__open_and_load failed #9/2 cubic:FAIL ...The reason of the failure is due to bpf program '
tcp_slow_start' func signature is different from vmlinux BTF. bpf program uses the following signature:extern __u32 tcp_slow_start(struct tcp_sock *tp, __u32 acked); which is identical to the kernel definition in linux:include/net/tcp.h: u32 tcp_slow_start(struct tcp_sock *tp, u32 acked); While vmlinux BTF definition like: [115303] FUNC_PROTO '(anon)' ret_type_id=0 vlen=2 'tp' type_id=39373 'acked' type_id=18 [115304] FUNC 'tcp_slow_start' type_id=115303 linkage=staticThe above is dumped with
bpftool btf dump file vmlinux. You can see theret_type_idis 0 and this caused the problem.Looking at dwarf, we have:
0x11f2ec67:DW_TAG_subprogramQuoted 14 lines
DW_AT_low_pc (0xffffffff81ed2330) DW_AT_high_pc (0xffffffff81ed235c) DW_AT_frame_base () DW_AT_GNU_all_call_sites (true) DW_AT_abstract_origin (0x11f2ed66 "tcp_slow_start") ... 0x11f2ed66: DW_TAG_subprogram DW_AT_name ("tcp_slow_start") DW_AT_decl_file ("/home/yhs/work/bpf-next/net/ipv4/tcp_cong.c") DW_AT_decl_line (392) DW_AT_prototyped (true) DW_AT_type (0x11f130c2 "u32") DW_AT_external (true) DW_AT_inline (DW_INL_inlined)
Quoted 5 lines
David,
Could you help confirm whether
DW_AT_abstract_originat aDW_TAG_subprogramalways points to anotherDW_TAG_subprogram, or there are possible other cases?
That's correct, so far as I understand the spec, specifically DWARFv5 3.3.8.3 says:
"The root entry for a concrete out-of-line instance of a given inlined subroutine has the same tag as does its associated (abstract) inlined subroutine entry (that is, tag DW_TAG_subprogram rather than DW_TAG_inlined_subroutine)."
Though people may come up with novel uses of DWARF features. What would happen if this constraint were violated/what's your motivation for asking (I don't quite understand the connection between test_progs failure description, and this question)
- David
Quoted 93 lines
Thanks,
Quoted 90 lines
We have a subprogram which has an
abstract_originpointing to the subprogram prototype with return type. Current one pass recoding cannot easily resolve this easily since
at the time recoding for0x11f2ec67, the return type in0x11f2ed66has not been resolved.To simplify implementation, I just added another pass to go through all functions after recoding pass. This should resolve the above issue.
With this patch, among total 250999 functions in vmlinux, 4821 functions needs return type adjustment from type id 0 to correct values. The above failed bpf selftest passed too.
Signed-off-by Yonghong Song <[email protected]>--- dwarf_loader.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)Arnaldo, this is the last known pahole bug in my hand w.r.t. clang LTO. With this, all self tests are passed except ones due to global function inlining, static variable promotion etc, which are not related to pahole.
dwarf_loader.c +46
-0@@ -2198,6 +2198,42 @@ out:return 0 ; } +static int cu__resolve_func_ret_types (struct cu *cu) +{ +struct ptr_table *pt = &cu->functions_table; +uint32_t i; + +for (i =0 ; i < pt->nr_entries; ++i) { +struct tag *tag = pt->entries[i]; + +if (tag ==NULL || tag->type !=0 ) +continue ; + +struct function *fn =tag__function (tag); +if (!fn->abstract_origin) +continue ; + +struct dwarf_tag *dtag = tag->priv; +struct dwarf_tag *dfunc; + dfunc =dwarf_cu__find_tag_by_ref (cu->priv, &dtag->abstract_origin); +if (dfunc ==NULL ) { +tag__print_abstract_origin_not_found (tag); +return -1 ; + } + +/* +* Based on what I see it should be a subprogram, +* but double check anyway to ensure I won't mess up +* now and in the future. +*/ +if (dfunc->tag->tag != DW_TAG_subprogram) +continue ; + + tag->type = dfunc->tag->type; + } +return 0 ; +} +static int cu__recode_dwarf_types_table (struct cu *cu,struct ptr_table *pt,uint32_t i)@@ -2637,6 +2673,16 @@ static int cus__merge_and_process_cu(struct cus *cus, struct conf_load *conf,/* process merged cu */ if (cu__recode_dwarf_types (cu) !=LSK__KEEPIT )return DWARF_CB_ABORT ; + +/* +* for lto build, the function return type may not be +* resolved due to the return type of a subprogram is +* encoded in another subprogram through abstract_origin +* tag. Let us visit all subprograms again to resolve this. +*/ +if (cu__resolve_func_ret_types (cu) !=LSK__KEEPIT ) +return DWARF_CB_ABORT ; +if (finalize_cu_immediately (cus, cu, dcu, conf) ==LSK__STOP_LOADING )return DWARF_CB_ABORT ;
A message that is not in the archive (sent off-list or not yet received): CAENS6EsZ5OX9o=Cn5L1jmx8ucR9siEWbGYiYHCUWuZjLyP3E7Q@mail.gmail.com
Quoted 53 lines · David Blaikie
Quoted 5 lines · On Thu, Apr 1, 2021 at 2:41 PM Yonghong Song <[email protected] <mailto:[email protected]>>…
Quoted 1 line · Yonghong Song
With latest bpf-next built with clang lto (thin or full), I hit one
test
Quoted 4 lines
Quoted 4 lines
failures:
$ ./test_progs -t tcp ... libbpf: extern (func ksym) 'tcp_slow_start': func_proto [23]incompatible with kernel [115303]
Quoted 22 lines
Quoted 22 lines
libbpf: failed to load object '
bpf_cubic'
libbpf: failed to load BPF skeleton 'bpf_cubic': -22 test_cubic:FAIL:bpf_cubic__open_and_load failed #9/2 cubic:FAIL
...The reason of the failure is due to bpf program '
tcp_slow_start' func signature is different from vmlinux BTF. bpf program uses the following signature:
extern__u32tcp_slow_start(struct tcp_sock *tp, __u32 acked); which is identical to the kernel definition in linux:include/net/tcp.h:
u32tcp_slow_start(struct tcp_sock *tp, u32 acked);
While vmlinux BTF definition like:
[115303]FUNC_PROTO'(anon)' ret_type_id=0 vlen=2
'tp' type_id=39373
'acked' type_id=18
[115304] FUNC 'tcp_slow_start' type_id=115303 linkage=static The above is dumped withbpftool btf dump file vmlinux. You can see theret_type_idis 0 and this caused the problem.Looking at dwarf, we have:
Quoted 10 lines
Quoted 10 lines
0x11f2ec67:DW_TAG_subprogram
DW_AT_low_pc (0xffffffff81ed2330)DW_AT_high_pc(0xffffffff81ed235c)DW_AT_frame_base()DW_AT_GNU_all_call_sites(true)DW_AT_abstract_origin(0x11f2ed66"tcp_slow_start")
...0x11f2ed66:DW_TAG_subprogram
DW_AT_name ("tcp_slow_start")DW_AT_decl_file("
/home/yhs/work/bpf-next/net/ipv4/tcp_cong.c")Quoted 8 lines
Quoted 5 lines
DW_AT_decl_line (392)
DW_AT_prototyped(true)DW_AT_type(0x11f130c2 "u32")DW_AT_external(true)DW_AT_inline(DW_INL_inlined)David,
Quoted 7 lines
Quoted 3 lines
Could you help confirm whether
DW_AT_abstract_originat aDW_TAG_subprogramalways points to anotherDW_TAG_subprogram, or there are possible other cases?That's correct, so far as I understand the spec, specifically DWARFv5 <http://dwarfstd.org/doc/DWARF5.pdf> 3.3.8.3 says:
"The root entry for a concrete out-of-line instance of a given inlined subroutine has the same tag as does its associated (abstract) inlined subroutine entry (that is, tag
DW_TAG_subprogramrather thanDW_TAG_inlined_subroutine)."
Thanks. That means that some of my codes in the patch is dead code.
Quoted 2 lines
Though people may come up with novel uses of DWARF features. What would happen if this constraint were violated/what's your motivation for asking (I don't quite understand the connection between
test_progsfailure description, and this question)
I have some codes to check the tag associated with abstract_origin for a subprogram must be a subprogram. Through experiment, I didn't see a violation, so I wonder that I can get confirmation from you and then I may delete that code.
The test_progs failure exposed the bug, that is all.
pahole cannot handle all weird usages of dwarf, so I think pahole is fine only to support well-formed dwarf.
Quoted 98 lines
- David
Quoted 46 lines
Thanks,
Quoted 43 lines
We have a subprogram which has an
abstract_originpointing to the subprogram prototype with return type. Current one pass recoding cannot easily resolve this easily since
at the time recoding for0x11f2ec67, the return type in0x11f2ed66has not been resolved.To simplify implementation, I just added another pass to go through all functions after recoding pass. This should resolve the above issue.
With this patch, among total 250999 functions in vmlinux, 4821 functions needs return type adjustment from type id 0 to correct values. The above failed bpf selftest passed too.
Signed-off-by Yonghong Song <[email protected] <mailto:[email protected]>>---
dwarf_loader.c| 46 ++++++++++++++++++++++++++++++++++++++++++++++1 file changed, 46 insertions(+)Arnaldo, this is the last known pahole bug in my hand w.r.t. clang LTO. With this, all self tests are passed except ones due to global function inlining, static variable promotion etc, which are not related to pahole.
dwarf_loader.c +10
-0@@ -2198,6 +2198,42 @@ out: return 0; } +static int cu__resolve_func_ret_types (struct cu *cu) +{ + struct ptr_table *pt = &cu->functions_table; + uint32_t i; + + for (i = 0; i < pt->nr_entries; ++i) { + struct tag *tag = pt->entries[i]; + + if (tag == NULL || tag->type != 0) + continue;Quoted 8 lines
dwarf_loader.c out:
Quoted 8 lines
dwarf_loader.c +8
-0+ + struct function *fn = tag__function(tag); + if (!fn->abstract_origin) + continue; + + struct dwarf_tag *dtag = tag->priv; + struct dwarf_tag *dfunc; + dfunc = dwarf_cu__find_tag_by_ref(cu->priv,
&dtag->abstract_origin);Quoted 14 lines
Quoted 14 lines
dwarf_loader.c +14
-0+ if (dfunc == NULL) { + tag__print_abstract_origin_not_found(tag); + return -1; + } + + /* + * Based on what I see it should be a subprogram, + * but double check anyway to ensure I won't mess up + * now and in the future. + */ + if (dfunc->tag->tag != DW_TAG_subprogram) + continue; + + tag->type = dfunc->tag->type;Quoted 8 lines
dwarf_loader.c static int cus__merge_and_process_cu(struct
Quoted 8 lines
dwarf_loader.c +4
-0+ } + return 0; +} + static int cu__recode_dwarf_types_table(struct cu *cu, struct ptr_table *pt, uint32_t i)@@ -2637,6 +2673,16 @@ static int cus__merge_and_process_cu(structcus *cus, struct
conf_load*conf,Quoted 17 lines
Quoted 17 lines
dwarf_loader.c +10
-0/* process merged cu */ if (cu__recode_dwarf_types(cu) != LSK__KEEPIT) return DWARF_CB_ABORT; + + /* + * for lto build, the function return type may not be + * resolved due to the return type of a subprogram is + * encoded in another subprogram through abstract_origin + * tag. Let us visit all subprograms again to resolve this. + */ + if (cu__resolve_func_ret_types(cu) != LSK__KEEPIT) + return DWARF_CB_ABORT; + if (finalize_cu_immediately(cus, cu, dcu, conf) == LSK__STOP_LOADING) return DWARF_CB_ABORT;
Quoted 85 lines · Yonghong Song
Quoted 58 lines · David Blaikie
Quoted 5 lines · On Thu, Apr 1, 2021 at 2:41 PM Yonghong Song <[email protected] <mailto:[email protected]>>…
Quoted 1 line · Yonghong Song
With latest bpf-next built with clang lto (thin or full), I hit one
test
Quoted 4 lines
Quoted 4 lines
failures:
$ ./test_progs -t tcp ... libbpf: extern (func ksym) 'tcp_slow_start': func_proto [23]incompatible with kernel [115303]
Quoted 22 lines
Quoted 22 lines
libbpf: failed to load object '
bpf_cubic'
libbpf: failed to load BPF skeleton 'bpf_cubic': -22 test_cubic:FAIL:bpf_cubic__open_and_load failed #9/2 cubic:FAIL
...The reason of the failure is due to bpf program '
tcp_slow_start' func signature is different from vmlinux BTF. bpf program uses the following signature:extern __u32 tcp_slow_start(struct tcp_sock *tp, __u32 acked); which is identical to the kernel definition in linux:include/net/tcp.h: u32 tcp_slow_start(struct tcp_sock *tp, u32 acked); While vmlinux BTF definition like: [115303] FUNC_PROTO '(anon)' ret_type_id=0 vlen=2 'tp' type_id=39373 'acked' type_id=18 [115304] FUNC 'tcp_slow_start' type_id=115303 linkage=staticThe above is dumped with
bpftool btf dump file vmlinux. You can see theret_type_idis 0 and this caused the problem.Looking at dwarf, we have:
Quoted 10 lines
Quoted 10 lines
0x11f2ec67:DW_TAG_subprogramDW_AT_low_pc (0xffffffff81ed2330) DW_AT_high_pc (0xffffffff81ed235c) DW_AT_frame_base () DW_AT_GNU_all_call_sites (true) DW_AT_abstract_origin (0x11f2ed66 "tcp_slow_start")...
0x11f2ed66:DW_TAG_subprogram
DW_AT_name("tcp_slow_start")
DW_AT_decl_file("
/home/yhs/work/bpf-next/net/ipv4/tcp_cong.c")Quoted 11 lines
Quoted 5 lines
DW_AT_decl_line (392) DW_AT_prototyped (true) DW_AT_type (0x11f130c2 "u32") DW_AT_external (true) DW_AT_inline (DW_INL_inlined)David,
Could you help confirm whether
DW_AT_abstract_originat aDW_TAG_subprogramalways points to anotherDW_TAG_subprogram, or there are possible other cases?Quoted 8 lines
That's correct, so far as I understand the spec, specifically DWARFv5
<http://dwarfstd.org/doc/DWARF5.pdf>
3.3.8.3 says:"The root entry for a concrete out-of-line instance of a given inlined subroutine has the same tag as does its associated (abstract) inlined subroutine entry (that is, tag
DW_TAG_subprogramrather thanDW_TAG_inlined_subroutine)."Thanks. That means that some of my codes in the patch is dead code.
Quoted 5 lines
Though people may come up with novel uses of DWARF features. What would happen if this constraint were violated/what's your motivation for asking (I don't quite understand the connection between
test_progsfailure description, and this question)I have some codes to check the tag associated with
abstract_originfor a subprogram must be a subprogram. Through experiment, I didn't see a violation, so I wonder that I can get confirmation from you and then I may delete that code.
Quoted 4 lines
The
test_progsfailure exposed the bug, that is all.pahole cannot handle all weird usages of dwarf, so I think pahole is fine only to support well-formed dwarf.
Sounds good. Thanks for the context!
Quoted 99 lines
Quoted 99 lines
- David
Quoted 46 lines
Thanks,
Quoted 43 lines
We have a subprogram which has an
abstract_originpointing to the subprogram prototype with return type. Current one pass recoding cannot easily resolve this easily since
at the time recoding for0x11f2ec67, the return type in0x11f2ed66has not been resolved.To simplify implementation, I just added another pass to go through all functions after recoding pass. This should resolve the above issue.
With this patch, among total 250999 functions in vmlinux, 4821 functions needs return type adjustment from type id 0 to correct values. The above failed bpf selftest passed too.
Signed-off-by Yonghong Song <[email protected] <mailto:[email protected]>>--- dwarf_loader.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)Arnaldo, this is the last known pahole bug in my hand w.r.t. clang LTO. With this, all self tests are passed except ones due to global function inlining, static variable promotion etc, which are not related to pahole.
dwarf_loader.c +10
-0@@ -2198,6 +2198,42 @@ out:return 0 ; } +static int cu__resolve_func_ret_types (struct cu *cu) +{ +struct ptr_table *pt = &cu->functions_table; +uint32_t i; + +for (i =0 ; i < pt->nr_entries; ++i) { +struct tag *tag = pt->entries[i]; + +if (tag ==NULL || tag->type !=0 ) +continue ;Quoted 8 lines
dwarf_loader.c out:
Quoted 8 lines
dwarf_loader.c +8
-0+ +struct function *fn =tag__function (tag); +if (!fn->abstract_origin) +continue ; + +struct dwarf_tag *dtag = tag->priv; +struct dwarf_tag *dfunc; + dfunc = dwarf_cu__find_tag_by_ref(cu->priv,
&dtag->abstract_origin);Quoted 14 lines
Quoted 14 lines
dwarf_loader.c +14
-0+if (dfunc ==NULL ) { +tag__print_abstract_origin_not_found (tag); +return -1 ; + } + +/* +* Based on what I see it should be a subprogram, +* but double check anyway to ensure I won't mess up +* now and in the future. +*/ +if (dfunc->tag->tag != DW_TAG_subprogram) +continue ; + + tag->type = dfunc->tag->type;Quoted 8 lines
dwarf_loader.c static int cus__merge_and_process_cu(struct
Quoted 8 lines
dwarf_loader.c +4
-0+ } +return 0 ; +} +static int cu__recode_dwarf_types_table (struct cu *cu,struct ptr_table *pt,uint32_t i)@@ -2637,6 +2673,16 @@ static int cus__merge_and_process_cu(structcus *cus, struct
conf_load*conf,Quoted 17 lines
Quoted 17 lines
dwarf_loader.c +10
-0/* process merged cu */ if (cu__recode_dwarf_types (cu) !=LSK__KEEPIT )return DWARF_CB_ABORT ; + +/* +* for lto build, the function return type may not be +* resolved due to the return type of a subprogram is +* encoded in another subprogram through abstract_origin +* tag. Let us visit all subprograms again to resolve this. +*/ +if (cu__resolve_func_ret_types (cu) !=LSK__KEEPIT ) +return DWARF_CB_ABORT ; +if (finalize_cu_immediately (cus, cu, dcu, conf) ==LSK__STOP_LOADING )return DWARF_CB_ABORT ;
Em Thu, Apr 01, 2021 at 05:00:46PM -0700, David Blaikie escreveu:
Quoted 86 lines · Yonghong Song
Quoted 85 lines · David Blaikie
Quoted 58 lines
Quoted 5 lines · On Thu, Apr 1, 2021 at 2:41 PM Yonghong Song <[email protected] <mailto:[email protected]>>…
Quoted 1 line · Yonghong Song
With latest bpf-next built with clang lto (thin or full), I hit one
test
Quoted 4 lines
Quoted 4 lines
failures:
$ ./test_progs -t tcp ... libbpf: extern (func ksym) 'tcp_slow_start': func_proto [23]incompatible with kernel [115303]
Quoted 22 lines
Quoted 22 lines
libbpf: failed to load object '
bpf_cubic'
libbpf: failed to load BPF skeleton 'bpf_cubic': -22 test_cubic:FAIL:bpf_cubic__open_and_load failed #9/2 cubic:FAIL
...The reason of the failure is due to bpf program '
tcp_slow_start' func signature is different from vmlinux BTF. bpf program uses the following signature:extern __u32 tcp_slow_start(struct tcp_sock *tp, __u32 acked); which is identical to the kernel definition in linux:include/net/tcp.h: u32 tcp_slow_start(struct tcp_sock *tp, u32 acked); While vmlinux BTF definition like: [115303] FUNC_PROTO '(anon)' ret_type_id=0 vlen=2 'tp' type_id=39373 'acked' type_id=18 [115304] FUNC 'tcp_slow_start' type_id=115303 linkage=staticThe above is dumped with
bpftool btf dump file vmlinux. You can see theret_type_idis 0 and this caused the problem.Looking at dwarf, we have:
Quoted 10 lines
Quoted 10 lines
0x11f2ec67:DW_TAG_subprogramDW_AT_low_pc (0xffffffff81ed2330) DW_AT_high_pc (0xffffffff81ed235c) DW_AT_frame_base () DW_AT_GNU_all_call_sites (true) DW_AT_abstract_origin (0x11f2ed66 "tcp_slow_start")...
0x11f2ed66:DW_TAG_subprogram
DW_AT_name("tcp_slow_start")
DW_AT_decl_file("
/home/yhs/work/bpf-next/net/ipv4/tcp_cong.c")Quoted 11 lines
Quoted 5 lines
DW_AT_decl_line (392) DW_AT_prototyped (true) DW_AT_type (0x11f130c2 "u32") DW_AT_external (true) DW_AT_inline (DW_INL_inlined)David,
Could you help confirm whether
DW_AT_abstract_originat aDW_TAG_subprogramalways points to anotherDW_TAG_subprogram, or there are possible other cases?Quoted 8 lines
That's correct, so far as I understand the spec, specifically DWARFv5
<http://dwarfstd.org/doc/DWARF5.pdf>
3.3.8.3 says:"The root entry for a concrete out-of-line instance of a given inlined subroutine has the same tag as does its associated (abstract) inlined subroutine entry (that is, tag
DW_TAG_subprogramrather thanDW_TAG_inlined_subroutine)."Thanks. That means that some of my codes in the patch is dead code.
Quoted 5 lines
Though people may come up with novel uses of DWARF features. What would happen if this constraint were violated/what's your motivation for asking (I don't quite understand the connection between
test_progsfailure description, and this question)I have some codes to check the tag associated with
abstract_originfor a subprogram must be a subprogram. Through experiment, I didn't see a violation, so I wonder that I can get confirmation from you and then I may delete that code.
Quoted 6 lines
Quoted 4 lines
The
test_progsfailure exposed the bug, that is all.pahole cannot handle all weird usages of dwarf, so I think pahole is fine only to support well-formed dwarf.
Sounds good. Thanks for the context!
David, since you took the time to go thru the changes and to agree that Yonghong's fix is good, can I add a:
to this patch?
Maybe even a:
Thanks,
- Arnaldo
Quoted 99 lines
Quoted 99 lines
Quoted 99 lines
- David
Quoted 46 lines
Thanks,
Quoted 43 lines
We have a subprogram which has an
abstract_originpointing to the subprogram prototype with return type. Current one pass recoding cannot easily resolve this easily since
at the time recoding for0x11f2ec67, the return type in0x11f2ed66has not been resolved.To simplify implementation, I just added another pass to go through all functions after recoding pass. This should resolve the above issue.
With this patch, among total 250999 functions in vmlinux, 4821 functions needs return type adjustment from type id 0 to correct values. The above failed bpf selftest passed too.
Signed-off-by Yonghong Song <[email protected] <mailto:[email protected]>>--- dwarf_loader.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)Arnaldo, this is the last known pahole bug in my hand w.r.t. clang LTO. With this, all self tests are passed except ones due to global function inlining, static variable promotion etc, which are not related to pahole.
dwarf_loader.c +10
-0@@ -2198,6 +2198,42 @@ out:return 0 ; } +static int cu__resolve_func_ret_types (struct cu *cu) +{ +struct ptr_table *pt = &cu->functions_table; +uint32_t i; + +for (i =0 ; i < pt->nr_entries; ++i) { +struct tag *tag = pt->entries[i]; + +if (tag ==NULL || tag->type !=0 ) +continue ;Quoted 8 lines
dwarf_loader.c out:
Quoted 8 lines
dwarf_loader.c +8
-0+ +struct function *fn =tag__function (tag); +if (!fn->abstract_origin) +continue ; + +struct dwarf_tag *dtag = tag->priv; +struct dwarf_tag *dfunc; + dfunc = dwarf_cu__find_tag_by_ref(cu->priv,
&dtag->abstract_origin);Quoted 14 lines
Quoted 14 lines
dwarf_loader.c +14
-0+if (dfunc ==NULL ) { +tag__print_abstract_origin_not_found (tag); +return -1 ; + } + +/* +* Based on what I see it should be a subprogram, +* but double check anyway to ensure I won't mess up +* now and in the future. +*/ +if (dfunc->tag->tag != DW_TAG_subprogram) +continue ; + + tag->type = dfunc->tag->type;Quoted 8 lines
dwarf_loader.c static int cus__merge_and_process_cu(struct
Quoted 8 lines
dwarf_loader.c +4
-0+ } +return 0 ; +} +static int cu__recode_dwarf_types_table (struct cu *cu,struct ptr_table *pt,uint32_t i)@@ -2637,6 +2673,16 @@ static int cus__merge_and_process_cu(structcus *cus, struct
conf_load*conf,Quoted 17 lines
Quoted 17 lines
dwarf_loader.c +10
-0/* process merged cu */ if (cu__recode_dwarf_types (cu) !=LSK__KEEPIT )return DWARF_CB_ABORT ; + +/* +* for lto build, the function return type may not be +* resolved due to the return type of a subprogram is +* encoded in another subprogram through abstract_origin +* tag. Let us visit all subprograms again to resolve this. +*/ +if (cu__resolve_func_ret_types (cu) !=LSK__KEEPIT ) +return DWARF_CB_ABORT ; +if (finalize_cu_immediately (cus, cu, dcu, conf) ==LSK__STOP_LOADING )return DWARF_CB_ABORT ;
Signature · 1 line
- Arnaldo
Em Fri, Apr 02, 2021 at 11:04:18AM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 23 lines
Em Thu, Apr 01, 2021 at 05:00:46PM -0700, David Blaikie escreveu:
Quoted 12 lines · Yonghong Song
Quoted 10 lines · David Blaikie
Quoted 4 lines
Though people may come up with novel uses of DWARF features. What would happen if this constraint were violated/what's your motivation for asking (I don't quite understand the connection between
test_progsfailure description, and this question)I have some codes to check the tag associated with
abstract_originfor a subprogram must be a subprogram. Through experiment, I didn't see a violation, so I wonder that I can get confirmation from you and then I may delete that code.Quoted 6 lines
Quoted 4 lines
The
test_progsfailure exposed the bug, that is all.pahole cannot handle all weird usages of dwarf, so I think pahole is fine only to support well-formed dwarf.
Sounds good. Thanks for the context!
David, since you took the time to go thru the changes and to agree that Yonghong's fix is good, can I add a:
Quoted 7 lines
Acked-by David Blaikie <[email protected]>to this patch?
Maybe even a:
Reviewed-by David Blaikie <[email protected]>
What I have is at tmp.master, please take a look and check that everything is ok, the only think I wished to fix but I think can be left for later is in the tmp.master branch at:
git://git.kernel.org/pub/scm/devel/pahole/pahole.git tmp.master
I did some testing for this ret type fix:
https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?h=tmp.master
And for the LTO ELF notes:
The only remaining thing, which I think can be left for 1.22 is:
[acme@five pahole]$ btfdiff vmlinux.clang.thin.LTO
vmlinux.clang.thin.LTO vmlinux.clang.thin.LTO+ELF_note
[acme@five pahole]$ btfdiff vmlinux.clang.thin.LTO+ELF_note
tmp/btfdiff.btf.d3L3vy renamed from tmp/btfdiff.dwarf.CtLJpQ +3 -3
@@ -67255,7 +67255,7 @@ struct cpu_rmap { struct { u16 index; /* 16 2 */ u16 dist; /* 18 2 */ - } near[0]; /* 16 0 */ + } near[]; /* 16 0 */ /* size: 16, cachelines: 1, members: 5 */ /* last cacheline: 16 bytes */
@@ -101181,7 +101181,7 @@ struct linux_efi_memreserve { struct { phys_addr_t base; /* 16 8 */ phys_addr_t size; /* 24 8 */ - } entry[0]; /* 16 0 */ + } entry[]; /* 16 0 */ /* size: 16, cachelines: 1, members: 4 */ /* last cacheline: 16 bytes */
@@ -113516,7 +113516,7 @@ struct netlink_policy_dump_state { struct { const struct nla_policy * policy; /* 16 8 */ unsigned int maxtype; /* 24 4 */ - } policies[0]; /* 16 0 */ + } policies[]; /* 16 0 */ /* size: 16, cachelines: 1, members: 4 */ /* sum members: 12, holes: 1, sum holes: 4 */
[acme@five pahole]$
- Arnaldo
Quoted 30 lines · Arnaldo Carvalho de Melo
Em Fri, Apr 02, 2021 at 11:04:18AM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 28 lines
Em Thu, Apr 01, 2021 at 05:00:46PM -0700, David Blaikie escreveu:
Quoted 12 lines · Yonghong Song
Quoted 10 lines · David Blaikie
Quoted 4 lines
Though people may come up with novel uses of DWARF features. What would happen if this constraint were violated/what's your motivation for asking (I don't quite understand the connection between
test_progsfailure description, and this question)I have some codes to check the tag associated with
abstract_originfor a subprogram must be a subprogram. Through experiment, I didn't see a violation, so I wonder that I can get confirmation from you and then I may delete that code.Quoted 6 lines
Quoted 4 lines
The
test_progsfailure exposed the bug, that is all.pahole cannot handle all weird usages of dwarf, so I think pahole is fine only to support well-formed dwarf.
Sounds good. Thanks for the context!
David, since you took the time to go thru the changes and to agree that Yonghong's fix is good, can I add a:
Acked-by David Blaikie <[email protected]>to this patch?
Maybe even a:
Quoted 7 lines
Quoted 1 line
Reviewed-by David Blaikie <[email protected]>What I have is at tmp.master, please take a look and check that everything is ok, the only think I wished to fix but I think can be left for later is in the tmp.master branch at:
git://git.kernel.org/pub/scm/devel/pahole/pahole.gittmp.master
Thanks. I checked out the branch and did some testing with latest clang trunk (just pulled in).
With kernel LTO note support, I tested gcc non-lto, and llvm-lto mode, it works fine.
Without kernel LTO note support, I tested
gcc non-lto <=== ok
llvm non-lto <=== not ok
llvm lto <=== ok
Surprisingly llvm non-lto vmlinux had the same "tcp_slow_start" issue. Some previous version of clang does not have this issue.
I double checked the dwarfdump and it is indeed has the same reason for lto vmlinux. I checked abbrev section and there is no cross-cu references.
That means we need to adapt this patch
dwarf_loader: Handle subprogram ret type with abstract_origin properly
for non merging case as well.
The previous patch fixed lto subprogram abstract_origin issue, I will submit a followup patch for this.
Quoted 47 lines
I did some testing for this ret type fix:
https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?h=tmp.master
And for the LTO ELF notes:
The only remaining thing, which I think can be left for 1.22 is:
[acme@five pahole]$ btfdiff vmlinux.clang.thin.LTO
vmlinux.clang.thin.LTO vmlinux.clang.thin.LTO+ELF_note
[acme@five pahole]$ btfdiff vmlinux.clang.thin.LTO+ELF_notetmp/btfdiff.btf.d3L3vy renamed from tmp/btfdiff.dwarf.CtLJpQ +3
-3@@ -67255,7 +67255,7 @@ struct cpu_rmap { struct { u16 index; /* 16 2 */ u16 dist; /* 18 2 */ - } near[0]; /* 16 0 */ + } near[]; /* 16 0 */ /* size: 16, cachelines: 1, members: 5 */ /* last cacheline: 16 bytes */@@ -101181,7 +101181,7 @@ struct linux_efi_memreserve { struct { phys_addr_t base; /* 16 8 */ phys_addr_t size; /* 24 8 */ - } entry[0]; /* 16 0 */ + } entry[]; /* 16 0 */ /* size: 16, cachelines: 1, members: 4 */ /* last cacheline: 16 bytes */@@ -113516,7 +113516,7 @@ struct netlink_policy_dump_state { struct { const struct nla_policy * policy; /* 16 8 */ unsigned int maxtype; /* 24 4 */ - } policies[0]; /* 16 0 */ + } policies[]; /* 16 0 */ /* size: 16, cachelines: 1, members: 4 */ /* sum members: 12, holes: 1, sum holes: 4 */[acme@five pahole]$
- Arnaldo
Quoted 56 lines · Yonghong Song
Quoted 30 lines · Arnaldo Carvalho de Melo
Em Fri, Apr 02, 2021 at 11:04:18AM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 28 lines
Em Thu, Apr 01, 2021 at 05:00:46PM -0700, David Blaikie escreveu:
Quoted 12 lines · Yonghong Song
Quoted 10 lines · David Blaikie
Quoted 4 lines
Though people may come up with novel uses of DWARF features. What would happen if this constraint were violated/what's your motivation for asking (I don't quite understand the connection between
test_progsfailure description, and this question)I have some codes to check the tag associated with
abstract_originfor a subprogram must be a subprogram. Through experiment, I didn't see a violation, so I wonder that I can get confirmation from you and then I may delete that code.Quoted 6 lines
Quoted 4 lines
The
test_progsfailure exposed the bug, that is all.pahole cannot handle all weird usages of dwarf, so I think pahole is fine only to support well-formed dwarf.
Sounds good. Thanks for the context!
David, since you took the time to go thru the changes and to agree that Yonghong's fix is good, can I add a:
Acked-by David Blaikie <[email protected]>to this patch?
Maybe even a:
Quoted 7 lines
Quoted 1 line
Reviewed-by David Blaikie <[email protected]>What I have is at tmp.master, please take a look and check that everything is ok, the only think I wished to fix but I think can be left for later is in the tmp.master branch at:
git://git.kernel.org/pub/scm/devel/pahole/pahole.gittmp.masterThanks. I checked out the branch and did some testing with latest clang trunk (just pulled in).
With kernel LTO note support, I tested gcc non-lto, and llvm-lto mode, it works fine.
Without kernel LTO note support, I tested
gcc non-lto <=== ok
llvm non-lto <=== not ok
llvm lto <=== okSurprisingly llvm non-lto vmlinux had the same "
tcp_slow_start" issue. Some previous version of clang does not have this issue.
I double checked the dwarfdump and it is indeed has the same reason for lto vmlinux. I checked abbrev section and there is no cross-cu references.
Quoted 5 lines
That means we need to adapt this patch
dwarf_loader: Handle subprogram ret type withabstract_originproperly
for non merging case as well.
The previous patch fixed lto subprogramabstract_originissue, I will submit a followup patch for this.
Actually, the change is pretty simple,
dwarf_loader.c +5 -1
@@ -2323,7 +2323,11 @@ static int die__process_and_recode(Dwarf_Die *die, struct cu *cu)int ret =die__process (die, cu);if (ret !=0 )return ret; -return cu__recode_dwarf_types (cu); + ret =cu__recode_dwarf_types (cu); +if (ret !=0 ) +return ret; + +return cu__resolve_func_ret_types (cu); }
Arnaldo, do you just want to fold into previous patches, or you want me to submit a new one?
Quoted 50 lines
Quoted 50 lines
I did some testing for this ret type fix:
https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?h=tmp.master
And for the LTO ELF notes:
The only remaining thing, which I think can be left for 1.22 is:
[acme@five pahole]$ btfdiff vmlinux.clang.thin.LTO vmlinux.clang.thin.LTO vmlinux.clang.thin.LTO+ELF_note [acme@five pahole]$ btfdiff vmlinux.clang.thin.LTO+ELF_note
tmp/btfdiff.btf.d3L3vy 2021-04-02 11:55:09.925439277 -0300 renamed from tmp/btfdiff.dwarf.CtLJpQ 2021-04-02 11:55:09.658433186 -0300 +0
-0@@ -67255,7 +67255,7 @@ struct cpu_rmap { struct {u16 index; /* 16 2 */ u16 dist; /* 18 2 */ - } near[0]; /* 16 0 */
+ } near[]; /* 16 0 *//* size: 16, cachelines: 1, members: 5 */
/* last cacheline: 16 bytes */tmp/btfdiff.btf.d3L3vy 2021-04-02 11:55:09.925439277 -0300 renamed from tmp/btfdiff.dwarf.CtLJpQ 2021-04-02 11:55:09.658433186 -0300 +0
-0@@ -101181,7 +101181,7 @@ struct linux_efi_memreserve { struct {phys_addr_t base; /* 16 8 */ phys_addr_t size; /* 24 8 */ - } entry[0]; /* 16 0 */
+ } entry[]; /* 16 0 *//* size: 16, cachelines: 1, members: 4 */
/* last cacheline: 16 bytes */tmp/btfdiff.btf.d3L3vy 2021-04-02 11:55:09.925439277 -0300 renamed from tmp/btfdiff.dwarf.CtLJpQ 2021-04-02 11:55:09.658433186 -0300 +0
-0@@ -113516,7 +113516,7 @@ struct netlink_policy_dump_state { struct {const struct nla_policy * policy; /* 16 8 */ unsigned int maxtype; /* 24 4 */ - } policies[0]; /* 16 0 */
+ } policies[]; /* 16 0 *//* size: 16, cachelines: 1, members: 4 */ /* sum members: 12, holes: 1, sum holes: 4 */ [acme@five pahole]$
- Arnaldo
Quoted 1 line · Yonghong Song
On 4/2/21 10:23 AM, Yonghong Song wrote:
:> Thanks. I checked out the branch and did some testing with latest
Quoted 45 lines
clang
Quoted 3 lines
trunk (just pulled in).
With kernel LTO note support, I tested gcc non-lto, and llvm-lto
mode,
Quoted 8 lines
it works fine.
Without kernel LTO note support, I tested
gcc non-lto <=== ok
llvm non-lto <=== not ok
llvm lto <=== okSurprisingly llvm non-lto vmlinux had the same "
tcp_slow_start"issue.
Quoted 7 lines
Some previous version of clang does not have this issue. I double checked the dwarfdump and it is indeed has the same reason for lto vmlinux. I checked abbrev section and there is no cross-cu references.
That means we need to adapt this patch
dwarf_loader: Handle subprogram ret type withabstract_originproperly
Quoted 3 lines
for non merging case as well.
The previous patch fixed lto subprogramabstract_originissue, I will submit a followup patch for this.Actually, the change is pretty simple,
dwarf_loader.c +5
-1@@ -2323,7 +2323,11 @@ static int die__process_and_recode(Dwarf_Die *die, struct cu *cu)int ret =die__process (die, cu);if (ret !=0 )return ret; -return cu__recode_dwarf_types (cu); + ret =cu__recode_dwarf_types (cu); +if (ret !=0 ) +return ret; + +return cu__resolve_func_ret_types (cu); }
Quoted 2 lines
Arnaldo, do you just want to fold into previous patches, or you want me to submit a new one?
I can take care of that.
And I think it's time for to look at Jiri's test suite... :-)
It's a holiday here, so I'll take some time to get to this, hopefully I'll tag 1.21 tomorrow tho.
Cheers,
- Arnaldo
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Quoted 50 lines · Arnaldo
Quoted 1 line · Yonghong Song
On 4/2/21 10:23 AM, Yonghong Song wrote:
:> Thanks. I checked out the branch and did some testing with latest
Quoted 45 lines
clang
Quoted 3 lines
trunk (just pulled in).
With kernel LTO note support, I tested gcc non-lto, and llvm-lto
mode,
Quoted 8 lines
it works fine.
Without kernel LTO note support, I tested
gcc non-lto <=== ok
llvm non-lto <=== not ok
llvm lto <=== okSurprisingly llvm non-lto vmlinux had the same "
tcp_slow_start"issue.
Quoted 7 lines
Some previous version of clang does not have this issue. I double checked the dwarfdump and it is indeed has the same reason for lto vmlinux. I checked abbrev section and there is no cross-cu references.
That means we need to adapt this patch
dwarf_loader: Handle subprogram ret type withabstract_originproperly
Quoted 3 lines
for non merging case as well.
The previous patch fixed lto subprogramabstract_originissue, I will submit a followup patch for this.Actually, the change is pretty simple,
dwarf_loader.c +5
-1@@ -2323,7 +2323,11 @@ static int die__process_and_recode(Dwarf_Die *die, struct cu *cu)int ret =die__process (die, cu);if (ret !=0 )return ret; -return cu__recode_dwarf_types (cu); + ret =cu__recode_dwarf_types (cu); +if (ret !=0 ) +return ret; + +return cu__resolve_func_ret_types (cu); }
Quoted 8 lines
Quoted 2 lines
Arnaldo, do you just want to fold into previous patches, or you want me to submit a new one?
I can take care of that.
And I think it's time for to look at Jiri's test suite... :-)
It's a holiday here, so I'll take some time to get to this, hopefully I'll tag 1.21 tomorrow tho.
heya,
I did not follow this change, but if you put the latest change into some branch I can run it on top of that
jirka
Quoted 50 lines · Arnaldo
Quoted 1 line · Yonghong Song
On 4/2/21 10:23 AM, Yonghong Song wrote:
:> Thanks. I checked out the branch and did some testing with latest
Quoted 45 lines
clang
Quoted 3 lines
trunk (just pulled in).
With kernel LTO note support, I tested gcc non-lto, and llvm-lto
mode,
Quoted 8 lines
it works fine.
Without kernel LTO note support, I tested
gcc non-lto <=== ok
llvm non-lto <=== not ok
llvm lto <=== okSurprisingly llvm non-lto vmlinux had the same "
tcp_slow_start"issue.
Quoted 7 lines
Some previous version of clang does not have this issue. I double checked the dwarfdump and it is indeed has the same reason for lto vmlinux. I checked abbrev section and there is no cross-cu references.
That means we need to adapt this patch
dwarf_loader: Handle subprogram ret type withabstract_originproperly
Quoted 3 lines
for non merging case as well.
The previous patch fixed lto subprogramabstract_originissue, I will submit a followup patch for this.Actually, the change is pretty simple,
dwarf_loader.c +5
-1@@ -2323,7 +2323,11 @@ static int die__process_and_recode(Dwarf_Die *die, struct cu *cu)int ret =die__process (die, cu);if (ret !=0 )return ret; -return cu__recode_dwarf_types (cu); + ret =cu__recode_dwarf_types (cu); +if (ret !=0 ) +return ret; + +return cu__resolve_func_ret_types (cu); }
Quoted 8 lines
Quoted 2 lines
Arnaldo, do you just want to fold into previous patches, or you want me to submit a new one?
I can take care of that.
And I think it's time for to look at Jiri's test suite... :-)
It's a holiday here, so I'll take some time to get to this, hopefully I'll tag 1.21 tomorrow tho.
Thanks for taking care of this! Right, 1.21 looks very close.
Quoted 5 lines
Cheers,
- Arnaldo
Em Fri, Apr 02, 2021 at 12:41:47PM -0700, Yonghong Song escreveu:
Quoted 58 lines · Arnaldo
Quoted 55 lines · Yonghong Song
Quoted 1 line · Yonghong Song
:> Thanks. I checked out the branch and did some testing with latest
Quoted 45 lines
clang
Quoted 3 lines
trunk (just pulled in).
With kernel LTO note support, I tested gcc non-lto, and llvm-lto
mode,
Quoted 8 lines
it works fine.
Without kernel LTO note support, I tested
gcc non-lto <=== ok
llvm non-lto <=== not ok
llvm lto <=== okSurprisingly llvm non-lto vmlinux had the same "
tcp_slow_start"issue.
Quoted 7 lines
Some previous version of clang does not have this issue. I double checked the dwarfdump and it is indeed has the same reason for lto vmlinux. I checked abbrev section and there is no cross-cu references.
That means we need to adapt this patch
dwarf_loader: Handle subprogram ret type withabstract_originproperly
Quoted 3 lines
for non merging case as well.
The previous patch fixed lto subprogramabstract_originissue, I will submit a followup patch for this.Actually, the change is pretty simple,
dwarf_loader.c +5
-1@@ -2323,7 +2323,11 @@ static int die__process_and_recode(Dwarf_Die *die, struct cu *cu)int ret =die__process (die, cu);if (ret !=0 )return ret; -return cu__recode_dwarf_types (cu); + ret =cu__recode_dwarf_types (cu); +if (ret !=0 ) +return ret; + +return cu__resolve_func_ret_types (cu); }Quoted 2 lines
Arnaldo, do you just want to fold into previous patches, or you want me to submit a new one?
I can take care of that.
Quoted 5 lines
Quoted 3 lines
And I think it's time for to look at Jiri's test suite... :-)
It's a holiday here, so I'll take some time to get to this, hopefully I'll tag 1.21 tomorrow tho.
Thanks for taking care of this! Right, 1.21 looks very close.
So our HEAD now is this:
commit c03cd5c6ae0cec97d23edcf0a343bbff3df3c96a
Author: Yonghong Song <[email protected]> Date: Thu Apr 1 16:55:34 2021 -0700
dwarf_loader: Handle subprogram ret type with abstract_origin properly
With latest bpf-next built with clang LTO (thin or full), I hit one test
failures:
$ ./test_progs -t tcp
...
libbpf: extern (func ksym) 'tcp_slow_start': func_proto [23] incompatible with kernel [115303]
libbpf: failed to load object 'bpf_cubic'
libbpf: failed to load BPF skeleton 'bpf_cubic': -22
test_cubic:FAIL:bpf_cubic__open_and_load failed
#9/2 cubic:FAIL
...
The reason of the failure is due to bpf program 'tcp_slow_start' func
signature is different from vmlinux BTF. bpf program uses the following
signature:
extern __u32 tcp_slow_start(struct tcp_sock *tp, __u32 acked);
which is identical to the kernel definition in linux:include/net/tcp.h:
u32 tcp_slow_start(struct tcp_sock *tp, u32 acked);
While vmlinux BTF definition like:
[115303] FUNC_PROTO '(anon)' ret_type_id=0 vlen=2
'tp' type_id=39373
'acked' type_id=18
[115304] FUNC 'tcp_slow_start' type_id=115303 linkage=static
The above is dumped with `bpftool btf dump file vmlinux`.
You can see the ret_type_id is 0 and this caused the problem.
Looking at dwarf, we have:
0x11f2ec67: DW_TAG_subprogram
DW_AT_low_pc (0xffffffff81ed2330)
DW_AT_high_pc (0xffffffff81ed235c)
DW_AT_frame_base ()
DW_AT_GNU_all_call_sites (true)
DW_AT_abstract_origin (0x11f2ed66 "tcp_slow_start")
...
0x11f2ed66: DW_TAG_subprogram
DW_AT_name ("tcp_slow_start")
DW_AT_decl_file ("/home/yhs/work/bpf-next/net/ipv4/tcp_cong.c")
DW_AT_decl_line (392)
DW_AT_prototyped (true)
DW_AT_type (0x11f130c2 "u32")
DW_AT_external (true)
DW_AT_inline (DW_INL_inlined)
We have a subprogram which has an abstract_origin pointing to the
subprogram prototype with return type. Current one pass recoding cannot
easily resolve this easily since at the time recoding for 0x11f2ec67,
the return type in 0x11f2ed66 has not been resolved.
To simplify implementation, I just added another pass to go through all
functions after recoding pass. This should resolve the above issue.
With this patch, among total 250999 functions in vmlinux, 4821 functions
needs return type adjustment from type id 0 to correct values. The above
failed bpf selftest passed too.
Committer testing:
Before:
$ pfunct tcp_slow_start
void tcp_slow_start(struct tcp_sock * tp, u32 acked);
$
$ pfunct --prototypes /sys/kernel/btf/vmlinux > before
$ head before
int fb_is_primary_device(struct fb_info * info);
int arch_resume_nosmt(void);
int relocate_restore_code(void);
int arch_hibernation_header_restore(void * addr);
int get_e820_md5(struct e820_table * table, void * buf);
int arch_hibernation_header_save(void * addr, unsigned int max_size);
int pfn_is_nosave(long unsigned int pfn);
int swsusp_arch_resume(void);
int amd_bus_cpu_online(unsigned int cpu);
void pci_enable_pci_io_ecs(void);
$
After:
$ pfunct -F btf ../build/bpf_clang_thin_lto/vmlinux -f tcp_slow_start
u32 tcp_slow_start(struct tcp_sock * tp, u32 acked);
$
$ pfunct -F btf --prototypes ../build/bpf_clang_thin_lto/vmlinux > after
$
$ head after
int fb_is_primary_device(struct fb_info * info);
int arch_resume_nosmt(void);
int relocate_restore_code(void);
int arch_hibernation_header_restore(void * addr);
int get_e820_md5(struct e820_table * table, void * buf);
int arch_hibernation_header_save(void * addr, unsigned int max_size);
int pfn_is_nosave(long unsigned int pfn);
int swsusp_arch_resume(void);
int amd_bus_cpu_online(unsigned int cpu);
void pci_enable_pci_io_ecs(void);
$
$ diff -u before after | grep ^+ | wc -l
1604
$
$ diff -u before after | grep tcp_slow_start
-void tcp_slow_start(struct tcp_sock * tp, u32 acked);
+u32 tcp_slow_start(struct tcp_sock * tp, u32 acked);
$
$ diff -u before after | grep ^[+-] | head
--- before 2021-04-02 11:35:15.578160795 -0300
+++ after 2021-04-02 11:33:34.204847317 -0300
-void set_bf_sort(const struct dmi_system_id * d);
+int set_bf_sort(const struct dmi_system_id * d);
-void raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn, int reg, int len, u32 val);
-void raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn, int reg, int len, u32 * val);
+int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn, int reg, int len, u32 val);
+int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn, int reg, int len, u32 * val);
-void xen_find_device_domain_owner(struct pci_dev * dev);
+int xen_find_device_domain_owner(struct pci_dev * dev);
$
The same results are obtained if using /sys/kernel/btf/vmlinux after
rebooting with the kernel built from the ../build/bpf_clang_thin_lto/vmlinux
file used in the above 'after' examples.
Signed-off-by: Yonghong Song <[email protected]>
Tested-by: Arnaldo Carvalho de Melo <[email protected]>
Acked-by: David Blaikie <[email protected]>
Cc: Alexei Starovoitov <[email protected]>
Cc: Bill Wendling <[email protected]>
Cc: Nick Desaulniers <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>dwarf_loader.c +38 -0
@@ -2198,6 +2198,34 @@ out:return 0 ; } +static int cu__resolve_func_ret_types (struct cu *cu) +{ +struct ptr_table *pt = &cu->functions_table; +uint32_t i; + +for (i =0 ; i < pt->nr_entries; ++i) { +struct tag *tag = pt->entries[i]; + +if (tag ==NULL || tag->type !=0 ) +continue ; + +struct function *fn =tag__function (tag); +if (!fn->abstract_origin) +continue ; + +struct dwarf_tag *dtag = tag->priv; +struct dwarf_tag *dfunc; + dfunc =dwarf_cu__find_tag_by_ref (cu->priv, &dtag->abstract_origin); +if (dfunc ==NULL ) { +tag__print_abstract_origin_not_found (tag); +return -1 ; + } + + tag->type = dfunc->tag->type; + } +return 0 ; +} +static int cu__recode_dwarf_types_table (struct cu *cu,struct ptr_table *pt,uint32_t i)
@@ -2637,6 +2665,16 @@ static int cus__merge_and_process_cu(struct cus *cus, struct conf_load *conf,/* process merged cu */ if (cu__recode_dwarf_types (cu) !=LSK__KEEPIT )return DWARF_CB_ABORT ; + +/* +* for lto build, the function return type may not be +* resolved due to the return type of a subprogram is +* encoded in another subprogram through abstract_origin +* tag. Let us visit all subprograms again to resolve this. +*/ +if (cu__resolve_func_ret_types (cu) !=LSK__KEEPIT ) +return DWARF_CB_ABORT ; +if (finalize_cu_immediately (cus, cu, dcu, conf) ==LSK__STOP_LOADING )return DWARF_CB_ABORT ;
Quoted 60 lines · Arnaldo Carvalho de Melo
Em Fri, Apr 02, 2021 at 12:41:47PM -0700, Yonghong Song escreveu:
Quoted 59 lines · Arnaldo
Quoted 56 lines · Yonghong Song
Quoted 1 line · Yonghong Song
:> Thanks. I checked out the branch and did some testing with latest
Quoted 45 lines
clang
Quoted 3 lines
trunk (just pulled in).
With kernel LTO note support, I tested gcc non-lto, and llvm-lto
mode,
Quoted 8 lines
it works fine.
Without kernel LTO note support, I tested
gcc non-lto <=== ok
llvm non-lto <=== not ok
llvm lto <=== okSurprisingly llvm non-lto vmlinux had the same "
tcp_slow_start"issue.
Quoted 7 lines
Some previous version of clang does not have this issue. I double checked the dwarfdump and it is indeed has the same reason for lto vmlinux. I checked abbrev section and there is no cross-cu references.
That means we need to adapt this patch
dwarf_loader: Handle subprogram ret type withabstract_originproperly
Quoted 3 lines
for non merging case as well.
The previous patch fixed lto subprogramabstract_originissue, I will submit a followup patch for this.Actually, the change is pretty simple,
dwarf_loader.c +5
-1@@ -2323,7 +2323,11 @@ static int die__process_and_recode(Dwarf_Die *die, struct cu *cu)int ret =die__process (die, cu);if (ret !=0 )return ret; -return cu__recode_dwarf_types (cu); + ret =cu__recode_dwarf_types (cu); +if (ret !=0 ) +return ret; + +return cu__resolve_func_ret_types (cu); }Quoted 2 lines
Arnaldo, do you just want to fold into previous patches, or you want me to submit a new one?
I can take care of that.
And I think it's time for to look at Jiri's test suite... :-)
heya,
the test did not get change in generated BTF data with the change below, so looks good
jirka
Quoted 210 lines
Quoted 4 lines
Quoted 2 lines
It's a holiday here, so I'll take some time to get to this, hopefully I'll tag 1.21 tomorrow tho.
Thanks for taking care of this! Right, 1.21 looks very close.
So our HEAD now is this:
commit
c03cd5c6ae0cec97d23edcf0a343bbff3df3c96aAuthor: Yonghong Song <[email protected]> Date: Thu Apr 1 16:55:34 2021 -0700dwarf_loader: Handle subprogram ret type with abstract_origin properly With latest bpf-next built with clang LTO (thin or full), I hit one test failures: $ ./test_progs -t tcp ... libbpf: extern (func ksym) 'tcp_slow_start': func_proto [23] incompatible with kernel [115303] libbpf: failed to load object 'bpf_cubic' libbpf: failed to load BPF skeleton 'bpf_cubic': -22 test_cubic:FAIL:bpf_cubic__open_and_load failed #9/2 cubic:FAIL ... The reason of the failure is due to bpf program 'tcp_slow_start' func signature is different from vmlinux BTF. bpf program uses the following signature: extern __u32 tcp_slow_start(struct tcp_sock *tp, __u32 acked); which is identical to the kernel definition in linux:include/net/tcp.h: u32 tcp_slow_start(struct tcp_sock *tp, u32 acked); While vmlinux BTF definition like: [115303] FUNC_PROTO '(anon)' ret_type_id=0 vlen=2 'tp' type_id=39373 'acked' type_id=18 [115304] FUNC 'tcp_slow_start' type_id=115303 linkage=static The above is dumped with `bpftool btf dump file vmlinux`. You can see the ret_type_id is 0 and this caused the problem. Looking at dwarf, we have: 0x11f2ec67: DW_TAG_subprogram DW_AT_low_pc (0xffffffff81ed2330) DW_AT_high_pc (0xffffffff81ed235c) DW_AT_frame_base () DW_AT_GNU_all_call_sites (true) DW_AT_abstract_origin (0x11f2ed66 "tcp_slow_start") ... 0x11f2ed66: DW_TAG_subprogram DW_AT_name ("tcp_slow_start") DW_AT_decl_file ("/home/yhs/work/bpf-next/net/ipv4/tcp_cong.c") DW_AT_decl_line (392) DW_AT_prototyped (true) DW_AT_type (0x11f130c2 "u32") DW_AT_external (true) DW_AT_inline (DW_INL_inlined) We have a subprogram which has an abstract_origin pointing to the subprogram prototype with return type. Current one pass recoding cannot easily resolve this easily since at the time recoding for 0x11f2ec67, the return type in 0x11f2ed66 has not been resolved. To simplify implementation, I just added another pass to go through all functions after recoding pass. This should resolve the above issue. With this patch, among total 250999 functions in vmlinux, 4821 functions needs return type adjustment from type id 0 to correct values. The above failed bpf selftest passed too. Committer testing: Before: $ pfunct tcp_slow_start void tcp_slow_start(struct tcp_sock * tp, u32 acked); $ $ pfunct --prototypes /sys/kernel/btf/vmlinux > before $ head before int fb_is_primary_device(struct fb_info * info); int arch_resume_nosmt(void); int relocate_restore_code(void); int arch_hibernation_header_restore(void * addr); int get_e820_md5(struct e820_table * table, void * buf); int arch_hibernation_header_save(void * addr, unsigned int max_size); int pfn_is_nosave(long unsigned int pfn); int swsusp_arch_resume(void); int amd_bus_cpu_online(unsigned int cpu); void pci_enable_pci_io_ecs(void); $ After: $ pfunct -F btf ../build/bpf_clang_thin_lto/vmlinux -f tcp_slow_start u32 tcp_slow_start(struct tcp_sock * tp, u32 acked); $ $ pfunct -F btf --prototypes ../build/bpf_clang_thin_lto/vmlinux > after $ $ head after int fb_is_primary_device(struct fb_info * info); int arch_resume_nosmt(void); int relocate_restore_code(void); int arch_hibernation_header_restore(void * addr); int get_e820_md5(struct e820_table * table, void * buf); int arch_hibernation_header_save(void * addr, unsigned int max_size); int pfn_is_nosave(long unsigned int pfn); int swsusp_arch_resume(void); int amd_bus_cpu_online(unsigned int cpu); void pci_enable_pci_io_ecs(void); $ $ diff -u before after | grep ^+ | wc -l 1604 $ $ diff -u before after | grep tcp_slow_start -void tcp_slow_start(struct tcp_sock * tp, u32 acked); +u32 tcp_slow_start(struct tcp_sock * tp, u32 acked); $ $ diff -u before after | grep ^[+-] | head --- before 2021-04-02 11:35:15.578160795 -0300 +++ after 2021-04-02 11:33:34.204847317 -0300 -void set_bf_sort(const struct dmi_system_id * d); +int set_bf_sort(const struct dmi_system_id * d); -void raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn, int reg, int len, u32 val); -void raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn, int reg, int len, u32 * val); +int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn, int reg, int len, u32 val); +int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn, int reg, int len, u32 * val); -void xen_find_device_domain_owner(struct pci_dev * dev); +int xen_find_device_domain_owner(struct pci_dev * dev); $ The same results are obtained if using /sys/kernel/btf/vmlinux after rebooting with the kernel built from the ../build/bpf_clang_thin_lto/vmlinux file used in the above 'after' examples. Signed-off-by: Yonghong Song <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Acked-by: David Blaikie <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Bill Wendling <[email protected]> Cc: Nick Desaulniers <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>dwarf_loader.c +38
-0@@ -2198,6 +2198,34 @@ out:return 0 ; } +static int cu__resolve_func_ret_types (struct cu *cu) +{ +struct ptr_table *pt = &cu->functions_table; +uint32_t i; + +for (i =0 ; i < pt->nr_entries; ++i) { +struct tag *tag = pt->entries[i]; + +if (tag ==NULL || tag->type !=0 ) +continue ; + +struct function *fn =tag__function (tag); +if (!fn->abstract_origin) +continue ; + +struct dwarf_tag *dtag = tag->priv; +struct dwarf_tag *dfunc; + dfunc =dwarf_cu__find_tag_by_ref (cu->priv, &dtag->abstract_origin); +if (dfunc ==NULL ) { +tag__print_abstract_origin_not_found (tag); +return -1 ; + } + + tag->type = dfunc->tag->type; + } +return 0 ; +} +static int cu__recode_dwarf_types_table (struct cu *cu,struct ptr_table *pt,uint32_t i)@@ -2637,6 +2665,16 @@ static int cus__merge_and_process_cu(struct cus *cus, struct conf_load *conf,/* process merged cu */ if (cu__recode_dwarf_types (cu) !=LSK__KEEPIT )return DWARF_CB_ABORT ; + +/* +* for lto build, the function return type may not be +* resolved due to the return type of a subprogram is +* encoded in another subprogram through abstract_origin +* tag. Let us visit all subprograms again to resolve this. +*/ +if (cu__resolve_func_ret_types (cu) !=LSK__KEEPIT ) +return DWARF_CB_ABORT ; +if (finalize_cu_immediately (cus, cu, dcu, conf) ==LSK__STOP_LOADING )return DWARF_CB_ABORT ;
Quoted 50 lines · Arnaldo
Quoted 1 line · Yonghong Song
On 4/2/21 10:23 AM, Yonghong Song wrote:
:> Thanks. I checked out the branch and did some testing with latest
Quoted 45 lines
clang
Quoted 3 lines
trunk (just pulled in).
With kernel LTO note support, I tested gcc non-lto, and llvm-lto
mode,
Quoted 8 lines
it works fine.
Without kernel LTO note support, I tested
gcc non-lto <=== ok
llvm non-lto <=== not ok
llvm lto <=== okSurprisingly llvm non-lto vmlinux had the same "
tcp_slow_start"issue.
Quoted 7 lines
Some previous version of clang does not have this issue. I double checked the dwarfdump and it is indeed has the same reason for lto vmlinux. I checked abbrev section and there is no cross-cu references.
That means we need to adapt this patch
dwarf_loader: Handle subprogram ret type withabstract_originproperly
Quoted 3 lines
for non merging case as well.
The previous patch fixed lto subprogramabstract_originissue, I will submit a followup patch for this.Actually, the change is pretty simple,
dwarf_loader.c +5
-1@@ -2323,7 +2323,11 @@ static int die__process_and_recode(Dwarf_Die *die, struct cu *cu)int ret =die__process (die, cu);if (ret !=0 )return ret; -return cu__recode_dwarf_types (cu); + ret =cu__recode_dwarf_types (cu); +if (ret !=0 ) +return ret; + +return cu__resolve_func_ret_types (cu); }
Quoted 4 lines
Quoted 2 lines
Arnaldo, do you just want to fold into previous patches, or you want me to submit a new one?
I can take care of that.
Arnaldo, just in case that you missed it, please remember to fold the above changes to the patch:
[PATCH dwarves] dwarf_loader: handle subprogram ret type withabstract_origin properly
Thanks!
Quoted 9 lines
And I think it's time for to look at Jiri's test suite... :-)
It's a holiday here, so I'll take some time to get to this, hopefully I'll tag 1.21 tomorrow tho.
Cheers,
- Arnaldo
Em Wed, Apr 07, 2021 at 07:54:26AM -0700, Yonghong Song escreveu:
Quoted 54 lines · Arnaldo
Quoted 48 lines · Yonghong Song
Quoted 1 line · Yonghong Song
:> Thanks. I checked out the branch and did some testing with latest
Quoted 45 lines
clang
Quoted 3 lines
trunk (just pulled in).
With kernel LTO note support, I tested gcc non-lto, and llvm-lto
mode,
Quoted 8 lines
it works fine.
Without kernel LTO note support, I tested
gcc non-lto <=== ok
llvm non-lto <=== not ok
llvm lto <=== okSurprisingly llvm non-lto vmlinux had the same "
tcp_slow_start"issue.
Quoted 7 lines
Some previous version of clang does not have this issue. I double checked the dwarfdump and it is indeed has the same reason for lto vmlinux. I checked abbrev section and there is no cross-cu references.
That means we need to adapt this patch
dwarf_loader: Handle subprogram ret type withabstract_originproperly
Quoted 3 lines
for non merging case as well.
The previous patch fixed lto subprogramabstract_originissue, I will submit a followup patch for this.Actually, the change is pretty simple,
dwarf_loader.c +5
-1@@ -2323,7 +2323,11 @@ static int die__process_and_recode(Dwarf_Die *die, struct cu *cu)int ret =die__process (die, cu);if (ret !=0 )return ret; -return cu__recode_dwarf_types (cu); + ret =cu__recode_dwarf_types (cu); +if (ret !=0 ) +return ret; + +return cu__resolve_func_ret_types (cu); }Quoted 4 lines
Quoted 2 lines
Arnaldo, do you just want to fold into previous patches, or you want me to submit a new one?
I can take care of that.
Quoted 5 lines
Arnaldo, just in case that you missed it, please remember to fold the above changes to the patch:
[PATCH dwarves]dwarf_loader: handle subprogram ret type withabstract_originproperly
Thanks!
Its there, I did it Sunday, IIRC:
@@ -2295,7 +2323,11 @@ static int die__process_and_recode(Dwarf_Die *die, struct cu *cu)
int ret = die__process(die, cu);
if (ret != 0)
return ret;
- return cu__recode_dwarf_types(cu);
+ ret = cu__recode_dwarf_types(cu);
+ if (ret != 0)
+ return ret;
+
+ return cu__resolve_func_ret_types(cu);
}
static int class_member__cache_byte_size(struct tag *tag, struct cu *cu,
----
My latest tests were all with it in place.
- Arnaldo
Quoted 9 lines
Quoted 9 lines
And I think it's time for to look at Jiri's test suite... :-)
It's a holiday here, so I'll take some time to get to this, hopefully I'll tag 1.21 tomorrow tho.
Cheers,
- Arnaldo
Signature · 1 line
- Arnaldo
[RFT] prepping up pahole 1.21, wanna test it? was Re: [PATCH dwarves] dwarf_loader: handle subprogram ret type with abstract_origin properly
Em Wed, Apr 07, 2021 at 12:37:09PM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 10 lines
Em Wed, Apr 07, 2021 at 07:54:26AM -0700, Yonghong Song escreveu:
Quoted 5 lines
Arnaldo, just in case that you missed it, please remember to fold the above changes to the patch:
[PATCH dwarves]dwarf_loader: handle subprogram ret type withabstract_originproperly
Thanks!Its there, I did it Sunday, IIRC:
So I pushed it all to the master branch, hopefully some more people may feel encouraged to give it a try for the various things it fixes since 1.20:
[acme@quaco pahole]$ git log --oneline v1.20..ae0b7dde1fd50b12 (HEAD -> master, origin/tmp.master, origin/master, origin/HEAD, github/master, five/master, acme.korg/tmp.master, acme.korg/master) dwarf_loader: Handle DWARF5 DW_OP_addrx properly 9adb014930f31c66 dwarf_loader: Handle subprogram ret type with abstract_origin properly5752d1951d081a80 dwarf_loader: Check .notes section for LTO build info209e45424ff4a22d dwarf_loader: Check .debug_abbrev for cross-CU references39227909db3cc2c2 dwarf_loader: Permit merging all DWARF CU's for clang LTO built binary763475ca1101ccfe dwarf_loader: Factor out common code to initialize a cud0d3fbd4744953e8 dwarf_loader: Permit a flexible HASHTAGS__BITSffe0ef4d73906c18 btf: Add --btf_gen_all flagde708b33114d42c2 btf: Add support for the floating-point types4b7f8c04d009942b fprintf: Honour conf_fprintf.hex when printing enumerationsf2889ff163726336 Avoid warning when building with NDEBUG8e1f8c904e303d5d btf_encoder: Match ftrace addresses within ELF functions9fecc77ed82d429f dwarf_loader: Use a better hashing function, from libbpf0125de3a4c055cdf btf_encoder: Funnel ELF error reporting through a macro7d8e829f636f47ab btf_encoder: Sanitize non-regular int base type
[acme@quaco pahole]$
- Arnaldo
Re: [RFT] prepping up pahole 1.21, wanna test it? was Re: [PATCH dwarves] dwarf_loader: handle subprogram ret type with abstract_origin properly
Quoted 25 lines · Arnaldo Carvalho de Melo
Em Wed, Apr 07, 2021 at 12:37:09PM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 10 lines
Em Wed, Apr 07, 2021 at 07:54:26AM -0700, Yonghong Song escreveu:
Quoted 5 lines
Arnaldo, just in case that you missed it, please remember to fold the above changes to the patch:
[PATCH dwarves]dwarf_loader: handle subprogram ret type withabstract_originproperly
Thanks!Its there, I did it Sunday, IIRC:
So I pushed it all to the master branch, hopefully some more people may feel encouraged to give it a try for the various things it fixes since 1.20:
[acme@quaco pahole]$ git log --oneline v1.20..
ae0b7dde1fd50b12(HEAD -> master, origin/tmp.master, origin/master, origin/HEAD, github/master, five/master, acme.korg/tmp.master, acme.korg/master)dwarf_loader: Handle DWARF5DW_OP_addrxproperly9adb014930f31c66dwarf_loader: Handle subprogram ret type withabstract_originproperly5752d1951d081a80dwarf_loader: Check .notes section for LTO build info209e45424ff4a22ddwarf_loader: Check .debug_abbrev for cross-CU references39227909db3cc2c2dwarf_loader: Permit merging all DWARF CU's for clang LTO built binary763475ca1101ccfedwarf_loader: Factor out common code to initialize a cud0d3fbd4744953e8dwarf_loader: Permit a flexibleHASHTAGS__BITSffe0ef4d73906c18btf: Add --btf_gen_all flag
Quoted 8 lines
de708b33114d42c2btf: Add support for the floating-point types4b7f8c04d009942bfprintf: Honour conf_fprintf.hex when printing enumerationsf2889ff163726336Avoid warning when building with NDEBUG8e1f8c904e303d5dbtf_encoder: Match ftrace addresses within ELF functions9fecc77ed82d429fdwarf_loader: Use a better hashing function, from libbpf0125de3a4c055cdfbtf_encoder: Funnel ELF error reporting through a macro7d8e829f636f47abbtf_encoder: Sanitize non-regular int base type [acme@quaco pahole]$
I tested with llvm-project "main" branch and latest bpf-next. clang non-lto, dwarf4/5: okay
clang thin-lto, dwarf4/5: okay
gcc (8.4.1, non-lto, default dwarf4): okay
So pahole looks good. Thanks!
Quoted 3 lines
- Arnaldo
Re: [RFT] prepping up pahole 1.21, wanna test it? was Re: [PATCH dwarves] dwarf_loader: handle subprogram ret type with abstract_origin properly
Em Wed, Apr 07, 2021 at 03:53:32PM -0700, Yonghong Song escreveu:
Quoted 37 lines · Arnaldo Carvalho de Melo
Quoted 25 lines
Em Wed, Apr 07, 2021 at 12:37:09PM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 10 lines
Em Wed, Apr 07, 2021 at 07:54:26AM -0700, Yonghong Song escreveu:
Quoted 5 lines
Arnaldo, just in case that you missed it, please remember to fold the above changes to the patch:
[PATCH dwarves]dwarf_loader: handle subprogram ret type withabstract_originproperly
Thanks!Its there, I did it Sunday, IIRC:
So I pushed it all to the master branch, hopefully some more people may feel encouraged to give it a try for the various things it fixes since 1.20:
[acme@quaco pahole]$ git log --oneline v1.20..
ae0b7dde1fd50b12(HEAD -> master, origin/tmp.master, origin/master, origin/HEAD, github/master, five/master, acme.korg/tmp.master, acme.korg/master)dwarf_loader: Handle DWARF5DW_OP_addrxproperly9adb014930f31c66dwarf_loader: Handle subprogram ret type withabstract_originproperly5752d1951d081a80dwarf_loader: Check .notes section for LTO build info209e45424ff4a22ddwarf_loader: Check .debug_abbrev for cross-CU references39227909db3cc2c2dwarf_loader: Permit merging all DWARF CU's for clang LTO built binary763475ca1101ccfedwarf_loader: Factor out common code to initialize a cud0d3fbd4744953e8dwarf_loader: Permit a flexibleHASHTAGS__BITSffe0ef4d73906c18btf: Add --btf_gen_all flagQuoted 8 lines
de708b33114d42c2btf: Add support for the floating-point types4b7f8c04d009942bfprintf: Honour conf_fprintf.hex when printing enumerationsf2889ff163726336Avoid warning when building with NDEBUG8e1f8c904e303d5dbtf_encoder: Match ftrace addresses within ELF functions9fecc77ed82d429fdwarf_loader: Use a better hashing function, from libbpf0125de3a4c055cdfbtf_encoder: Funnel ELF error reporting through a macro7d8e829f636f47abbtf_encoder: Sanitize non-regular int base type [acme@quaco pahole]$
Quoted 6 lines
I tested with llvm-project "main" branch and latest bpf-next. clang non-lto, dwarf4/5: okay
clang thin-lto, dwarf4/5: okay
gcc (8.4.1, non-lto, default dwarf4): okaySo pahole looks good. Thanks!
Thanks a lot, in time for a friday release! :-)
- Arnaldo
Re: [RFT] prepping up pahole 1.21, wanna test it? was Re: [PATCH dwarves] dwarf_loader: handle subprogram ret type with abstract_origin properly
In reply to Arnaldo Carvalho de MeloQuoted 8 lines · Arnaldo Carvalho de Melo
Em Wed, Apr 07, 2021 at 12:37:09PM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 7 lines
Em Wed, Apr 07, 2021 at 07:54:26AM -0700, Yonghong Song escreveu:
Quoted 5 lines
Arnaldo, just in case that you missed it, please remember to fold the above changes to the patch:
[PATCH dwarves]dwarf_loader: handle subprogram ret type withabstract_originproperly
Thanks!
Quoted 7 lines
Quoted 3 lines
Its there, I did it Sunday, IIRC:
So I pushed it all to the master branch, hopefully some more people may feel encouraged to give it a try for the various things it fixes since 1.20:
heya,
the test script passed
jirka
Quoted 21 lines
[acme@quaco pahole]$ git log --oneline v1.20..
ae0b7dde1fd50b12(HEAD -> master, origin/tmp.master, origin/master, origin/HEAD, github/master, five/master, acme.korg/tmp.master, acme.korg/master)dwarf_loader: Handle DWARF5DW_OP_addrxproperly9adb014930f31c66dwarf_loader: Handle subprogram ret type withabstract_originproperly5752d1951d081a80dwarf_loader: Check .notes section for LTO build info209e45424ff4a22ddwarf_loader: Check .debug_abbrev for cross-CU references39227909db3cc2c2dwarf_loader: Permit merging all DWARF CU's for clang LTO built binary763475ca1101ccfedwarf_loader: Factor out common code to initialize a cud0d3fbd4744953e8dwarf_loader: Permit a flexibleHASHTAGS__BITSffe0ef4d73906c18btf: Add --btf_gen_all flagde708b33114d42c2btf: Add support for the floating-point types4b7f8c04d009942bfprintf: Honour conf_fprintf.hex when printing enumerationsf2889ff163726336Avoid warning when building with NDEBUG8e1f8c904e303d5dbtf_encoder: Match ftrace addresses within ELF functions9fecc77ed82d429fdwarf_loader: Use a better hashing function, from libbpf0125de3a4c055cdfbtf_encoder: Funnel ELF error reporting through a macro7d8e829f636f47abbtf_encoder: Sanitize non-regular int base type
[acme@quaco pahole]$- Arnaldo
Re: [RFT] prepping up pahole 1.21, wanna test it? was Re: [PATCH dwarves] dwarf_loader: handle subprogram ret type with abstract_origin properly
Em Thu, Apr 08, 2021 at 11:23:32PM +0200, Jiri Olsa escreveu:
Quoted 11 lines · Arnaldo Carvalho de Melo
Quoted 10 lines
Em Wed, Apr 07, 2021 at 12:37:09PM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 9 lines
Em Wed, Apr 07, 2021 at 07:54:26AM -0700, Yonghong Song escreveu:
Quoted 5 lines
Arnaldo, just in case that you missed it, please remember to fold the above changes to the patch:
[PATCH dwarves]dwarf_loader: handle subprogram ret type withabstract_originproperly
Thanks!Its there, I did it Sunday, IIRC:
Quoted 8 lines
Quoted 5 lines
So I pushed it all to the master branch, hopefully some more people may feel encouraged to give it a try for the various things it fixes since 1.20:
heya,
the test script passed
Thanks a lot for testing!
- Arnaldo
Quoted 24 lines
jirka
Quoted 21 lines
[acme@quaco pahole]$ git log --oneline v1.20..
ae0b7dde1fd50b12(HEAD -> master, origin/tmp.master, origin/master, origin/HEAD, github/master, five/master, acme.korg/tmp.master, acme.korg/master)dwarf_loader: Handle DWARF5DW_OP_addrxproperly9adb014930f31c66dwarf_loader: Handle subprogram ret type withabstract_originproperly5752d1951d081a80dwarf_loader: Check .notes section for LTO build info209e45424ff4a22ddwarf_loader: Check .debug_abbrev for cross-CU references39227909db3cc2c2dwarf_loader: Permit merging all DWARF CU's for clang LTO built binary763475ca1101ccfedwarf_loader: Factor out common code to initialize a cud0d3fbd4744953e8dwarf_loader: Permit a flexibleHASHTAGS__BITSffe0ef4d73906c18btf: Add --btf_gen_all flagde708b33114d42c2btf: Add support for the floating-point types4b7f8c04d009942bfprintf: Honour conf_fprintf.hex when printing enumerationsf2889ff163726336Avoid warning when building with NDEBUG8e1f8c904e303d5dbtf_encoder: Match ftrace addresses within ELF functions9fecc77ed82d429fdwarf_loader: Use a better hashing function, from libbpf0125de3a4c055cdfbtf_encoder: Funnel ELF error reporting through a macro7d8e829f636f47abbtf_encoder: Sanitize non-regular int base type
[acme@quaco pahole]$- Arnaldo
Signature · 1 line
- Arnaldo
Quoted 70 lines · Arnaldo Carvalho de Melo
Em Wed, Apr 07, 2021 at 07:54:26AM -0700, Yonghong Song escreveu:
Quoted 54 lines · Arnaldo
Quoted 48 lines · Yonghong Song
Quoted 1 line · Yonghong Song
:> Thanks. I checked out the branch and did some testing with latest
Quoted 45 lines
clang
Quoted 3 lines
trunk (just pulled in).
With kernel LTO note support, I tested gcc non-lto, and llvm-lto
mode,
Quoted 8 lines
it works fine.
Without kernel LTO note support, I tested
gcc non-lto <=== ok
llvm non-lto <=== not ok
llvm lto <=== okSurprisingly llvm non-lto vmlinux had the same "
tcp_slow_start"issue.
Quoted 7 lines
Some previous version of clang does not have this issue. I double checked the dwarfdump and it is indeed has the same reason for lto vmlinux. I checked abbrev section and there is no cross-cu references.
That means we need to adapt this patch
dwarf_loader: Handle subprogram ret type withabstract_originproperly
Quoted 3 lines
for non merging case as well.
The previous patch fixed lto subprogramabstract_originissue, I will submit a followup patch for this.Actually, the change is pretty simple,
dwarf_loader.c +5
-1@@ -2323,7 +2323,11 @@ static int die__process_and_recode(Dwarf_Die *die, struct cu *cu)int ret =die__process (die, cu);if (ret !=0 )return ret; -return cu__recode_dwarf_types (cu); + ret =cu__recode_dwarf_types (cu); +if (ret !=0 ) +return ret; + +return cu__resolve_func_ret_types (cu); }Quoted 4 lines
Quoted 2 lines
Arnaldo, do you just want to fold into previous patches, or you want me to submit a new one?
I can take care of that.
Quoted 5 lines
Arnaldo, just in case that you missed it, please remember to fold the above changes to the patch:
[PATCH dwarves]dwarf_loader: handle subprogram ret type withabstract_originproperly
Thanks!Its there, I did it Sunday, IIRC:
dwarf_loader.c +0
-1@@ -2295,7 +2323,11 @@ static int die__process_and_recode(Dwarf_Die *die, struct cu *cu)int ret =die__process (die, cu);if (ret !=0 )return ret; -return cu__recode_dwarf_types (cu);
dwarf_loader.c static int die__process_and_recode(Dwarf_Die *die, struct cu *cu)
Quoted 10 lines
dwarf_loader.c +5
-1+ ret =cu__recode_dwarf_types (cu); +if (ret !=0 ) +return ret; + +return cu__resolve_func_ret_types (cu); } static int class_member__cache_byte_size(struct tag *tag, struct cu *cu, ----
Thanks! I just saw it in the master branch now. Somehow I did not see it in tmp.master branch yesterday and I don't know why.
Quoted 15 lines
My latest tests were all with it in place.
- Arnaldo
Quoted 9 lines
Quoted 9 lines
And I think it's time for to look at Jiri's test suite... :-)
It's a holiday here, so I'll take some time to get to this, hopefully I'll tag 1.21 tomorrow tho.
Cheers,
- Arnaldo