From: sashiko-bot@kernel.org
To: "Arnaldo Carvalho de Melo" <acme@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v1 1/1] perf annotate-data: Cache the per-instruction data type resolution
Date: Sat, 05 Dec 2026 13:18:36 +0000 [thread overview]
Message-ID: <sashiko-outbox-251559@kernel.org> (raw)
In-Reply-To: <20261205130136.5962-1-acme@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] perf annotate-data: wrong ms key in
__hist_entry__get_data_type()
--
commit 91c505c1c8646d1d466660ac433e03bbaba797f2
Author: Arnaldo Carvalho de Melo <acme@kernel.org>
perf annotate-data: Cache the per-instruction data type resolution
This commit adds a session-global hashmap (dtype_cache) keyed on (dso, ip)
to memoize per-instruction data type resolution and replay its statistics
in __hist_entry__get_data_type().
> diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
> index 86a4beec6528e..321c0af4265c3 100644
> --- a/tools/perf/util/annotate.c
> +++ b/tools/perf/util/annotate.c
[ ... ]
> @@ -2847,32 +3052,48 @@ __hist_entry__get_data_type(struct hist_entry *he, const struct arch *arch,
> struct map_symbol *ms = &he->ms;
> struct annotated_insn_loc loc;
> struct annotated_op_loc *op_loc;
> - struct annotated_data_type *mem_type;
> + struct annotated_data_type *mem_type = NULL, *ret;
> struct annotated_item_stat *istat;
> + struct dtype_cache fill = { .replay = DTYPE_REPLAY_NONE };
> + struct dtype_cache *dc;
> + struct annotated_data_stat before;
> int i;
>
> + dc = dtype_cache__find(map__dso(ms->map), ms->sym->start + dl->al.offset);
> + if (dc)
> + return dtype_cache__replay(dc, he, type_offset);
[ ... ]
> +out_add:
> + annotated_data_stat__delta(&fill.stat_delta, &before);
> + dtype_cache__add(map__dso(ms->map), ms->sym->start + dl->al.offset, &fill);
> + return ret;
> }
[Severity: Medium]
Can he->ms differ from the symbol that owns dl, or have a NULL sym or map,
when __hist_entry__get_data_type() keys dtype_cache on it?
In __hist_entry__tui_annotate(), browser.he->ms is only updated from ms when
hbt != NULL && he != &annotate_he. When hbt is NULL (in perf report, perf
annotate, or perf c2c) or on nested calls in perf top, browser.he->ms stays
on the caller or root entry while dl comes from ms.
With code-with-type enabled, annotate_browser__callq() passes the callee's
target_ms with the caller's browser->he. disasm_line__snprint_type_info()
then looks up and inserts under the caller's (dso, sym->start + offset),
replaying the caller's verdicts onto the callee and poisoning dtype_cache.
If he->ms.sym is NULL, such as when do_annotate() annotates a synthetic
symbol from symbol__new_unresolved() in perf_evsel__hists_browse(),
ms->sym->start also causes a NULL pointer dereference on entry before any
early returns.
Passing the annotated map_symbol to __hist_entry__get_data_type() (and
checking ms->map and ms->sym) would ensure the cache key matches dl.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205130136.5962-1-acme@kernel.org?part=1
prev parent reply other threads:[~2026-12-05 13:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 13:01 [PATCH v1 1/1] perf annotate-data: Cache the per-instruction data type resolution Arnaldo Carvalho de Melo
2026-12-05 13:18 ` sashiko-bot [this message]
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=sashiko-outbox-251559@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=acme@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.