Re: [PATCH v2] pahole: Apply CU-level filters early in loading

Arnaldo Carvalho de Melo
2024-08-09T12:45:13Z

On Tue, Aug 06, 2024 at 01:10:03PM +0100, Alan Maguire wrote:
> On 01/08/2024 19:50, Matthew Maurer wrote:
> > Without this, even with `--lang_exclude=rust` set, running on `vmlinux`
> > with `CONFIG_RUST` enabled will lead to errors like:
> > die__process_function: tag not supported 0x2f (template_type_parameter)!
> > because the filtering doesn't happen until finalization, but unsupported
> > tags are reported during loading.
> >
> > As an added bonus, this should speed up processing of large objects with
> > filtered CUs, as their details will no longer be walked.
> >
> > Signed-off-by: Matthew Maurer <mmaurer@google.com>
>
> LGTM, thanks!
>
> Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
> Tested-by: Alan Maguire <alan.maguire@oracle.com>

Thanks, I just split it into two patches, one adding the new early
filtering facility and with the second making then use of this new
facility in pahole:

⬢[acme@toolbox pahole]$ git log --oneline -5
fbcca0f6c2fbeb52 (HEAD -> master) pahole: Do --languages_exclude CU filtering earlier
1f8d83d16d6d6dfa dwarf_loader: Allow filtering CUs early in loading
14be4e3d3fe56ce9 pahole: Only warn about multithreading not being available with older versions of elfutils in verbose mode
ee933f35484ac934 dwarf_loader: Simplify the tag__alloc() routine
cbecc3785266f0c5 (x1/master) dwarf_loader: Do just one alloc for 'struct dwarf_tag + struct tag'
⬢[acme@toolbox pahole]$ git show
commit fbcca0f6c2fbeb52349e28f03093a7efafb040ea (HEAD -> master)
Author: Matthew Maurer <mmaurer@google.com>
Date: Thu Aug 1 18:50:54 2024 +0000

pahole: Do --languages_exclude CU filtering earlier

With this, we can avoid warnings for unsupported DWARF tags like:

die__process_function: tag not supported 0x2f (template_type_parameter)!

when processing object files generated from languages such as Rust, for
instance when building the Linux kernel with `CONFIG_RUST`, after
appltying the next patch in this series.

As an added bonus, this should speed up processing of large objects with
filtered CUs, as their details will no longer be walked.

Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: Matthew Maurer <mmaurer@google.com>
Tested-by: Alan Maguire <alan.maguire@oracle.com>
Cc: Alice Ryhl <aliceryhl@google.com>
Cc: rust-for-linux@vger.kernel.org
Link: https://lore.kernel.org/r/20240801185054.2518383-1-mmaurer@google.com
[ Split from a larger patch ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

diff --git a/pahole.c b/pahole.c
index 4db51071b97d5f09..42ef6c262384a8e0 100644
--- a/pahole.c
+++ b/pahole.c
@@ -3766,6 +3766,10 @@ int main(int argc, char *argv[])
memset(tab, ' ', sizeof(tab) - 1);

conf_load.steal = pahole_stealer;
+
+ if (languages.exclude)
+ conf_load.early_cu_filter = cu__filter;
+
conf_load.thread_exit = pahole_thread_exit;

if (conf_load.reproducible_build) {
⬢[acme@toolbox pahole]$