linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf symbols: Ignore mapping symbols on riscv
@ 2025-04-09  2:51 Haibo Xu
  2025-04-11  0:53 ` Namhyung Kim
  2025-06-02 22:12 ` patchwork-bot+linux-riscv
  0 siblings, 2 replies; 4+ messages in thread
From: Haibo Xu @ 2025-04-09  2:51 UTC (permalink / raw)
  Cc: xiaobo55x, Haibo Xu, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
	Liang, Kan, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Alexandre Ghiti, Stephen Brennan, linux-perf-users, linux-kernel,
	linux-riscv

RISCV ELF use mapping symbols with special names $x, $d to
identify regions of RISCV code or code with different ISAs[1].
These symbols don't identify functions, so will confuse the
perf output.

The patch filters out these symbols at load time, similar to
"4886f2ca perf symbols: Ignore mapping symbols on aarch64".

[1] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/
    master/riscv-elf.adoc#mapping-symbol

Signed-off-by: Haibo Xu <haibo1.xu@intel.com>
---
 tools/perf/util/symbol-elf.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index fbf6d0f73af9..55b1409b0593 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -1733,6 +1733,12 @@ dso__load_sym_internal(struct dso *dso, struct map *map, struct symsrc *syms_ss,
 				continue;
 		}
 
