From: sashiko-bot@kernel.org
To: "Tengda Wu" <wutengda@huaweicloud.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v8 13/15] perf annotate-arm64: Support 'adrp' instruction to track global variables
Date: Tue, 20 Oct 2026 15:15:45 +0000 [thread overview]
Message-ID: <sashiko-outbox-179232@kernel.org> (raw)
In-Reply-To: <145ac934f72c090987c2e6d0be28b28972f843c7.1792411435.git.wutengda@huaweicloud.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] perf annotate-arm64: adjust_reg_index_state() drops global addr writeback
--
commit 329d013c0c7d0b8be3fe8f0ec1e0f669451e6cbd
Author: Tengda Wu <wutengda@huaweicloud.com>
perf annotate-arm64: Support 'adrp' instruction to track global variables
This commit extends arm64 data type profiling to track global variable
addresses calculated via page-relative adrp instructions. It introduces
TSR_KIND_GLOBAL_ADDR to store the page-aligned base address and resolves
the symbol address and DWARF type on subsequent add or load instructions.
> diff --git a/tools/perf/util/annotate-arch/annotate-arm64.c b/tools/perf/util/annotate-arch/annotate-arm64.c
> index 61df9c4f48776..bd060a823b765 100644
> --- a/tools/perf/util/annotate-arch/annotate-arm64.c
> +++ b/tools/perf/util/annotate-arch/annotate-arm64.c
[ ... ]
> @@ -722,6 +722,33 @@ static int propagate_load_reg_state(struct type_state *state,
> return 0;
> }
>
> + /* Or check if it's a global variable */
> + if (src_tsr->kind == TSR_KIND_GLOBAL_ADDR) {
> + u64 ip = dloc->ms->sym->start + dl->al.offset;
> + u64 addr = src_tsr->imm_value + reg_offset;
> + int offset;
> +
> + if (!get_global_var_type(cu_die, dloc, ip, addr, &offset, &type_die) ||
> + !die_get_member_type(&type_die, offset, &type_die))
> + return -1;
[ ... ]
> @@ -991,14 +1018,16 @@ static void update_add_insn_state(struct type_state *state,
> if (arch_get_reg_offset(dloc->arch, src, sreg, state, false, ®_offset))
> goto add_non_regoff;
>
> - if (src_tsr.kind == TSR_KIND_CONST) {
> + if (src_tsr.kind == TSR_KIND_CONST || src_tsr.kind == TSR_KIND_GLOBAL_ADDR) {
> tsr->kind = src_tsr.kind;
> + /* For 'adrp + add' pair: resolve the full global variable address. */
> tsr->imm_value = src_tsr.imm_value + reg_offset;
> tsr->offset = 0;
> tsr->ok = src_tsr.ok;
[Severity: Medium]
What happens when a pre-indexed or post-indexed load or store instruction
(for example, ldr x0, [x19, #0x40]! or ldr x0, [x19], #8) uses a
TSR_KIND_GLOBAL_ADDR register as its base?
Both update_load_insn_state() and update_store_insn_state() call
adjust_reg_index_state(), which adds the writeback offset to tsr->offset:
tools/perf/util/annotate-arch/annotate-arm64.c:adjust_reg_index_state() {
...
if (arch_get_reg_offset(dloc->arch, op_loc, reg, state, true, &offset)) {
invalidate_reg_state(tsr);
return;
}
tsr->offset += offset;
...
}
However, TSR_KIND_GLOBAL_ADDR stores the base address in tsr->imm_value,
and all consumers — propagate_load_reg_state(), update_add_insn_state(),
and check_matching_type() in tools/perf/util/annotate-data.c — compute the
target address from imm_value + reg_offset while ignoring tsr->offset (and
update_add_insn_state() resets tsr->offset to 0).
Should adjust_reg_index_state() update tsr->imm_value (or should the
consumers include tsr->offset) so that pre/post-index writeback updates on
global address registers are not lost on subsequent instructions?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1792411435.git.wutengda@huaweicloud.com?part=13
next prev parent reply other threads:[~2026-10-20 15:16 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-20 13:44 [PATCH v8 00/15] perf annotate arm64: Support instruction tracking for data type profiling Tengda Wu
2026-10-20 13:44 ` [PATCH v8 01/15] perf annotate-data: Extract invalidate_reg_state() as a common helper Tengda Wu
2026-10-20 13:57 ` sashiko-bot
2026-10-20 13:44 ` [PATCH v8 02/15] perf annotate-arm64: Enable instruction tracking support Tengda Wu
2026-10-20 14:05 ` sashiko-bot
2026-10-20 13:44 ` [PATCH v8 03/15] perf annotate-data: Add arch_get_reg_offset helper Tengda Wu
2026-10-20 14:13 ` sashiko-bot
2026-10-20 13:45 ` [PATCH v8 04/15] perf annotate-arm64: Track return type after call instructions Tengda Wu
2026-10-20 14:15 ` sashiko-bot
2026-10-20 13:45 ` [PATCH v8 05/15] perf annotate-arm64: Support load instruction tracking Tengda Wu
2026-10-20 14:36 ` sashiko-bot
2026-10-20 13:45 ` [PATCH v8 06/15] perf annotate-arm64: Support store " Tengda Wu
2026-10-20 14:39 ` sashiko-bot
2026-10-20 13:45 ` [PATCH v8 07/15] perf annotate-data: Expand type_state_reg imm_value to u64 Tengda Wu
2026-10-20 14:43 ` sashiko-bot
2026-10-20 13:45 ` [PATCH v8 08/15] perf annotate-data: Track imm_value for stack variables Tengda Wu
2026-10-20 14:46 ` sashiko-bot
2026-10-20 13:45 ` [PATCH v8 09/15] perf annotate-x86: Delete stale stack state on store of untracked register Tengda Wu
2026-10-20 14:50 ` sashiko-bot
2026-10-20 13:45 ` [PATCH v8 10/15] perf annotate-arm64: Support stack variable tracking Tengda Wu
2026-10-20 14:59 ` sashiko-bot
2026-10-20 13:45 ` [PATCH v8 11/15] perf annotate-arm64: Support 'mov' instruction tracking Tengda Wu
2026-10-20 15:01 ` sashiko-bot
2026-10-20 13:45 ` [PATCH v8 12/15] perf annotate-arm64: Support 'add' " Tengda Wu
2026-10-20 15:05 ` sashiko-bot
2026-10-20 13:45 ` [PATCH v8 13/15] perf annotate-arm64: Support 'adrp' instruction to track global variables Tengda Wu
2026-10-20 15:15 ` sashiko-bot [this message]
2026-10-20 13:45 ` [PATCH v8 14/15] perf annotate-arm64: Support per-cpu variable access tracking Tengda Wu
2026-10-20 15:24 ` sashiko-bot
2026-10-20 13:45 ` [PATCH v8 15/15] perf annotate-arm64: Support 'mrs' instruction to track 'current' pointer Tengda Wu
2026-10-20 15:30 ` sashiko-bot
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-179232@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wutengda@huaweicloud.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