On Thu, 2024-11-28 at 01:24 +0000, Ihor Solodrai wrote: > Do not collect functions from ELF for each new btf_encoder, and > instead set a pointer to a shared elf_functions table, built > beforehand by btf_encoder__pre_cus__load_module(). > > Do not call btf_encoder__add_saved_funcs() on every > btf_encoder__add_encoder(). Instead, for non-reproducible > multi-threaded case do that in pahole_threads_collect(), and for > single-threaded or reproducible_build do that right before > btf_encoder__encode(). > > Signed-off-by: Ihor Solodrai <ihor.solodrai@xxxxx> > --- Acked-by: Eduard Zingerman <eddyz87@xxxxxxxxx> [...] > diff --git a/pahole.c b/pahole.c > index 1f8cf4b..b5aea56 100644 > --- a/pahole.c > +++ b/pahole.c > @@ -3185,12 +3185,16 @@ static int pahole_threads_collect(struct conf_load *conf, int nr_threads, void * > if (error) > goto out; > > + err = btf_encoder__add_saved_funcs(btf_encoder); > + if (err < 0) > + goto out; > + > for (i = 0; i < nr_threads; i++) { > /* > * Merge content of the btf instances of worker threads to the btf > * instance of the primary btf_encoder. > */ > - if (!threads[i]->btf) > + if (!threads[i]->encoder || !threads[i]->btf) > continue; When can 'threads[i]->encoder' be NULL? In case if worker thread exits with error? > err = btf_encoder__add_encoder(btf_encoder, threads[i]->encoder); > if (err < 0) [...]