Re: [PAHOLE v5 1/5] btf_loader: Handle decl tag component_idx for parameters
Vineet Gupta <[email protected]> Thu, 18 Jun 2026 10:18:21 -0700
| Newsgroups | org.kernel.vger.dwarves,org.kernel.vger.bpf |
|---|---|
| Message-ID | <[email protected]> |
On 6/18/26 7:38 AM, Alan Maguire wrote: > On 18/06/2026 05:46, Emil Tsalapatis wrote: >> On Wed Jun 17, 2026 at 8:57 PM EDT, Vineet Gupta wrote: >>> From: Alan Maguire <[email protected]> >>> >>> A BTF_KIND_DECL_TAG with a non-negative component_idx applies to a >>> specific function parameter (or struct/union member), not to the >>> function itself. btf_loader.c however attached every decl tag to the >>> type named by btf_type->type, so parameter decl tags were recorded on >>> the function rather than on the parameter, and pfunct never printed >>> them with the parameter. >>> >>> Resolve a non-negative component_idx to the corresponding parameter via >>> new helpers ftype__parameter()/function__parameter(), and attach the >>> tag there. Teach the pretty printer to emit a parameter's attributes by >>> factoring the function-level attribute loop into tag__attributes_fprintf() >>> and calling it from ftype__fprintf_parms() for each parameter. >>> >>> Signed-off-by: Alan Maguire <[email protected]> >>> Signed-off-by: Vineet Gupta <[email protected]> >> With one nit: >> >> Reviewed-by: Emil Tsalapatis <[email protected]> >> >> (Also feel free to keep the tags for the other 3 patches since the >> changes are minimal). >> >> </SNIP> >> >>> + if (component_idx >= 0) { >>> + struct tag *func_tag = cu__function(cu, tp->type); >>> + >>> + if (func_tag != NULL) { >>> + tag = function__parameter(tag__function(func_tag), cu, >>> + component_idx); >>> + if (tag == NULL) { >>> + fprintf(stderr, "WARNING: BTF_KIND_DECL_TAG for unknown parameter %d in BTF id %d\n", >>> + component_idx, tp->type); >>> + return 0; >>> + } >>> + } >>> + } >>> + >>> + if (tag == NULL && component_idx < 0) >>> tag = cu__function(cu, tp->type); >> Nit, I think this can be simplified as follows: >> >> tag = cu__function(cu, tp->type); >> if (component_idx >= 0 && tag != NULL) { >> tag = function__parameter(tag__function(tag), cu, component_idx); >> if (tag == NULL) { >> fprintf(stderr, "WARNING: BTF_KIND_DECL_TAG for unknown parameter %d in BTF id %d\n", >> component_idx, tp->type); >> return 0; >> } >> } >> >> <SNIP> > yep, that looks good to me. if there are no other issues arising from this > round and Vineet is happy with that change I can roll it in when landing this > to save having to roll a v6. Cool, works for me and and indeed it will be nice to avoid a v6 :-) Thx, -Vineet > > One other issue; we need to install bpftool for CI. I'm working on a change to > support this (installing the version from the kernel tree), I'll try and get > this in place ASAP. Thanks!