From: Jiri Olsa <olsajiri@gmail.com>
To: Ihor Solodrai <ihor.solodrai@pm.me>
Cc: dwarves@vger.kernel.org, acme@kernel.org,
alan.maguire@oracle.com, eddyz87@gmail.com, andrii@kernel.org,
mykolal@fb.com, bpf@vger.kernel.org
Subject: Re: [PATCH dwarves v3 2/8] btf_encoder: separate elf function, saved function representations
Date: Wed, 1 Jan 2025 17:56:07 +0100 [thread overview]
Message-ID: <Z3Vzp9M55sRsNgCP@krava> (raw)
In-Reply-To: <20241221012245.243845-3-ihor.solodrai@pm.me>
On Sat, Dec 21, 2024 at 01:23:01AM +0000, Ihor Solodrai wrote:
SNIP
> +static int saved_functions_combine(void *_a, void *_b)
> +{
> + uint8_t optimized, unexpected, inconsistent;
> + struct btf_encoder_func_state *a = _a;
> + struct btf_encoder_func_state *b = _b;
> + int ret;
> +
> + ret = strncmp(a->elf->name, b->elf->name,
> + max(a->elf->prefixlen, b->elf->prefixlen));
> + if (ret != 0)
> + return ret;
> + optimized = a->optimized_parms | b->optimized_parms;
> + unexpected = a->unexpected_reg | b->unexpected_reg;
> + inconsistent = a->inconsistent_proto | b->inconsistent_proto;
> + if (!unexpected && !inconsistent && !funcs__match(a, b))
> + inconsistent = 1;
> + a->optimized_parms = b->optimized_parms = optimized;
> + a->unexpected_reg = b->unexpected_reg = unexpected;
> + a->inconsistent_proto = b->inconsistent_proto = inconsistent;
do we still need to update the 'b' state object?
> +
> + return 0;
> +}
> +
> +static void btf_encoder__delete_saved_funcs(struct btf_encoder *encoder)
> +{
> + struct btf_encoder_func_state *pos, *s;
> +
> + list_for_each_entry_safe(pos, s, &encoder->func_states, node) {
> + list_del(&pos->node);
> + free(pos->parms);
> + free(pos->annots);
> + free(pos);
> + }
> +
> + for (int i = 0; i < encoder->functions.cnt; i++)
> + free(encoder->functions.entries[i].alias);
> +}
> +
> +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++;
> + }
the encoder loop goes eventualy away, but still would it make to store
func_states count instead of the loop?
now when there's just single place that stores 'state' it seems like it
should be straighforward
SNIP
> void btf_encoder__delete(struct btf_encoder *encoder)
> {
> - int i;
> size_t shndx;
>
> if (encoder == NULL)
> @@ -2447,18 +2469,19 @@ void btf_encoder__delete(struct btf_encoder *encoder)
> btf_encoders__delete(encoder);
> for (shndx = 0; shndx < encoder->seccnt; shndx++)
> __gobuffer__delete(&encoder->secinfo[shndx].secinfo);
> + free(encoder->secinfo);
nit, this seems unrelated to this change, should be in separate fix?
thanks,
jirka
> zfree(&encoder->filename);
> zfree(&encoder->source_filename);
> btf__free(encoder->btf);
> encoder->btf = NULL;
> elf_symtab__delete(encoder->symtab);
>
> - for (i = 0; i < encoder->functions.cnt; i++)
> - btf_encoder__delete_func(&encoder->functions.entries[i]);
> encoder->functions.allocated = encoder->functions.cnt = 0;
> free(encoder->functions.entries);
> encoder->functions.entries = NULL;
>
> + btf_encoder__delete_saved_funcs(encoder);
> +
> free(encoder);
> }
>
SNIP
next prev parent reply other threads:[~2025-01-01 16:56 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-21 1:22 [PATCH dwarves v3 0/8] pahole: faster reproducible BTF encoding Ihor Solodrai
2024-12-21 1:22 ` [PATCH dwarves v3 1/8] btf_encoder: simplify function encoding Ihor Solodrai
2024-12-21 1:23 ` [PATCH dwarves v3 2/8] btf_encoder: separate elf function, saved function representations Ihor Solodrai
2025-01-01 16:56 ` Jiri Olsa [this message]
2025-01-02 19:54 ` Ihor Solodrai
2024-12-21 1:23 ` [PATCH dwarves v3 3/8] btf_encoder: introduce elf_functions struct type Ihor Solodrai
2025-01-01 16:56 ` Jiri Olsa
2025-01-02 20:06 ` Ihor Solodrai
2024-12-21 1:23 ` [PATCH dwarves v3 4/8] btf_encoder: introduce elf_functions_list Ihor Solodrai
2024-12-21 1:23 ` [PATCH dwarves v3 5/8] btf_encoder: remove skip_encoding_inconsistent_proto Ihor Solodrai
2024-12-21 1:23 ` [PATCH dwarves v3 6/8] dwarf_loader: introduce cu->id Ihor Solodrai
2024-12-21 1:23 ` [PATCH dwarves v3 7/8] dwarf_loader: multithreading with a job/worker model Ihor Solodrai
2024-12-30 16:07 ` Arnaldo Carvalho de Melo
2024-12-30 16:11 ` Arnaldo Carvalho de Melo
2024-12-30 18:37 ` Arnaldo Carvalho de Melo
2025-01-02 23:09 ` Ihor Solodrai
2025-01-01 16:56 ` Jiri Olsa
2025-01-03 0:24 ` Ihor Solodrai
2024-12-21 1:23 ` [PATCH dwarves v3 8/8] btf_encoder: clean up global encoders list Ihor Solodrai
2025-01-01 16:56 ` Jiri Olsa
2025-01-03 0:43 ` Ihor Solodrai
2025-01-03 9:27 ` Jiri Olsa
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=Z3Vzp9M55sRsNgCP@krava \
--to=olsajiri@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=eddyz87@gmail.com \
--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