+		/* Reject RISCV ELF "mapping symbols" */
+		if (ehdr.e_machine == EM_RISCV) {
+			if (elf_name[0] == '$' && strchr("dx", elf_name[1]))
+				continue;
+		}
+
 		if (runtime_ss->opdsec && sym.st_shndx == runtime_ss->opdidx) {
 			u32 offset = sym.st_value - syms_ss->opdshdr.sh_addr;
 			u64 *opd = opddata->d_buf + offset;
-- 
2.43.0


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

* Re: [PATCH] perf symbols: Ignore mapping symbols on riscv
  2025-04-09  2:51 [PATCH] perf symbols: Ignore mapping symbols on riscv Haibo Xu
@ 2025-04-11  0:53 ` Namhyung Kim
  2025-05-19  8:13   ` Haibo Xu
  2025-06-02 22:12 ` patchwork-bot+linux-riscv
  1 sibling, 1 reply; 4+ messages in thread
From: Namhyung Kim @ 2025-04-11  0:53 UTC (permalink / raw)
  To: Haibo Xu
  Cc: xiaobo55x, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Liang, Kan, Paul Walmsley, Palmer Dabbelt,
	Albert Ou, Alexandre Ghiti, Stephen Brennan, linux-perf-users,
	linux-kernel, linux-riscv

Hello,

On Wed, Apr 09, 2025 at 10:51:56AM +0800, Haibo Xu wrote:
> RISCV ELF use mapping symbols with special names $x, $d to
> identify regions of RISCV code or code with different ISAs[1].
> These symbols don't identify functions, so will confuse the
> perf output.
> 
> The patch filters out these symbols at load time, similar to
> "4886f2ca perf symbols: Ignore mapping symbols on aarch64".
> 
> [1] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/
>     master/riscv-elf.adoc#mapping-symbol
> 
> Signed-off-by: Haibo Xu <haibo1.xu@intel.com>

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung


> ---
>  tools/perf/util/symbol-elf.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
> index fbf6d0f73af9..55b1409b0593 100644
> --- a/tools/perf/util/symbol-elf.c
> +++ b/tools/perf/util/symbol-elf.c
> @@ -1733,6 +1733,12 @@ dso__load_sym_internal(struct dso *dso, struct map *map, struct symsrc *syms_ss,
>  				continue;
>  		}
>  
> +		/* Reject RISCV ELF "mapping symbols" */
> +		if (ehdr.e_machine == EM_RISCV) {
> +			if (elf_name[0] == '$' && strchr("dx", elf_name[1]))
> +				continue;
> +		}
> +
>  		if (runtime_ss->opdsec && sym.st_shndx == runtime_ss->opdidx) {
>  			u32 offset = sym.st_value - syms_ss->opdshdr.sh_addr;
>  			u64 *opd = opddata->d_buf + offset;
> -- 
> 2.43.0
> 

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

* Re: [PATCH] perf symbols: Ignore mapping symbols on riscv
  2025-04-11  0:53 ` Namhyung Kim
@ 2025-05-19  8:13   ` Haibo Xu
  0 siblings, 0 replies; 4+ messages in thread
From: Haibo Xu @ 2025-05-19  8:13 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Haibo Xu, Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Ian Rogers,
	Adrian Hunter, Liang, Kan, Paul Walmsley, Palmer Dabbelt,
	Albert Ou, Alexandre Ghiti, Stephen Brennan, linux-perf-users,
	linux-kernel, linux-riscv

kindly ping.

Regards,
Haibo

On Fri, Apr 11, 2025 at 8:53 AM Namhyung Kim <namhyung@kernel.org> wrote:
>
> Hello,
>
> On Wed, Apr 09, 2025 at 10:51:56AM +0800, Haibo Xu wrote:
> > RISCV ELF use mapping symbols with special names $x, $d to
> > identify regions of RISCV code or code with different ISAs[1].
> > These symbols don't identify functions, so will confuse the
> > perf output.
> >
> > The patch filters out these symbols at load time, similar to
> > "4886f2ca perf symbols: Ignore mapping symbols on aarch64".
> >
> > [1] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/
> >     master/riscv-elf.adoc#mapping-symbol
> >
> > Signed-off-by: Haibo Xu <haibo1.xu@intel.com>
>
> Acked-by: Namhyung Kim <namhyung@kernel.org>
>
> Thanks,
> Namhyung
>
>
> > ---
> >  tools/perf/util/symbol-elf.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
> > index fbf6d0f73af9..55b1409b0593 100644
> > --- a/tools/perf/util/symbol-elf.c
> > +++ b/tools/perf/util/symbol-elf.c
> > @@ -1733,6 +1733,12 @@ dso__load_sym_internal(struct dso *dso, struct map *map, struct symsrc *syms_ss,
> >                               continue;
> >               }
> >
> > +             /* Reject RISCV ELF "mapping symbols" */
> > +             if (ehdr.e_machine == EM_RISCV) {
> > +                     if (elf_name[0] == '$' && strchr("dx", elf_name[1]))
> > +                             continue;
> > +             }
> > +
> >               if (runtime_ss->opdsec && sym.st_shndx == runtime_ss->opdidx) {
> >                       u32 offset = sym.st_value - syms_ss->opdshdr.sh_addr;
> >                       u64 *opd = opddata->d_buf + offset;
> > --
> > 2.43.0
> >

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

* Re: [PATCH] perf symbols: Ignore mapping symbols on riscv
  2025-04-09  2:51 [PATCH] perf symbols: Ignore mapping symbols on riscv Haibo Xu
  2025-04-11  0:53 ` Namhyung Kim
@ 2025-06-02 22:12 ` patchwork-bot+linux-riscv
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+linux-riscv @ 2025-06-02 22:12 UTC (permalink / raw)
  To: Haibo Xu
  Cc: linux-riscv, xiaobo55x, peterz, mingo, acme, namhyung,
	mark.rutland, alexander.shishkin, jolsa, irogers, adrian.hunter,
	kan.liang, paul.walmsley, palmer, aou, alex, stephen.s.brennan,
	linux-perf-users, linux-kernel

Hello:

This patch was applied to riscv/linux.git (for-next)
by Palmer Dabbelt <palmer@dabbelt.com>:

On Wed,  9 Apr 2025 10:51:56 +0800 you wrote:
> RISCV ELF use mapping symbols with special names $x, $d to
> identify regions of RISCV code or code with different ISAs[1].
> These symbols don't identify functions, so will confuse the
> perf output.
> 
> The patch filters out these symbols at load time, similar to
> "4886f2ca perf symbols: Ignore mapping symbols on aarch64".
> 
> [...]

Here is the summary with links:
  - perf symbols: Ignore mapping symbols on riscv
    https://git.kernel.org/riscv/c/e4c39a45a0ea

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2025-06-02 22:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-09  2:51 [PATCH] perf symbols: Ignore mapping symbols on riscv Haibo Xu
2025-04-11  0:53 ` Namhyung Kim
2025-05-19  8:13   ` Haibo Xu
2025-06-02 22:12 ` patchwork-bot+linux-riscv

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).