]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
perf annotate: Track arithmetic instructions on pointers
authorZecheng Li <zecheng@google.com>
Mon, 13 Oct 2025 18:16:00 +0000 (18:16 +0000)
committerNamhyung Kim <namhyung@kernel.org>
Tue, 21 Oct 2025 13:02:49 +0000 (06:02 -0700)
commit1f4cc4ae3f8ae661bae3722e973a0f5be650fcbf
treef9b831524882a12f403593844f98e637c5b724df
parent24a30ce9b14ce84b00105b970c4d16eabe09a62a
perf annotate: Track arithmetic instructions on pointers

Track the arithmetic operations on registers with pointer types. We
handle only add, sub and lea instructions. The original pointer
information needs to be preserved for getting outermost struct types.
For example, reg0 points to a struct cfs_rq, when we add 0x10 to reg0,
it should preserve the information of struct cfs_rq + 0x10 in the
register instead of a pointer type to the child field at 0x10.

Details:

1.  struct type_state_reg now includes an offset, indicating if the
    register points to the start or an internal part of its associated
    type. This offset is used in mem to reg and reg to stack mem
    transfers, and also applied to the final type offset.

2.  lea offset(%sp/%fp), reg is now treated as taking the address of a
    stack variable. It worked fine in most cases, but an issue with this
    approach is the pointer type may not exist.

3.  lea offset(%base), reg is handled by moving the type from %base and
    adding an offset, similar to an add operation followed by a mov reg
    to reg.

4.  Non-stack variables from DWARF with non-zero offsets in their
    location expressions are now accepted with register offset tracking.

Multi-register addressing modes in LEA are not supported.

Signed-off-by: Zecheng Li <zecheng@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/arch/x86/annotate/instructions.c
tools/perf/util/annotate-data.c
tools/perf/util/annotate-data.h