From: Jiri Olsa <olsajiri@gmail.com>
To: Alan Maguire <alan.maguire@oracle.com>
Cc: acme@kernel.org, yhs@fb.com, ast@kernel.org, olsajiri@gmail.com,
timo@incline.eu, daniel@iogearbox.net, andrii@kernel.org,
songliubraving@fb.com, john.fastabend@gmail.com,
kpsingh@chromium.org, sdf@google.com, haoluo@google.com,
martin.lau@kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH dwarves 5/5] btf_encoder: skip BTF encoding of static functions with inconsistent prototypes
Date: Wed, 25 Jan 2023 14:39:02 +0100 [thread overview]
Message-ID: <Y9Ew9iwd3Jg5vk9c@krava> (raw)
In-Reply-To: <1674567931-26458-6-git-send-email-alan.maguire@oracle.com>
On Tue, Jan 24, 2023 at 01:45:31PM +0000, Alan Maguire wrote:
SNIP
> static int32_t btf_encoder__save_func(struct btf_encoder *encoder, struct function *fn)
> {
> @@ -819,13 +837,51 @@ static int32_t btf_encoder__save_func(struct btf_encoder *encoder, struct functi
> }
> /* If we find an existing entry, we want to merge observations
> * across both functions, checking that the "seen optimized-out
> - * parameters" status is reflected in our tree entry.
> + * parameters"/inconsistent proto status is reflected in tree entry.
> * If the entry is new, record encoder state required
> * to add the local function later (encoder + type_id_off)
> - * such that we can add the function later.
> + * such that we can add the function later. Parameter names are
> + * also stored in state to speed up multiple static function
> + * comparisons.
> */
> if (*nodep != fn) {
> - (*nodep)->proto.optimized_parms |= fn->proto.optimized_parms;
> + struct function *ofn = *nodep;
> +
> + ofn->proto.optimized_parms |= fn->proto.optimized_parms;
> + /* compare parameters to see if signatures match */
> +
> + if (ofn->proto.inconsistent_proto)
> + goto out;
> +
> + if (ofn->proto.nr_parms != fn->proto.nr_parms) {
> + ofn->proto.inconsistent_proto = 1;
> + goto out;
> + }
> + if (ofn->proto.nr_parms > 0) {
> + struct btf_encoder_state *state = ofn->priv;
> + const char *parameter_names[BTF_ENCODER_MAX_PARAMETERS];
> + int i;
> +
> + if (!state->got_parameter_names) {
> + parameter_names__get(&ofn->proto, BTF_ENCODER_MAX_PARAMETERS,
> + state->parameter_names);
> + state->got_parameter_names = true;
> + }
> + parameter_names__get(&fn->proto, BTF_ENCODER_MAX_PARAMETERS,
> + parameter_names);
> + for (i = 0; i < ofn->proto.nr_parms; i++) {
> + if (!state->parameter_names[i]) {
> + if (!parameter_names[i])
> + continue;
> + } else if (parameter_names[i]) {
> + if (strcmp(state->parameter_names[i],
> + parameter_names[i]) == 0)
> + continue;
I guess we can't check type easily? tag has type field,
but I'm not sure if we can get reasonable type info from that
jirka
> + }
> + ofn->proto.inconsistent_proto = 1;
> + goto out;
> + }
> + }
> } else {
> struct btf_encoder_state *state = zalloc(sizeof(*state));
>
> @@ -898,10 +954,12 @@ static void btf_encoder__add_saved_func(const void *nodep, const VISIT which,
> /* we can safely free encoder state since we visit each node once */
> free(fn->priv);
> fn->priv = NULL;
> - if (fn->proto.optimized_parms) {
> + if (fn->proto.optimized_parms || fn->proto.inconsistent_proto) {
> if (encoder->verbose)
> - printf("skipping addition of '%s' due to optimized-out parameters\n",
> - function__name(fn));
> + printf("skipping addition of '%s' due to %s\n",
> + function__name(fn),
> + fn->proto.optimized_parms ? "optimized-out parameters" :
> + "multiple inconsistent function prototypes");
> } else {
> btf_encoder__add_func(encoder, fn);
> }
> @@ -1775,6 +1833,8 @@ int btf_encoder__encode_cu(struct btf_encoder *encoder, struct cu *cu, struct co
> */
> if (fn->declaration)
> continue;
> + if (!fn->external)
> + save = true;
> if (!ftype__has_arg_names(&fn->proto))
> continue;
> if (encoder->functions.cnt) {
> @@ -1790,7 +1850,8 @@ int btf_encoder__encode_cu(struct btf_encoder *encoder, struct cu *cu, struct co
> if (func) {
> if (func->generated)
> continue;
> - func->generated = true;
> + if (!save)
> + func->generated = true;
> } else if (encoder->functions.suffix_cnt) {
> /* falling back to name.isra.0 match if no exact
> * match is found; only bother if we found any
> diff --git a/dwarves.h b/dwarves.h
> index 1ad1b3b..9b80262 100644
> --- a/dwarves.h
> +++ b/dwarves.h
> @@ -830,6 +830,7 @@ struct ftype {
> uint16_t nr_parms;
> uint8_t unspec_parms:1; /* just one bit is needed */
> uint8_t optimized_parms:1;
> + uint8_t inconsistent_proto:1;
> };
>
> static inline struct ftype *tag__ftype(const struct tag *tag)
> --
> 1.8.3.1
>
next prev parent reply other threads:[~2023-01-25 13:39 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-24 13:45 [PATCH dwarves 0/5] dwarves: support encoding of optimized-out parameters, removal of inconsistent static functions Alan Maguire
2023-01-24 13:45 ` [PATCH dwarves 1/5] dwarves: help dwarf loader spot functions with optimized-out parameters Alan Maguire
2023-01-25 16:53 ` Jiri Olsa
2023-01-25 17:47 ` Eduard Zingerman
2023-01-25 18:28 ` Alan Maguire
2023-01-25 21:34 ` Eduard Zingerman
2023-01-25 22:52 ` Alan Maguire
2023-01-25 23:42 ` Eduard Zingerman
2023-01-26 0:20 ` Eduard Zingerman
2023-01-26 14:02 ` Alan Maguire
2023-01-26 15:02 ` Eduard Zingerman
2023-01-24 13:45 ` [PATCH dwarves 2/5] btf_encoder: refactor function addition into dedicated btf_encoder__add_func Alan Maguire
2023-01-24 13:45 ` [PATCH dwarves 3/5] btf_encoder: child encoders should have a reference to parent encoder Alan Maguire
2023-01-24 13:45 ` [PATCH dwarves 4/5] btf_encoder: represent "."-suffixed optimized functions (".isra.0") in BTF Alan Maguire
2023-01-25 17:54 ` Kui-Feng Lee
2023-01-25 18:56 ` Arnaldo Carvalho de Melo
2023-01-26 18:37 ` Kui-Feng Lee
2023-01-25 18:59 ` Alan Maguire
2023-01-26 17:43 ` Kui-Feng Lee
2023-01-24 13:45 ` [PATCH dwarves 5/5] btf_encoder: skip BTF encoding of static functions with inconsistent prototypes Alan Maguire
2023-01-25 13:39 ` Jiri Olsa [this message]
2023-01-25 14:18 ` Alan Maguire
2023-01-25 16:53 ` Jiri Olsa
2023-01-26 14:12 ` Alan Maguire
2023-01-24 15:14 ` [PATCH dwarves 0/5] dwarves: support encoding of optimized-out parameters, removal of inconsistent static functions Jiri Olsa
2023-01-24 16:11 ` Alan Maguire
2023-01-25 13:59 ` 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=Y9Ew9iwd3Jg5vk9c@krava \
--to=olsajiri@gmail.com \
--cc=acme@kernel.org \
--cc=alan.maguire@oracle.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=kpsingh@chromium.org \
--cc=martin.lau@kernel.org \
--cc=sdf@google.com \
--cc=songliubraving@fb.com \
--cc=timo@incline.eu \
--cc=yhs@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