Re: [PATCH v2 dwarves 1/4] btf_encoder: refactor btf_encoder__tag_kfuncs()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2025-02-12 at 12:15 -0800, Ihor Solodrai wrote:
> btf_encoder__tag_kfuncs() is a post-processing step of BTF encoding,
> executed right before BTF is deduped and dumped to the output.
> 
> Rewrite btf_encoder__tag_kfuncs() into btf_encoder__collect_kfuncs().
> Now it only reads the .BTF_ids section of the ELF, collecting kfunc
> information and adding it to corresponding elf_function structs. It is
> executed in btf_encoder__new() if tag_kfuncs flag is set. This way
> kfunc information is available within entire lifetime of the
> btf_encoder.
> 
> BTF decl tags for kfuncs are added immediately after the function is
> added to BTF in btf_encoder__add_func(). It's done by btf__tag_kfunc()
> factored out from the btf_encoder__tag_kfunc().
> 
> As a result btf_encoder__tag_kfuncs(), its subroutines and struct

Nit: btf_encoder__collect_btf_funcs() is the one removed,
     btf_encoder__tag_kfuncs is renamed.

> btf_func type are deleted, as they are no longer necessary.
> 
> Link: https://lore.kernel.org/dwarves/3782640a577e6945c86d6330bc8a05018a1e5c52.camel@xxxxxxxxx/
> 
> Suggested-by: Eduard Zingerman <eddyz87@xxxxxxxxx>
> Signed-off-by: Ihor Solodrai <ihor.solodrai@xxxxxxxxx>
> ---

Acked-by: Eduard Zingerman <eddyz87@xxxxxxxxx>

[...]

>  btf_encoder.c | 192 +++++++++++++++-----------------------------------
>  1 file changed, 57 insertions(+), 135 deletions(-)
> 
> diff --git a/btf_encoder.c b/btf_encoder.c
> index 511c1ea..965e8f0 100644
> --- a/btf_encoder.c
> +++ b/btf_encoder.c

[...]

> @@ -1199,6 +1230,16 @@ static int32_t btf_encoder__add_func(struct btf_encoder *encoder,
>  		       name, btf_fnproto_id < 0 ? "proto" : "func");
>  		return -1;
>  	}
> +
> +	if (func->kfunc && encoder->tag_kfuncs && !encoder->skip_encoding_decl_tag) {
> +		err = btf__tag_kfunc(encoder->btf, func, btf_fn_id);
> +		if (err < 0) {
> +			fprintf(stderr, "%s: failed to tag kfunc '%s': %d\n",
> +				__func__, func->name, err);

Nit: btf__tag_kfunc() already prints to stderr in case of an error,
     this printf is unnecessary.

> +			return err;
> +		}
> +	}
> +
>  	if (state->nr_annots == 0)
>  		return 0;
>  

[...]






[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux