All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf riscv: fix register name strings
@ 2026-06-08 19:26 Martin Kaiser
  2026-06-08 20:08 ` Ian Rogers
  0 siblings, 1 reply; 6+ messages in thread
From: Martin Kaiser @ 2026-06-08 19:26 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Namhyung Kim, Ian Rogers
  Cc: linux-perf-users, linux-kernel, Martin Kaiser

On risc-v, pref probe generates an invalid syntax for a named register in
a kprobe.

$ perf probe --debug verbose --add "n_tty_write tty"
...
Writing event: p:probe/n_tty_write _text+8922528 tty=%"%a0":x64
Failed to write event: Invalid argument

The problem is the combination of

   #define REG_DWARFNUM_NAME(reg, idx) [idx] = "%" #reg

and entries such as

   REG_DWARFNUM_NAME("%a0", 10)

where #reg will escape the quotes of the first macro parameter.

Update the macro definition to produce the correct syntax for a named
register in a kprobe, i.e. the unquoted register name with only one
leading %.

Fixes: a90c4519186d ("perf riscv: Remove dwarf-regs.c and add dwarf-regs-table.h")
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
 tools/perf/arch/riscv/include/dwarf-regs-table.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/arch/riscv/include/dwarf-regs-table.h b/tools/perf/arch/riscv/include/dwarf-regs-table.h
index a45b63a6d5a8..c0a6e84e7a75 100644
--- a/tools/perf/arch/riscv/include/dwarf-regs-table.h
+++ b/tools/perf/arch/riscv/include/dwarf-regs-table.h
@@ -2,7 +2,7 @@
 #ifdef DEFINE_DWARF_REGSTR_TABLE
 /* This is included in perf/util/dwarf-regs.c */
 
-#define REG_DWARFNUM_NAME(reg, idx)	[idx] = "%" #reg
+#define REG_DWARFNUM_NAME(reg, idx)	[idx] = reg
 
 static const char * const riscv_regstr_tbl[] = {
 	REG_DWARFNUM_NAME("%zero", 0),
-- 
2.43.7


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf riscv: fix register name strings
  2026-06-08 19:26 [PATCH] perf riscv: fix register name strings Martin Kaiser
@ 2026-06-08 20:08 ` Ian Rogers
  2026-06-08 20:18   ` Arnaldo Carvalho de Melo
  2026-06-08 20:27   ` Arnaldo Carvalho de Melo
  0 siblings, 2 replies; 6+ messages in thread
From: Ian Rogers @ 2026-06-08 20:08 UTC (permalink / raw)
  To: Martin Kaiser
  Cc: Arnaldo Carvalho de Melo, Namhyung Kim, linux-perf-users,
	linux-kernel

On Mon, Jun 8, 2026 at 12:27 PM Martin Kaiser <martin@kaiser.cx> wrote:
>
> On risc-v, pref probe generates an invalid syntax for a named register in
> a kprobe.
>
> $ perf probe --debug verbose --add "n_tty_write tty"
> ...
> Writing event: p:probe/n_tty_write _text+8922528 tty=%"%a0":x64
> Failed to write event: Invalid argument
>
> The problem is the combination of
>
>    #define REG_DWARFNUM_NAME(reg, idx) [idx] = "%" #reg
>
> and entries such as
>
>    REG_DWARFNUM_NAME("%a0", 10)
>
> where #reg will escape the quotes of the first macro parameter.
>
> Update the macro definition to produce the correct syntax for a named
> register in a kprobe, i.e. the unquoted register name with only one
> leading %.
>
> Fixes: a90c4519186d ("perf riscv: Remove dwarf-regs.c and add dwarf-regs-table.h")
> Signed-off-by: Martin Kaiser <martin@kaiser.cx>

Reviewed-by: Ian Rogers <irogers@google.com>

Thanks for catching this! Sashiko is also green for this change:
https://sashiko.dev/#/patchset/20260608192731.708606-1-martin%40kaiser.cx

Thanks,
Ian

> ---
>  tools/perf/arch/riscv/include/dwarf-regs-table.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/arch/riscv/include/dwarf-regs-table.h b/tools/perf/arch/riscv/include/dwarf-regs-table.h
> index a45b63a6d5a8..c0a6e84e7a75 100644
> --- a/tools/perf/arch/riscv/include/dwarf-regs-table.h
> +++ b/tools/perf/arch/riscv/include/dwarf-regs-table.h
> @@ -2,7 +2,7 @@
>  #ifdef DEFINE_DWARF_REGSTR_TABLE
>  /* This is included in perf/util/dwarf-regs.c */
>
> -#define REG_DWARFNUM_NAME(reg, idx)    [idx] = "%" #reg
> +#define REG_DWARFNUM_NAME(reg, idx)    [idx] = reg
>
>  static const char * const riscv_regstr_tbl[] = {
>         REG_DWARFNUM_NAME("%zero", 0),
> --
> 2.43.7
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf riscv: fix register name strings
  2026-06-08 20:08 ` Ian Rogers
@ 2026-06-08 20:18   ` Arnaldo Carvalho de Melo
  2026-06-08 20:27   ` Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-06-08 20:18 UTC (permalink / raw)
  To: Ian Rogers; +Cc: Martin Kaiser, Namhyung Kim, linux-perf-users, linux-kernel

On Mon, Jun 08, 2026 at 01:08:28PM -0700, Ian Rogers wrote:
> On Mon, Jun 8, 2026 at 12:27 PM Martin Kaiser <martin@kaiser.cx> wrote:
> >
> > On risc-v, pref probe generates an invalid syntax for a named register in
> > a kprobe.
> >
> > $ perf probe --debug verbose --add "n_tty_write tty"
> > ...
> > Writing event: p:probe/n_tty_write _text+8922528 tty=%"%a0":x64
> > Failed to write event: Invalid argument
> >
> > The problem is the combination of
> >
> >    #define REG_DWARFNUM_NAME(reg, idx) [idx] = "%" #reg
> >
> > and entries such as
> >
> >    REG_DWARFNUM_NAME("%a0", 10)
> >
> > where #reg will escape the quotes of the first macro parameter.
> >
> > Update the macro definition to produce the correct syntax for a named
> > register in a kprobe, i.e. the unquoted register name with only one
> > leading %.
> >
> > Fixes: a90c4519186d ("perf riscv: Remove dwarf-regs.c and add dwarf-regs-table.h")
> > Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> 
> Reviewed-by: Ian Rogers <irogers@google.com>
> 
> Thanks for catching this! Sashiko is also green for this change:
> https://sashiko.dev/#/patchset/20260608192731.708606-1-martin%40kaiser.cx

Thanks, applying.

- Arnaldo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf riscv: fix register name strings
  2026-06-08 20:08 ` Ian Rogers
  2026-06-08 20:18   ` Arnaldo Carvalho de Melo
@ 2026-06-08 20:27   ` Arnaldo Carvalho de Melo
  2026-06-08 20:42     ` Arnaldo Carvalho de Melo
  1 sibling, 1 reply; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-06-08 20:27 UTC (permalink / raw)
  To: Ian Rogers; +Cc: Martin Kaiser, Namhyung Kim, linux-perf-users, linux-kernel

On Mon, Jun 08, 2026 at 01:08:28PM -0700, Ian Rogers wrote:
> On Mon, Jun 8, 2026 at 12:27 PM Martin Kaiser <martin@kaiser.cx> wrote:
> >
> > On risc-v, pref probe generates an invalid syntax for a named register in
> > a kprobe.
> >
> > $ perf probe --debug verbose --add "n_tty_write tty"
> > ...
> > Writing event: p:probe/n_tty_write _text+8922528 tty=%"%a0":x64
> > Failed to write event: Invalid argument
> >
> > The problem is the combination of
> >
> >    #define REG_DWARFNUM_NAME(reg, idx) [idx] = "%" #reg
> >
> > and entries such as
> >
> >    REG_DWARFNUM_NAME("%a0", 10)
> >
> > where #reg will escape the quotes of the first macro parameter.
> >
> > Update the macro definition to produce the correct syntax for a named
> > register in a kprobe, i.e. the unquoted register name with only one
> > leading %.
> >
> > Fixes: a90c4519186d ("perf riscv: Remove dwarf-regs.c and add dwarf-regs-table.h")
> > Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> 
> Reviewed-by: Ian Rogers <irogers@google.com>
> 
> Thanks for catching this! Sashiko is also green for this change:
> https://sashiko.dev/#/patchset/20260608192731.708606-1-martin%40kaiser.cx

Strange,

  LD      /tmp/build/perf-tools-next/tests/perf-test-in.o
  LD      /tmp/build/perf-tools-next/perf-test-in.o
In file included from util/dwarf-regs.c:23:
util/../arch/riscv/include/dwarf-regs-table.h:5:9: error: ‘REG_DWARFNUM_NAME’ redefined [-Werror]
    5 | #define REG_DWARFNUM_NAME(reg, idx)     [idx] = reg
      |         ^~~~~~~~~~~~~~~~~
In file included from util/dwarf-regs.c:22:
util/../arch/powerpc/include/dwarf-regs-table.h:10:9: note: this is the location of the previous definition
   10 | #define REG_DWARFNUM_NAME(reg, idx)     [idx] = "%" #reg
      |         ^~~~~~~~~~~~~~~~~
In file included from util/dwarf-regs.c:24:
util/../arch/s390/include/dwarf-regs-table.h:5:9: error: ‘REG_DWARFNUM_NAME’ redefined [-Werror]
    5 | #define REG_DWARFNUM_NAME(reg, idx)     [idx] = "%" #reg
      |         ^~~~~~~~~~~~~~~~~
util/../arch/riscv/include/dwarf-regs-table.h:5:9: note: this is the location of the previous definition
    5 | #define REG_DWARFNUM_NAME(reg, idx)     [idx] = reg
      |         ^~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[4]: *** [/home/acme/git/perf-tools-next/tools/build/Makefile.build:96: /tmp/build/perf-tools-next/util/dwarf-regs.o] Error 1


Trying to figure out why Sashiko is green on it but it doesn't buind
here...

- Arnaldo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf riscv: fix register name strings
  2026-06-08 20:27   ` Arnaldo Carvalho de Melo
@ 2026-06-08 20:42     ` Arnaldo Carvalho de Melo
  2026-06-09  7:32       ` Martin Kaiser
  0 siblings, 1 reply; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-06-08 20:42 UTC (permalink / raw)
  To: Ian Rogers; +Cc: Martin Kaiser, Namhyung Kim, linux-perf-users, linux-kernel

On Mon, Jun 08, 2026 at 05:27:03PM -0300, Arnaldo Carvalho de Melo wrote:
> On Mon, Jun 08, 2026 at 01:08:28PM -0700, Ian Rogers wrote:
> > On Mon, Jun 8, 2026 at 12:27 PM Martin Kaiser <martin@kaiser.cx> wrote:
> > >
> > > On risc-v, pref probe generates an invalid syntax for a named register in
> > > a kprobe.
> > >
> > > $ perf probe --debug verbose --add "n_tty_write tty"
> > > ...
> > > Writing event: p:probe/n_tty_write _text+8922528 tty=%"%a0":x64
> > > Failed to write event: Invalid argument
> > >
> > > The problem is the combination of
> > >
> > >    #define REG_DWARFNUM_NAME(reg, idx) [idx] = "%" #reg
> > >
> > > and entries such as
> > >
> > >    REG_DWARFNUM_NAME("%a0", 10)
> > >
> > > where #reg will escape the quotes of the first macro parameter.
> > >
> > > Update the macro definition to produce the correct syntax for a named
> > > register in a kprobe, i.e. the unquoted register name with only one
> > > leading %.
> > >
> > > Fixes: a90c4519186d ("perf riscv: Remove dwarf-regs.c and add dwarf-regs-table.h")
> > > Signed-off-by: Martin Kaiser <martin@kaiser.cx>
> > 
> > Reviewed-by: Ian Rogers <irogers@google.com>
> > 
> > Thanks for catching this! Sashiko is also green for this change:
> > https://sashiko.dev/#/patchset/20260608192731.708606-1-martin%40kaiser.cx
> 
> Strange,
> 
>   LD      /tmp/build/perf-tools-next/tests/perf-test-in.o
>   LD      /tmp/build/perf-tools-next/perf-test-in.o
> In file included from util/dwarf-regs.c:23:
> util/../arch/riscv/include/dwarf-regs-table.h:5:9: error: ‘REG_DWARFNUM_NAME’ redefined [-Werror]
>     5 | #define REG_DWARFNUM_NAME(reg, idx)     [idx] = reg
>       |         ^~~~~~~~~~~~~~~~~
> In file included from util/dwarf-regs.c:22:
> util/../arch/powerpc/include/dwarf-regs-table.h:10:9: note: this is the location of the previous definition
>    10 | #define REG_DWARFNUM_NAME(reg, idx)     [idx] = "%" #reg
>       |         ^~~~~~~~~~~~~~~~~
> In file included from util/dwarf-regs.c:24:
> util/../arch/s390/include/dwarf-regs-table.h:5:9: error: ‘REG_DWARFNUM_NAME’ redefined [-Werror]
>     5 | #define REG_DWARFNUM_NAME(reg, idx)     [idx] = "%" #reg
>       |         ^~~~~~~~~~~~~~~~~
> util/../arch/riscv/include/dwarf-regs-table.h:5:9: note: this is the location of the previous definition
>     5 | #define REG_DWARFNUM_NAME(reg, idx)     [idx] = reg
>       |         ^~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
> make[4]: *** [/home/acme/git/perf-tools-next/tools/build/Makefile.build:96: /tmp/build/perf-tools-next/util/dwarf-regs.o] Error 1
> 
> 
> Trying to figure out why Sashiko is green on it but it doesn't build
> here...

C preprocessor benign redefinition rule kicked in, this is a preexisting
problem, the headers need to undef that REG_DWARFNUM_NAME that now is
different in one of the headers, Risc-V's.

I'll cook up a patch to merge before this one.

- Arnaldo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] perf riscv: fix register name strings
  2026-06-08 20:42     ` Arnaldo Carvalho de Melo
@ 2026-06-09  7:32       ` Martin Kaiser
  0 siblings, 0 replies; 6+ messages in thread
From: Martin Kaiser @ 2026-06-09  7:32 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ian Rogers, Namhyung Kim, linux-perf-users, linux-kernel

Thus wrote Arnaldo Carvalho de Melo (acme@kernel.org):

> On Mon, Jun 08, 2026 at 05:27:03PM -0300, Arnaldo Carvalho de Melo wrote:
> > On Mon, Jun 08, 2026 at 01:08:28PM -0700, Ian Rogers wrote:
> > > On Mon, Jun 8, 2026 at 12:27 PM Martin Kaiser <martin@kaiser.cx> wrote:

> > > > On risc-v, pref probe generates an invalid syntax for a named register in
> > > > a kprobe.

> > > > $ perf probe --debug verbose --add "n_tty_write tty"
> > > > ...
> > > > Writing event: p:probe/n_tty_write _text+8922528 tty=%"%a0":x64
> > > > Failed to write event: Invalid argument

> > > > The problem is the combination of

> > > >    #define REG_DWARFNUM_NAME(reg, idx) [idx] = "%" #reg

> > > > and entries such as

> > > >    REG_DWARFNUM_NAME("%a0", 10)

> > > > where #reg will escape the quotes of the first macro parameter.

> > > > Update the macro definition to produce the correct syntax for a named
> > > > register in a kprobe, i.e. the unquoted register name with only one
> > > > leading %.

> > > > Fixes: a90c4519186d ("perf riscv: Remove dwarf-regs.c and add dwarf-regs-table.h")
> > > > Signed-off-by: Martin Kaiser <martin@kaiser.cx>

> > > Reviewed-by: Ian Rogers <irogers@google.com>

> > > Thanks for catching this! Sashiko is also green for this change:
> > > https://sashiko.dev/#/patchset/20260608192731.708606-1-martin%40kaiser.cx

> > Strange,

> >   LD      /tmp/build/perf-tools-next/tests/perf-test-in.o
> >   LD      /tmp/build/perf-tools-next/perf-test-in.o
> > In file included from util/dwarf-regs.c:23:
> > util/../arch/riscv/include/dwarf-regs-table.h:5:9: error: ‘REG_DWARFNUM_NAME’ redefined [-Werror]
> >     5 | #define REG_DWARFNUM_NAME(reg, idx)     [idx] = reg
> >       |         ^~~~~~~~~~~~~~~~~
> > In file included from util/dwarf-regs.c:22:
> > util/../arch/powerpc/include/dwarf-regs-table.h:10:9: note: this is the location of the previous definition
> >    10 | #define REG_DWARFNUM_NAME(reg, idx)     [idx] = "%" #reg
> >       |         ^~~~~~~~~~~~~~~~~
> > In file included from util/dwarf-regs.c:24:
> > util/../arch/s390/include/dwarf-regs-table.h:5:9: error: ‘REG_DWARFNUM_NAME’ redefined [-Werror]
> >     5 | #define REG_DWARFNUM_NAME(reg, idx)     [idx] = "%" #reg
> >       |         ^~~~~~~~~~~~~~~~~
> > util/../arch/riscv/include/dwarf-regs-table.h:5:9: note: this is the location of the previous definition
> >     5 | #define REG_DWARFNUM_NAME(reg, idx)     [idx] = reg
> >       |         ^~~~~~~~~~~~~~~~~
> > cc1: all warnings being treated as errors
> > make[4]: *** [/home/acme/git/perf-tools-next/tools/build/Makefile.build:96: /tmp/build/perf-tools-next/util/dwarf-regs.o] Error 1


> > Trying to figure out why Sashiko is green on it but it doesn't build
> > here...

> C preprocessor benign redefinition rule kicked in, this is a preexisting
> problem, the headers need to undef that REG_DWARFNUM_NAME that now is
> different in one of the headers, Risc-V's.

> I'll cook up a patch to merge before this one.

I see. We need an undef for risc-v, similar to mips.

Let me send a v2 so we have all in one patch, that should be simpler to
backport to stable.

Thanks,
Martin

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-06-09  7:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-08 19:26 [PATCH] perf riscv: fix register name strings Martin Kaiser
2026-06-08 20:08 ` Ian Rogers
2026-06-08 20:18   ` Arnaldo Carvalho de Melo
2026-06-08 20:27   ` Arnaldo Carvalho de Melo
2026-06-08 20:42     ` Arnaldo Carvalho de Melo
2026-06-09  7:32       ` Martin Kaiser

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.