]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
perf riscv: Add SDT argument parsing for RISC-V
authorChen Pei <cp0613@linux.alibaba.com>
Wed, 20 May 2026 13:40:04 +0000 (21:40 +0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 20 May 2026 16:29:23 +0000 (13:29 -0300)
commit6a082433bcc749f3e07bd2e28a733758ee875373
treef1470328c12ee720a40f1fcc1ba83b432f55a5d0
parente445b78ffb8d43440b9f417d6701826746114a0d
perf riscv: Add SDT argument parsing for RISC-V

Implement __perf_sdt_arg_parse_op_riscv() to convert RISC-V GCC-generated
SDT probe operands into uprobe-compatible format, and register it in the
perf_sdt_arg_parse_op() dispatcher for EM_RISCV.

RISC-V GCC uses the 'nor' constraint for SDT arguments, producing operands
in the following formats:

  Format       Example      Uprobe format
  -----------  -----------  -------------
  register     a0           %a0
  memory (+)   8(a0)        +8(%a0)
  memory (-)   -20(s0)      -20(%s0)
  constant     99           (skip, not supported by uprobe)

Key differences from other architectures:
 - Register names use ABI aliases (a0-a7, t0-t6, s0-s11, sp, ra, etc.)
   without any '%' prefix, unlike x86 (%rax) or arm64 (x0).
 - Memory operands use OFFSET(REG) syntax where OFFSET may be negative,
   unlike arm64's [sp, NUM] or powerpc's NUM(%rREG).

Two regexes are used:
 - SDT_OP_REGEX1: matches RISC-V ABI register names saved in pt_regs
 - SDT_OP_REGEX2: matches [-]NUM(REG) memory operands

Reviewed-by: Guo Ren <guoren@kernel.org>
Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Chen Pei <cp0613@linux.alibaba.com>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Walmsley <pjw@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/perf-regs-arch/perf_regs_riscv.c
tools/perf/util/perf_regs.c
tools/perf/util/perf_regs.h