From: "Edwin Török" <edwin@etorok.net>
To: linux-riscv@lists.infradead.org
Cc: "Edwin Török" <edwin@etorok.net>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
"Arnaldo Carvalho de Melo" <acme@kernel.org>,
"Fabian Hemmer" <copy@copy.sh>, "Ingo Molnar" <mingo@redhat.com>,
"Jiri Olsa" <jolsa@redhat.com>,
"John Garry" <john.garry@huawei.com>,
"Leo Yan" <leo.yan@linaro.org>,
"Namhyung Kim" <namhyung@kernel.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Remi Bernon" <rbernon@codeweavers.com>,
"Rob Herring" <robh@kernel.org>,
linux-perf-users@vger.kernel.org
Subject: [PATCH 0/4] RISC-V: make perf record --call-graph=dwarf work
Date: Tue, 6 Jul 2021 00:25:20 +0100 [thread overview]
Message-ID: <20210705232524.4024832-1-edwin@etorok.net> (raw)
Currently perf on RISC-V cannot gather callgraphs when built without frame pointers.
After this series is applied, and using a trunk version of OCaml (which emits DWARF CFI)
I can successfully get callgraphs from an OCaml program.
Note that the default cpu-cycles event doesn't work, but that is unrelated.
Tested on HiFive Unmatched:
```
# perf record --user-regs=?
available registers: pc ra sp gp tp t0 t1 t2 s0 s1 a0 a1 a2 a3 a4 a5 a6 a7
s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 t3 t4 t5 t6
# sed -e 's/(\*\*//' -e 's/\*\*)//' \
testsuite/tests/misc-unsafe/almabench.ml >almabench_benchmark.ml
# ocamlopt almabench_benchmark.ml -unsafe -o almabench_benchmark
# perf record -e cpu-clock -v --call-graph=dwarf -F 99 \
./almabench_benchmark
callchain: type DWARF
callchain: stack dump size 8192
nr_cblocks: 0
affinity: SYS
mmap flush: 1
comp level: 0
mmap size 528384B
mmap size 528384B
Control descriptor is not initialized
0 17.00 -26.06
1 12.34 1.29
2 6.83 22.95
3 0.04 -1.26
4 2.30 12.54
5 2.93 14.35
6 21.27 -16.57
7 20.41 -19.04
[ perf record: Woken up 65 times to write data ]
Looking at the vmlinux_path (8 entries long)
Failed to open /proc/kcore.
Note /proc/kcore requires CAP_SYS_RAWIO capability to access.
Using /proc/kallsyms for symbols
failed to write feature CPUDESC
failed to write feature CPUID
failed to write feature NUMA_TOPOLOGY
failed to write feature MEM_TOPOLOGY
[ perf record: Captured and wrote 16.265 MB perf.data (1997 samples) ]
# perf script
...
almabench_bench 1193 14816.399235: 10101010 cpu-clock:
3fbbd63d54 reduce_sincos+0x268 (inlined)
3fbbd63d54 __cos+0x268 (/lib/libm-2.33.so)
2aac4b261b Almabench_benchmark.planetpv+0x25f
(/home/root/ocaml/almabench_benchmark)
2aac4b3e03 Almabench_benchmark.entry+0x12bb
(/home/root/ocaml/almabench_benchmark)
2aac4b0097 caml_program+0x143
(/home/root/ocaml/almabench_benchmark)
2aac4e4e3d caml_start_program+0x71
(/home/root/ocaml/almabench_benchmark)
2aac4e5409 caml_startup_common+0x18f
(/home/root/ocaml/almabench_benchmark)
2aac4e5465 caml_startup_exn+0x9 (inlined)
2aac4e5465 caml_startup+0x9 (inlined)
2aac4e5465 caml_main+0x9
(/home/root/ocaml/almabench_benchmark)
2aac4afe89 main+0x9
(/home/root/ocaml/almabench_benchmark)
3fbbc47b0b __libc_start_main+0x85 (/lib/libc-2.33.so)
2aac4afebb _start+0x2b (/home/root/ocaml/almabench_benchmark)
```
Edwin Török (4):
tools/perf/arch/riscv: record registers needed for --call-graph=dwarf
tools/perf: add riscv perf_regs.h to check_headers.sh
MAINTAINERS: add tools/perf/arch/riscv
tools/perf/arch/riscv: add libdw unwind test
MAINTAINERS | 1 +
tools/perf/arch/riscv/Build | 1 +
tools/perf/arch/riscv/include/arch-tests.h | 12 +++++
tools/perf/arch/riscv/include/perf_regs.h | 2 +
tools/perf/arch/riscv/tests/Build | 4 ++
tools/perf/arch/riscv/tests/arch-tests.c | 16 ++++++
tools/perf/arch/riscv/tests/dwarf-unwind.c | 63 ++++++++++++++++++++++
tools/perf/arch/riscv/tests/regs_load.S | 45 ++++++++++++++++
tools/perf/arch/riscv/util/perf_regs.c | 32 +++++++++++
tools/perf/check-headers.sh | 1 +
tools/perf/tests/Build | 2 +-
11 files changed, 178 insertions(+), 1 deletion(-)
create mode 100644 tools/perf/arch/riscv/include/arch-tests.h
create mode 100644 tools/perf/arch/riscv/tests/Build
create mode 100644 tools/perf/arch/riscv/tests/arch-tests.c
create mode 100644 tools/perf/arch/riscv/tests/dwarf-unwind.c
create mode 100644 tools/perf/arch/riscv/tests/regs_load.S
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Fabian Hemmer <copy@copy.sh>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Remi Bernon <rbernon@codeweavers.com>
Cc: Rob Herring <robh@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Cc: linux-riscv@lists.infradead.org
base-commit: c76826a65f50038f050424365dbf3f97203f8710
prerequisite-patch-id: 7144f880f49c60cdec11fcbae019e764ba37a73d
--
2.31.1
next reply other threads:[~2021-07-05 23:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-05 23:25 Edwin Török [this message]
2021-07-05 23:25 ` [PATCH 1/4] tools/perf/arch/riscv: record registers needed for --call-graph=dwarf Edwin Török
2021-08-04 4:22 ` Palmer Dabbelt
2021-08-04 18:39 ` Edwin Török
2021-07-05 23:25 ` [PATCH 4/4] tools/perf/arch/riscv: add libdw unwind test Edwin Török
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=20210705232524.4024832-1-edwin@etorok.net \
--to=edwin@etorok.net \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=aou@eecs.berkeley.edu \
--cc=copy@copy.sh \
--cc=john.garry@huawei.com \
--cc=jolsa@redhat.com \
--cc=leo.yan@linaro.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=peterz@infradead.org \
--cc=rbernon@codeweavers.com \
--cc=robh@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).