From: Tengda Wu <wutengda@huaweicloud.com>
To: sashiko-reviews@lists.linux.dev
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v5 25/26] perf annotate-arm64: Support per-cpu variable access tracking
Date: Fri, 11 Sep 2026 18:15:23 +0800 [thread overview]
Message-ID: <05e0e407-c4d1-44e2-9d88-b170f57eb663@huaweicloud.com> (raw)
In-Reply-To: <20260908133059.E85591F00AC4@smtp.kernel.org>
On 2026/9/8 21:30, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] The newly added logic to track per-cpu base registers in 'add' and 'ldr' instructions is entirely unreachable dead code because `arch_get_reg_offset` prematurely aborts the tracking state.
> --
>
> commit e3331fba4432f08f3db300129b5060bba477930c
> Author: Tengda Wu <wutengda@huaweicloud.com>
>
> perf annotate-arm64: Support per-cpu variable access tracking
>
> This commit extends update_insn_state_arm64() to handle per-cpu variable
> addressing. It detects 'adrp + ldr' pairs that resolve to the
> '__per_cpu_offset' symbol, and attempts to propagate this type information
> through subsequent 'ldr' and 'add' instructions. However, the newly added
> logic is entirely unreachable dead code because arch_get_reg_offset()
> prematurely aborts the tracking state.
>
>> diff --git a/tools/perf/util/annotate-arch/annotate-arm64.c b/tools/perf/util/annotate-arch/annotate-arm64.c
>> index 9daf959055457..33fef3d153786 100644
>> --- a/tools/perf/util/annotate-arch/annotate-arm64.c
>> +++ b/tools/perf/util/annotate-arch/annotate-arm64.c
>
> [ ... ]
>
>> @@ -649,6 +660,12 @@ static int propagate_load_reg_state(struct type_state *state,
>> return 0;
>> }
>>
>> + /*
>> + * If src_tsr->kind is TSR_KIND_PERCPU_BASE, treat it as an array.
>> + * No special handling is needed here; just fall through to retry
>> + * and resolve the type from the second register.
>> + */
>> +
>
> [Severity: Medium]
> Is this fall-through logic in propagate_load_reg_state() for intermediate
> Pattern A ('ldr') instructions actually reachable?
>
> Earlier in propagate_load_reg_state(), arch_get_reg_offset() forces an early
> exit by returning -1 when evaluating a multi-register load where the second
> register isn't a constant. This happens before this new per-cpu fallback
> logic can be reached, making this dead code.
>
Indeed. The return happens too early.
>> /* Or try another register if any */
>> if (src->multi_regs && src->reg1 != src->reg2 && sreg != src->reg2 &&
>> !(src->extend_type || src->shift_type)) {
>
> [ ... ]
>
>> @@ -949,6 +966,34 @@ static void update_add_insn_state(struct type_state *state,
>> return;
>> }
>>
>> + if (src_tsr.kind == TSR_KIND_PERCPU_BASE) {
>> + int reg2;
>> +
>> + if (!src->multi_regs) {
>> + invalidate_reg_state(tsr);
>> + return;
>> + }
>> +
>> + reg2 = (sreg == src->reg1) ? src->reg2 : src->reg1;
>> +
>> + if (!has_reg_type(state, reg2) || !state->regs[reg2].ok) {
>> + invalidate_reg_state(tsr);
>> + return;
>> + }
>> +
>> + /* Treat percpu as array: inherit type from reg2 */
>> + tsr->type = state->regs[reg2].type;
>> + tsr->kind = state->regs[reg2].kind;
>> + tsr->offset = state->regs[reg2].offset;
>> + tsr->imm_value = state->regs[reg2].imm_value;
>> + tsr->ok = state->regs[reg2].ok;
>> +
>> + pr_debug_dtp("add [%x] percpu (reg%d, reg%d) -> reg%d",
>> + insn_offset, src->reg1, src->reg2, dreg);
>> + pr_debug_type_name(&tsr->type, tsr->kind);
>> + return;
>> + }
>> +
>
> [Severity: Medium]
> Does this block ever execute when handling a per-cpu address calculation
> (Pattern B like 'add x0, x6, x5') in update_add_insn_state()?
>
> When arch_get_reg_offset() executes earlier in update_add_insn_state(), it
> returns -1 for multi-register non-memory operations (like 'add') unless one
> register is a TSR_KIND_CONST or the base is a known TSR_KIND_POINTER.
>
> Since the registers here are PERCPU_BASE and GLOBAL_ADDR, it returns -1
> and jumps to the try_other_reg label, permanently bypassing this new tracking
> logic.
>
Agreed. This is the same issue as above. Will fix in v6.
>> try_other_reg:
>> /* Try another register if any */
>> if (src->multi_regs && src->reg1 != src->reg2 && sreg != src->reg2 &&
>
next prev parent reply other threads:[~2026-09-11 10:15 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 13:05 [PATCH v5 00/26] perf arm64: Support data type profiling Tengda Wu
2026-09-08 13:05 ` [PATCH v5 01/26] perf capstone: Symbolize address operands to match objdump on arm64 Tengda Wu
2026-09-08 13:18 ` sashiko-bot
2026-09-09 14:49 ` Namhyung Kim
2026-09-10 7:38 ` Tengda Wu
2026-09-08 13:05 ` [PATCH v5 02/26] perf llvm: Fix arm64 adrp instruction disassembly mismatch with objdump Tengda Wu
2026-09-08 13:16 ` sashiko-bot
2026-09-09 14:50 ` Namhyung Kim
2026-09-08 13:05 ` [PATCH v5 03/26] perf annotate-arm64: Generalize arm64_mov__parse to support more instructions Tengda Wu
2026-09-08 13:15 ` sashiko-bot
2026-09-09 14:52 ` Namhyung Kim
2026-09-08 13:05 ` [PATCH v5 04/26] perf annotate-arm64: Handle load and store instructions Tengda Wu
2026-09-08 13:15 ` sashiko-bot
2026-09-09 14:58 ` Namhyung Kim
2026-09-08 13:05 ` [PATCH v5 05/26] perf annotate: Normalize arch__dwarf_regnum() error return values Tengda Wu
2026-09-08 13:24 ` sashiko-bot
2026-09-08 17:57 ` Ian Rogers
2026-09-09 15:00 ` Namhyung Kim
2026-09-08 13:05 ` [PATCH v5 06/26] perf annotate: Introduce extract_op_location callback for arch-specific parsing Tengda Wu
2026-09-08 13:20 ` sashiko-bot
2026-09-09 15:01 ` Namhyung Kim
2026-09-08 13:05 ` [PATCH v5 07/26] perf dwarf-regs: Adapt get_dwarf_regnum() for arm64 Tengda Wu
2026-09-08 13:21 ` sashiko-bot
2026-09-09 15:03 ` Namhyung Kim
2026-09-08 13:05 ` [PATCH v5 08/26] perf annotate: Adapt arch__dwarf_regnum() " Tengda Wu
2026-09-08 13:15 ` sashiko-bot
2026-09-09 15:04 ` Namhyung Kim
2026-09-08 13:05 ` [PATCH v5 09/26] perf annotate-arm64: Implement extract_op_location() callback Tengda Wu
2026-09-08 13:18 ` sashiko-bot
2026-09-10 8:49 ` Tengda Wu
2026-09-08 13:05 ` [PATCH v5 10/26] perf annotate: Default to --itrace=i1i for data type profiling Tengda Wu
2026-09-08 13:15 ` sashiko-bot
2026-09-09 15:38 ` Adrian Hunter
2026-09-08 13:05 ` [PATCH v5 11/26] perf arm-spe: Set default synthesized event period to 1 Tengda Wu
2026-09-08 13:12 ` sashiko-bot
2026-09-08 13:05 ` [PATCH v5 12/26] perf annotate-data: Extract invalidate_reg_state() as a common helper Tengda Wu
2026-09-08 13:11 ` sashiko-bot
2026-09-08 13:05 ` [PATCH v5 13/26] perf annotate-arm64: Enable instruction tracking support Tengda Wu
2026-09-08 13:18 ` sashiko-bot
2026-09-10 9:20 ` Tengda Wu
2026-09-08 13:05 ` [PATCH v5 14/26] perf annotate-data: Add arch_get_reg_offset helper Tengda Wu
2026-09-08 13:22 ` sashiko-bot
2026-09-10 12:13 ` Tengda Wu
2026-09-08 13:05 ` [PATCH v5 15/26] perf annotate-arm64: Track return type after call instructions Tengda Wu
2026-09-08 13:14 ` sashiko-bot
2026-09-08 13:05 ` [PATCH v5 16/26] perf annotate-arm64: Support load instruction tracking Tengda Wu
2026-09-08 13:23 ` sashiko-bot
2026-09-10 13:19 ` Tengda Wu
2026-09-10 13:28 ` Tengda Wu
2026-09-08 13:05 ` [PATCH v5 17/26] perf annotate-arm64: Support store " Tengda Wu
2026-09-08 13:22 ` sashiko-bot
2026-09-08 13:05 ` [PATCH v5 18/26] perf annotate-data: Expand type_state_reg imm_value to u64 Tengda Wu
2026-09-08 13:26 ` sashiko-bot
2026-09-08 13:05 ` [PATCH v5 19/26] perf annotate-data: Track imm_value for stack variables Tengda Wu
2026-09-08 13:29 ` sashiko-bot
2026-09-08 13:05 ` [PATCH v5 20/26] perf annotate-x86: Delete stale stack state on store of untracked register Tengda Wu
2026-09-08 13:20 ` sashiko-bot
2026-09-08 13:05 ` [PATCH v5 21/26] perf annotate-arm64: Support stack variable tracking Tengda Wu
2026-09-08 13:36 ` sashiko-bot
2026-09-11 1:41 ` Tengda Wu
2026-09-08 13:05 ` [PATCH v5 22/26] perf annotate-arm64: Support 'mov' instruction tracking Tengda Wu
2026-09-08 13:27 ` sashiko-bot
2026-09-11 2:22 ` Tengda Wu
2026-09-08 13:05 ` [PATCH v5 23/26] perf annotate-arm64: Support 'add' " Tengda Wu
2026-09-08 13:27 ` sashiko-bot
2026-09-11 2:29 ` Tengda Wu
2026-09-08 13:06 ` [PATCH v5 24/26] perf annotate-arm64: Support 'adrp' instruction to track global variables Tengda Wu
2026-09-08 13:26 ` sashiko-bot
2026-09-08 13:06 ` [PATCH v5 25/26] perf annotate-arm64: Support per-cpu variable access tracking Tengda Wu
2026-09-08 13:30 ` sashiko-bot
2026-09-11 10:15 ` Tengda Wu [this message]
2026-09-08 13:06 ` [PATCH v5 26/26] perf annotate-arm64: Support 'mrs' instruction to track 'current' pointer Tengda Wu
2026-09-08 13:31 ` 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=05e0e407-c4d1-44e2-9d88-b170f57eb663@huaweicloud.com \
--to=wutengda@huaweicloud.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox