Re: [PATCH dwarves] btf_encoder: Ensure the first same-name function has a non-zero address

Alan Maguire <[email protected]>
Newsgroups org.kernel.vger.bpf,org.kernel.vger.dwarves
Message-ID <[email protected]>
On 28/07/2026 03:37, Yonghong Song wrote:
> 
> When true_signature is enabled, the same function can appear as two kinds
> of saved states: an inlined (abstract) instance that carries the original
> source signature with no address, and an out-of-line instance that carries
> the reconstructed true signature. saved_functions_combine() compares every
> same-name state in a group against the first (anchor) one and, when their
> prototypes differ, marks the function as having an inconsistent prototype.
> 
> Without this patch, the first same-name function may be an inlined instance
> whose prototype is the original source signature and thus differs from the
> true signature. The two prototypes are then flagged as inconsistent and,
> because --btf_features=+true_signature also enables the default
> consistent_func feature (skip_encoding_btf_inconsistent_proto), which drops
> functions flagged with an inconsistent prototype, the whole function is
> dropped from BTF. This primarily affects clang: its signature-changed
> functions keep their original name (no "." suffix), so state->sym is never
> set and they bypass btf_encoder__add_true_signature(), falling through to
> this canonical-state path.
> 
> With this patch, same-name functions are sorted so that, if any instance
> has a non-zero address, such an instance becomes the first (anchor). That
> addressed out-of-line instance is the one whose signature represents the
> true signature, so the consistency check compares real instances against
> each other and the function is retained in BTF with its true signature.
> 
> It is hard to create a test case where one function is inlined in one
> place and not inlined in another place. So I built the latest bpf-next
> kernel with
>   make LLVM=1 -j
> and then did
>   with master branch:
>     pahole -JV --btf_features=+true_signature vmlinux >& log.pahole.old
>   with this patch on top of master branch:
>     pahole -JV --btf_features=+true_signature vmlinux >& log.pahole.new
> and then get warning messages:
>   grep "skipping BTF encoding of function" log.pahole.old > log.old
>   grep "skipping BTF encoding of function" log.pahole.new > log.new
> and compare log.old and log.new
>   diff log.old log.new > log.diff
> 
> The following are some results:
>   --- log.old     2026-07-27 19:06:20.223881463 -0700
>   +++ log.new     2026-07-27 19:06:28.874109831 -0700
>   @@ -15,45 +15,28 @@
>    ZSTD_getCParams_internal : skipping BTF encoding of function due to unexpected register usage for parameter
>    ZSTD_getParams : skipping BTF encoding of function due to unexpected register usage for parameter
>    __ata_sff_port_intr : skipping BTF encoding of function due to unexpected register usage for parameter
>   -__build_flow_key : skipping BTF encoding of function due to param count mismatch; 9 params != 8 params
>   -__build_flow_key : skipping BTF encoding of function due to inconsistet prototype
>    __collect_tables : skipping BTF encoding of function due to ambiguous address
>    __fl_lookup : skipping BTF encoding of function due to return type mismatch
>    __fl_lookup : skipping BTF encoding of function due to ambiguous address
>    __in6_dev_get : skipping BTF encoding of function due to ambiguous address
>    __in_dev_get_rcu : skipping BTF encoding of function due to ambiguous address
>   -__instance_destroy : skipping BTF encoding of function due to param type mismatch for param#1 inst != inst
>   -__instance_destroy : skipping BTF encoding of function due to inconsistet prototype
>    __ioremap_caller : skipping BTF encoding of function due to unexpected register usage for parameter
>   -__ipmr_get_table : skipping BTF encoding of function due to param count mismatch; 2 params != 1 params
>   -__ipmr_get_table : skipping BTF encoding of function due to inconsistet prototype
>    __ipv6_neigh_lookup_noref : skipping BTF encoding of function due to ambiguous address
>    __key_get : skipping BTF encoding of function due to ambiguous address
>   -__kmem_cache_create : skipping BTF encoding of function due to param count mismatch; 5 params != 2 params
>   -__kmem_cache_create : skipping BTF encoding of function due to inconsistet prototype
>   -__kunmap_atomic : skipping BTF encoding of function due to param count mismatch; 1 params != 0 params
>   -__kunmap_atomic : skipping BTF encoding of function due to inconsistet prototype
>    __map_range : skipping BTF encoding of function due to ambiguous address
>    __map_range_leaf : skipping BTF encoding of function due to ambiguous address
>   -__map_single_page3 : skipping BTF encoding of function due to param count mismatch; 3 params != 4 params
>   -__map_single_page3 : skipping BTF encoding of function due to inconsistet prototype
>    __migrate_disable : skipping BTF encoding of function due to ambiguous address
>    __migrate_enable : skipping BTF encoding of function due to ambiguous address
>    __mod_tree_insert : skipping BTF encoding of function due to unexpected register usage for parameter
>    __mptcp_pm_send_ack : skipping BTF encoding of function due to unexpected register usage for parameter
>   +__neigh_lookup : skipping BTF encoding of function due to param count mismatch; 3 params != 2 params
>    __neigh_lookup : skipping BTF encoding of function due to ambiguous address
>   -__netdev_walk_all_lower_dev : skipping BTF encoding of function due to param count mismatch; 1 params != 3 params
>   -__netdev_walk_all_lower_dev : skipping BTF encoding of function due to inconsistet prototype
>    __pci_bus_set_current_state : skipping BTF encoding of function due to unexpected register usage for parameter
>    __pskb_trim : skipping BTF encoding of function due to ambiguous address
>    __release_region : skipping BTF encoding of function due to unexpected register usage for parameter
>    __remove_hrtimer : skipping BTF encoding of function due to unexpected register usage for parameter
>    __sk_dst_get : skipping BTF encoding of function due to ambiguous address
>    __skb_complete_tx_timestamp : skipping BTF encoding of function due to unexpected register usage for parameter
>   -__skb_gro_checksum_validate_complete : skipping BTF encoding of function due to param count mismatch; 2 params != 1 params
>   -__skb_gro_checksum_validate_complete : skipping BTF encoding of function due to inconsistet prototype
>   -__skb_gro_checksum_validate_needed : skipping BTF encoding of function due to param count mismatch; 3 params != 1 params
>   -__skb_gro_checksum_validate_needed : skipping BTF encoding of function due to inconsistet prototype
>    __task_rq_unlock : skipping BTF encoding of function due to unexpected register usage for parameter
>    __tracing_open : skipping BTF encoding of function due to unexpected register usage for parameter
>    __tty_buffer_request_room : skipping BTF encoding of function due to unexpected register usage for parameter
>   @@ -63,44 +46,28 @@
>   ...
> 
> With true signature enabled, this patch allows more BTF functions.
> 
> Signed-off-by: Yonghong Song <[email protected]>

Applied, thanks.

Alan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.