[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250523-b4-ctr_upstream_v3-v3-0-ad355304ba1c@rivosinc.com>
Date: Fri, 23 May 2025 00:25:06 +0100
From: Rajnesh Kanwal <rkanwal@...osinc.com>
To: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Namhyung Kim <namhyung@...nel.org>, Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>, Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>, Albert Ou <aou@...s.berkeley.edu>,
Alexandre Ghiti <alex@...ti.fr>, Atish Kumar Patra <atishp@...osinc.com>,
Anup Patel <anup@...infault.org>, Will Deacon <will@...nel.org>,
Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, Beeman Strong <beeman@...osinc.com>
Cc: linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-riscv@...ts.infradead.org, linux-arm-kernel@...ts.infradead.org,
Palmer Dabbelt <palmer@...ive.com>, Conor Dooley <conor@...nel.org>,
devicetree@...r.kernel.org, Rajnesh Kanwal <rkanwal@...osinc.com>
Subject: [PATCH v3 0/7] riscv: pmu: Add support for Control Transfer
Records Ext.
This series enables Control Transfer Records extension support on riscv
architecture. This extension is similar to Arch LBR in x86 and BRBE in ARM.
The Extension has been ratified and latest release can be found here [0]
CTR extension depends on both the implementation of S-mode and Sscsrind
extension v1.0.0 [1]. CTR access ctrsource, ctrtartget and ctrdata CSRs
using sscsrind extension.
The series is based on Smcdeleg/Ssccfg counter delegation extension [2]
patches [3]. CTR itself doesn't depend on counter delegation support. This
rebase is basically to include the Smcsrind patches.
The last patch is in the perf tool to allow processing 256 entries. Without
this perf seems to consider that sample as corrupted and discards it.
Here is the link to a quick guide [4] to setup and run a basic perf demo on
Linux to use CTR Ext.
Qemu patches are merged upstream:
https://lore.kernel.org/qemu-devel/20250205-b4-ctr_upstream_v6-v6-0-439d8e06c8ef@rivosinc.com/
Opensbi patch is merged upstream:
https://lore.kernel.org/opensbi/20250307124451.122828-1-rkanwal@rivosinc.com/
Linux kernel patches can be found here:
https://github.com/rajnesh-kanwal/linux/tree/b4/ctr_upstream_v3
[0]: https://github.com/riscv/riscv-control-transfer-records/releases/tag/v1.0
[1]: https://github.com/riscvarchive/riscv-indirect-csr-access/releases/tag/v1.0.0
[2]: https://github.com/riscvarchive/riscv-smcdeleg-ssccfg/releases/tag/v1.0.0
[3]: https://lore.kernel.org/lkml/20250114-counter_delegation-v2-0-8ba74cdb851b@rivosinc.com/
[4]: https://github.com/rajnesh-kanwal/linux/wiki/Running-CTR-basic-demo-on-QEMU-RISC%E2%80%90V-Virt-machine
To: Peter Zijlstra <peterz@...radead.org>
To: Ingo Molnar <mingo@...hat.com>
To: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Namhyung Kim <namhyung@...nel.org>
To: Mark Rutland <mark.rutland@....com>
To: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
To: Jiri Olsa <jolsa@...nel.org>
To: Ian Rogers <irogers@...gle.com>
To: Adrian Hunter <adrian.hunter@...el.com>
To: Liang, Kan <kan.liang@...ux.intel.com>
To: Paul Walmsley <paul.walmsley@...ive.com>
To: Palmer Dabbelt <palmer@...belt.com>
To: Albert Ou <aou@...s.berkeley.edu>
To: Alexandre Ghiti <alex@...ti.fr>
To: Atish Kumar Patra <atishp@...osinc.com>
To: Anup Patel <anup@...infault.org>
To: Will Deacon <will@...nel.org>
To: Rob Herring <robh@...nel.org>
To: Krzysztof Kozlowski <krzk+dt@...nel.org>
To: Conor Dooley <conor+dt@...nel.org>
To: Beeman Strong <beeman@...osinc.com>
Cc: linux-perf-users@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
Cc: linux-riscv@...ts.infradead.org
Cc: linux-arm-kernel@...ts.infradead.org
Cc: Palmer Dabbelt <palmer@...ive.com>
Cc: Conor Dooley <conor@...nel.org>
Cc: devicetree@...r.kernel.org
Signed-off-by: Rajnesh Kanwal <rkanwal@...osinc.com>
---
Changelog:
v3:
- Added missing To/Cc, especially devicetree@...r.kernel.org
- Changed the commit description to better describe the need of
perf tool change that increases max sample size processing
capacity of remove_loops function.
- Minor fixes found while doing a virtualization PoC.
- Added the missing commit and repository information to dt-bindings,
indicating where the extension was ratified.
v2
- Added context save/restore support for tasks using CTR feature.
- https://lore.kernel.org/lkml/20250116230955.867152-1-rkanwal@rivosinc.com/
v1:
- https://lore.kernel.org/lkml/20240529185337.182722-1-rkanwal@rivosinc.com/
---
---
Rajnesh Kanwal (7):
perf: Increase the maximum number of branches remove_loops() can process.
riscv: pmu: Add Control transfer records CSR definations.
riscv: Add Control Transfer Records extension parsing
riscv: pmu: Add infrastructure for Control Transfer Record
riscv: pmu: Add driver for Control Transfer Records Ext.
riscv: pmu: Integrate CTR Ext support in riscv_pmu_dev driver
dt-bindings: riscv: add Sxctr ISA extension description
.../devicetree/bindings/riscv/extensions.yaml | 28 +
MAINTAINERS | 1 +
arch/riscv/include/asm/csr.h | 83 +++
arch/riscv/include/asm/hwcap.h | 4 +
arch/riscv/kernel/cpufeature.c | 2 +
drivers/perf/Kconfig | 11 +
drivers/perf/Makefile | 1 +
drivers/perf/riscv_ctr.c | 612 +++++++++++++++++++++
drivers/perf/riscv_pmu_common.c | 25 +-
drivers/perf/riscv_pmu_dev.c | 82 +++
drivers/perf/riscv_pmu_legacy.c | 2 +
include/linux/perf/riscv_pmu.h | 55 ++
tools/perf/util/machine.c | 21 +-
13 files changed, 918 insertions(+), 9 deletions(-)
---
base-commit: e0200e37637e573cd68f522ecd550be87e304c6c
change-id: 20250416-b4-ctr_upstream_v3-204f4b0b7481
Best regards,
--
Rajnesh Kanwal
Powered by blists - more mailing lists