From: Eduard Zingerman <eddyz87@gmail.com>
To: Ihor Solodrai <ihor.solodrai@pm.me>,
dwarves@vger.kernel.org, acme@kernel.org
Cc: bpf@vger.kernel.org, alan.maguire@oracle.com, andrii@kernel.org,
mykolal@fb.com
Subject: Re: [RFC PATCH 3/9] btf_encoder: separate elf function, saved function representations
Date: Fri, 29 Nov 2024 12:37:57 -0800 [thread overview]
Message-ID: <39b3f6f04838b96e858effc09e01d7b29c529f2e.camel@gmail.com> (raw)
In-Reply-To: <20241128012341.4081072-4-ihor.solodrai@pm.me>
On Thu, 2024-11-28 at 01:23 +0000, Ihor Solodrai wrote:
> From: Alan Maguire <alan.maguire@oracle.com>
>
> Have saved function representation point back at immutable ELF function
> table. This will make sharing the ELF function table across encoders
> easier. Simply accumulate saved functions for each encoder, and on
> completion combine them into a name-sorted list. Then carry out
> comparisons to check for inconsistent representations, skipping functions
> that are inconsistent in their representation.
>
> Thre is a small growth in maximum resident set size due to saving
> more functions; it grows from
>
> Maximum resident set size (kbytes): 701888
>
> to:
>
> Maximum resident set size (kbytes): 704168
>
> ...with this patch for -j1.
>
> Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
> Signed-off-by: Ihor Solodrai <ihor.solodrai@pm.me>
> ---
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
I like what this patch does, a few nits below.
Note:
this patch leads to 58 less functions being generated,
compared to a previous patch, for my test configuration.
For example, functions like:
- hid_map_usage_clear
- jhash
- nlmsg_parse_deprecated_strict
Are not in the BTF anymore. It would be good if patch message could
explain why this happens.
[...]
> +static int btf_encoder__add_saved_funcs(struct btf_encoder *encoder)
> +{
> + struct btf_encoder_func_state **saved_fns, *s;
> + struct btf_encoder *e = NULL;
> + int i = 0, j, nr_saved_fns = 0;
> +
> + /* Retrieve function states from each encoder, combine them
> + * and sort by name, addr.
> + */
> + btf_encoders__for_each_encoder(e) {
> + list_for_each_entry(s, &e->func_states, node)
> + nr_saved_fns++;
> + }
> + /* Another thread already did this work */
> + if (nr_saved_fns == 0) {
> + printf("nothing to do for encoder...\n");
> + return 0;
> + }
Nit: this function is called from pahole_threads_collect():
static int pahole_threads_collect(...)
for (i = 0; i < nr_threads; i++)
...
err = btf_encoder__add_encoder(btf_encoder, threads[i]->encoder);
...
int32_t btf_encoder__add_encoder(struct btf_encoder *encoder, struct btf_encoder *other)
...
btf_encoder__add_saved_funcs(other);
...
maybe move call to btf_encoder__add_saved_funcs() to pahole_threads_collect()
outside of the loop? So that comment about another thread won't be necessary.
> +
> + printf("got %d saved functions...\n", nr_saved_fns);
> + saved_fns = calloc(nr_saved_fns, sizeof(*saved_fns));
> + btf_encoders__for_each_encoder(e) {
> + list_for_each_entry(s, &e->func_states, node)
> + saved_fns[i++] = s;
> + }
> + printf("added %d saved fns\n", i);
> + qsort(saved_fns, nr_saved_fns, sizeof(*saved_fns), saved_functions_cmp);
> +
> + for (i = 0; i < nr_saved_fns; i = j) {
> + struct btf_encoder_func_state *state = saved_fns[i];
> +
> + /* Compare across sorted functions that match by name/prefix;
> + * share inconsistent/unexpected reg state between them.
> + */
> + j = i + 1;
> +
> + while (j < nr_saved_fns &&
> + saved_functions_combine(saved_fns[i], saved_fns[j]) == 0)
> + j++;
> +
> + /* do not exclude functions with optimized-out parameters; they
> + * may still be _called_ with the right parameter values, they
> + * just do not _use_ them. Only exclude functions with
> + * unexpected register use or multiple inconsistent prototypes.
> + */
> + if (!encoder->skip_encoding_inconsistent_proto ||
> + (!state->unexpected_reg && !state->inconsistent_proto)) {
> + if (btf_encoder__add_func(state->encoder, state)) {
> + free(saved_fns);
> + return -1;
> + }
> + }
> + }
> + /* Now that we are done with function states, free them. */
> + free(saved_fns);
> + btf_encoders__for_each_encoder(e)
> + btf_encoder__delete_saved_funcs(e);
> + return 0;
> +}
[...]
> @@ -2437,16 +2470,8 @@ out_delete:
> return NULL;
> }
>
> -void btf_encoder__delete_func(struct elf_function *func)
> -{
> - free(func->alias);
Nit: it looks like func->alias is never freed after this change.
> - zfree(&func->state.annots);
> - zfree(&func->state.parms);
> -}
[...]
next prev parent reply other threads:[~2024-11-29 20:38 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-28 1:23 [RFC PATCH 0/9] pahole: shared ELF and faster reproducible BTF encoding Ihor Solodrai
2024-11-28 1:23 ` [RFC PATCH 1/9] btf_encoder: simplify function encoding Ihor Solodrai
2024-11-29 8:16 ` Eduard Zingerman
2024-12-02 13:55 ` Jiri Olsa
2024-11-28 1:23 ` [RFC PATCH 2/9] btf_encoder: store,use section-relative addresses in ELF function representation Ihor Solodrai
2024-11-29 9:07 ` Eduard Zingerman
2024-12-02 14:34 ` Alan Maguire
2024-11-28 1:23 ` [RFC PATCH 3/9] btf_encoder: separate elf function, saved function representations Ihor Solodrai
2024-11-29 20:37 ` Eduard Zingerman [this message]
2024-12-09 21:19 ` Ihor Solodrai
2024-11-28 1:24 ` [RFC PATCH 4/9] dwarf_loader: introduce pre_load_module hook to conf_load Ihor Solodrai
2024-11-29 21:03 ` Eduard Zingerman
2024-11-28 1:24 ` [RFC PATCH 5/9] btf_encoder: introduce elf_functions struct type Ihor Solodrai
2024-11-29 21:50 ` Eduard Zingerman
2024-11-28 1:24 ` [RFC PATCH 6/9] btf_encoder: collect elf_functions in btf_encoder__pre_load_module Ihor Solodrai
2024-11-29 22:27 ` Eduard Zingerman
2024-11-28 1:24 ` [RFC PATCH 7/9] btf_encoder: switch to shared elf_functions table Ihor Solodrai
2024-11-29 22:35 ` Eduard Zingerman
2024-12-09 23:55 ` Ihor Solodrai
2024-11-28 1:24 ` [RFC PATCH 8/9] btf_encoder: introduce btf_encoding_context Ihor Solodrai
2024-11-29 23:12 ` Eduard Zingerman
2024-11-28 1:24 ` [RFC PATCH 9/9] pahole: faster reproducible BTF encoding Ihor Solodrai
2024-11-30 0:17 ` Eduard Zingerman
2024-12-02 13:55 ` [RFC PATCH 0/9] pahole: shared ELF and " Jiri Olsa
2024-12-06 18:19 ` Ihor Solodrai
2024-12-06 18:30 ` Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=39b3f6f04838b96e858effc09e01d7b29c529f2e.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=acme@kernel.org \
--cc=alan.maguire@oracle.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=dwarves@vger.kernel.org \
--cc=ihor.solodrai@pm.me \
--cc=mykolal@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox