From: Atish Patra <atish.patra@wdc.com> To: linux-kernel@vger.kernel.org Cc: Atish Patra <atish.patra@wdc.com>, Anup Patel <anup.patel@wdc.com>, bpf@vger.kernel.org, Daniel Lezcano <daniel.lezcano@linaro.org>, Guo Ren <guoren@linux.alibaba.com>, Heinrich Schuchardt <xypron.glpk@gmx.de>, Kefeng Wang <wangkefeng.wang@huawei.com>, linux-doc@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-riscv@lists.infradead.org, Nick Kossifidis <mick@ics.forth.gr>, Palmer Dabbelt <palmer@dabbelt.com>, Paul Walmsley <paul.walmsley@sifive.com>, Alan Kao <alankao@andestech.com>, Nick Hu <nickhu@andestech.com>, Vincent Chen <vincent.chen@sifive.com> Subject: [RFC v2 0/7] Improve RISC-V Perf support using SBI PMU extension Date: Fri, 28 May 2021 11:43:58 -0700 [thread overview] Message-ID: <20210528184405.1793783-1-atish.patra@wdc.com> (raw) This series adds improved perf support for RISC-V based system using SBI PMU extension[1]. It is based on a platform driver instead of a existing arch specific implementation. The new perf implementation has adopted a modular approach where most of the generic event handling is done in the core library while individual PMUs need to only implement necessary features specific to the PMU. This is easily extensible and any future RISC-V PMU implementation can leverage this. Currently, SBI PMU driver & legacy PMU driver are implemented as a part of this series. The SBI based driver provides more advanced features such as event configure start/stop. This version does not implement counter overflow & filtering yet. That will implemented in the future on top of this series using "Sscofpmf" extension. The legacy driver tries to reimplement the existing minimal perf under a new config to maintain backward compatibility. This implementation only allows monitoring of always running cycle/instruction counters. Moreover, they can not be started or stopped. In general, this is very limited and not very useful. That's why, I am not very keen to carry the support into the new driver. However, I don't want to break perf for any existing hardware platforms. If nobody really uses perf currently, I will be happy to drop PATCH 4. This series has been tested in Qemu on RV64 only. Qemu[2] & OpenSBI [3] patches are required to test it. Qemu changes are not backward compatible. That means, you can not use perf anymore on older Qemu versions with latest OpenSBI and/or Kernel. However, newer kernel will just use legacy pmu driver if old OpenSBI is detected or hardware doesn't implement mcountinhibit. Here is an output of perf stat while running hackbench. [root@fedora-riscv riscv]# perf stat -e r8000000000000007 -e r8000000000000006 \ -e r0000000000000002 -e r0000000000000004 -e branch-misses -e cache-misses \ -e cycles -e instructions ./hackbench -pipe 15 process 15 Running with 15*40 (== 600) tasks. Time: 1.548 Performance counter stats for './hackbench -pipe 15 process 15': 7,103 r8000000000000007 (62.56%) --> SBI_PMU_FW_IPI_RECVD 7,767 r8000000000000006 (12.19%) --> SBI_PMU_FW_IPI_SENT 0 r0000000000000002 (24.79%) --> a custom raw event described in DT <not counted> r0000000000000004 (0.00%) --> non-supported raw event described in DT 0 branch-misses (12.65%) 0 cache-misses (25.36%) 27,978,868,702 cycles (38.12%) 27,849,527,556 instructions # 1.00 insn per cycle (50.46%) 2.431195184 seconds time elapsed 1.553153000 seconds user 13.615924000 seconds sys The patches can also be found in the github[4]. [1] https://lists.riscv.org/g/tech-unixplatformspec/message/950 [2] https://github.com/atishp04/qemu/tree/riscv_pmu_v1 [3] https://github.com/atishp04/opensbi/tree/riscv_pmu_v2 [4] https://github.com/atishp04/linux/tree/riscv_pmu_v2 Changes from v1->v2 1. Implemented the latest SBI PMU extension specification. 2. The core platform driver was changed to operate as a library while only sbi based PMU is built as a driver. The legacy one is just a fallback if SBI PMU extension is not available. Atish Patra (7): RISC-V: Remove the current perf implementation RISC-V: Add CSR encodings for all HPMCOUNTERS RISC-V: Add a perf core library for pmu drivers RISC-V: Add a simple platform driver for RISC-V legacy perf RISC-V: Add RISC-V SBI PMU extension definitions RISC-V: Add perf platform driver based on SBI PMU extension Documentation: riscv: Remove the old documentation Documentation/riscv/pmu.rst | 255 ------------- arch/riscv/Kconfig | 13 - arch/riscv/include/asm/csr.h | 58 +++ arch/riscv/include/asm/perf_event.h | 72 ---- arch/riscv/include/asm/sbi.h | 94 +++++ arch/riscv/kernel/Makefile | 1 - arch/riscv/kernel/perf_event.c | 485 ------------------------- drivers/perf/Kconfig | 25 ++ drivers/perf/Makefile | 5 + drivers/perf/riscv_pmu.c | 328 +++++++++++++++++ drivers/perf/riscv_pmu_legacy.c | 92 +++++ drivers/perf/riscv_pmu_sbi.c | 537 ++++++++++++++++++++++++++++ include/linux/cpuhotplug.h | 1 + include/linux/perf/riscv_pmu.h | 61 ++++ 14 files changed, 1201 insertions(+), 826 deletions(-) delete mode 100644 Documentation/riscv/pmu.rst delete mode 100644 arch/riscv/kernel/perf_event.c create mode 100644 drivers/perf/riscv_pmu.c create mode 100644 drivers/perf/riscv_pmu_legacy.c create mode 100644 drivers/perf/riscv_pmu_sbi.c create mode 100644 include/linux/perf/riscv_pmu.h -- 2.25.1
WARNING: multiple messages have this Message-ID (diff)
From: Atish Patra <atish.patra@wdc.com> To: linux-kernel@vger.kernel.org Cc: Atish Patra <atish.patra@wdc.com>, Anup Patel <anup.patel@wdc.com>, bpf@vger.kernel.org, Daniel Lezcano <daniel.lezcano@linaro.org>, Guo Ren <guoren@linux.alibaba.com>, Heinrich Schuchardt <xypron.glpk@gmx.de>, Kefeng Wang <wangkefeng.wang@huawei.com>, linux-doc@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-riscv@lists.infradead.org, Nick Kossifidis <mick@ics.forth.gr>, Palmer Dabbelt <palmer@dabbelt.com>, Paul Walmsley <paul.walmsley@sifive.com>, Alan Kao <alankao@andestech.com>, Nick Hu <nickhu@andestech.com>, Vincent Chen <vincent.chen@sifive.com> Subject: [RFC v2 0/7] Improve RISC-V Perf support using SBI PMU extension Date: Fri, 28 May 2021 11:43:58 -0700 [thread overview] Message-ID: <20210528184405.1793783-1-atish.patra@wdc.com> (raw) This series adds improved perf support for RISC-V based system using SBI PMU extension[1]. It is based on a platform driver instead of a existing arch specific implementation. The new perf implementation has adopted a modular approach where most of the generic event handling is done in the core library while individual PMUs need to only implement necessary features specific to the PMU. This is easily extensible and any future RISC-V PMU implementation can leverage this. Currently, SBI PMU driver & legacy PMU driver are implemented as a part of this series. The SBI based driver provides more advanced features such as event configure start/stop. This version does not implement counter overflow & filtering yet. That will implemented in the future on top of this series using "Sscofpmf" extension. The legacy driver tries to reimplement the existing minimal perf under a new config to maintain backward compatibility. This implementation only allows monitoring of always running cycle/instruction counters. Moreover, they can not be started or stopped. In general, this is very limited and not very useful. That's why, I am not very keen to carry the support into the new driver. However, I don't want to break perf for any existing hardware platforms. If nobody really uses perf currently, I will be happy to drop PATCH 4. This series has been tested in Qemu on RV64 only. Qemu[2] & OpenSBI [3] patches are required to test it. Qemu changes are not backward compatible. That means, you can not use perf anymore on older Qemu versions with latest OpenSBI and/or Kernel. However, newer kernel will just use legacy pmu driver if old OpenSBI is detected or hardware doesn't implement mcountinhibit. Here is an output of perf stat while running hackbench. [root@fedora-riscv riscv]# perf stat -e r8000000000000007 -e r8000000000000006 \ -e r0000000000000002 -e r0000000000000004 -e branch-misses -e cache-misses \ -e cycles -e instructions ./hackbench -pipe 15 process 15 Running with 15*40 (== 600) tasks. Time: 1.548 Performance counter stats for './hackbench -pipe 15 process 15': 7,103 r8000000000000007 (62.56%) --> SBI_PMU_FW_IPI_RECVD 7,767 r8000000000000006 (12.19%) --> SBI_PMU_FW_IPI_SENT 0 r0000000000000002 (24.79%) --> a custom raw event described in DT <not counted> r0000000000000004 (0.00%) --> non-supported raw event described in DT 0 branch-misses (12.65%) 0 cache-misses (25.36%) 27,978,868,702 cycles (38.12%) 27,849,527,556 instructions # 1.00 insn per cycle (50.46%) 2.431195184 seconds time elapsed 1.553153000 seconds user 13.615924000 seconds sys The patches can also be found in the github[4]. [1] https://lists.riscv.org/g/tech-unixplatformspec/message/950 [2] https://github.com/atishp04/qemu/tree/riscv_pmu_v1 [3] https://github.com/atishp04/opensbi/tree/riscv_pmu_v2 [4] https://github.com/atishp04/linux/tree/riscv_pmu_v2 Changes from v1->v2 1. Implemented the latest SBI PMU extension specification. 2. The core platform driver was changed to operate as a library while only sbi based PMU is built as a driver. The legacy one is just a fallback if SBI PMU extension is not available. Atish Patra (7): RISC-V: Remove the current perf implementation RISC-V: Add CSR encodings for all HPMCOUNTERS RISC-V: Add a perf core library for pmu drivers RISC-V: Add a simple platform driver for RISC-V legacy perf RISC-V: Add RISC-V SBI PMU extension definitions RISC-V: Add perf platform driver based on SBI PMU extension Documentation: riscv: Remove the old documentation Documentation/riscv/pmu.rst | 255 ------------- arch/riscv/Kconfig | 13 - arch/riscv/include/asm/csr.h | 58 +++ arch/riscv/include/asm/perf_event.h | 72 ---- arch/riscv/include/asm/sbi.h | 94 +++++ arch/riscv/kernel/Makefile | 1 - arch/riscv/kernel/perf_event.c | 485 ------------------------- drivers/perf/Kconfig | 25 ++ drivers/perf/Makefile | 5 + drivers/perf/riscv_pmu.c | 328 +++++++++++++++++ drivers/perf/riscv_pmu_legacy.c | 92 +++++ drivers/perf/riscv_pmu_sbi.c | 537 ++++++++++++++++++++++++++++ include/linux/cpuhotplug.h | 1 + include/linux/perf/riscv_pmu.h | 61 ++++ 14 files changed, 1201 insertions(+), 826 deletions(-) delete mode 100644 Documentation/riscv/pmu.rst delete mode 100644 arch/riscv/kernel/perf_event.c create mode 100644 drivers/perf/riscv_pmu.c create mode 100644 drivers/perf/riscv_pmu_legacy.c create mode 100644 drivers/perf/riscv_pmu_sbi.c create mode 100644 include/linux/perf/riscv_pmu.h -- 2.25.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv
next reply other threads:[~2021-05-28 18:44 UTC|newest] Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-28 18:43 Atish Patra [this message] 2021-05-28 18:43 ` [RFC v2 0/7] Improve RISC-V Perf support using SBI PMU extension Atish Patra 2021-05-28 18:43 ` [RFC v2 1/7] RISC-V: Remove the current perf implementation Atish Patra 2021-05-28 18:43 ` Atish Patra 2021-05-30 19:16 ` kernel test robot 2021-09-01 10:36 ` Not compiling with CONFIG_BPF_SYSCALL enabled Nikita Shubin 2021-09-01 10:36 ` Nikita Shubin 2021-09-01 15:45 ` Atish Patra 2021-09-01 15:45 ` Atish Patra 2021-05-28 18:44 ` [RFC v2 2/7] RISC-V: Add CSR encodings for all HPMCOUNTERS Atish Patra 2021-05-28 18:44 ` Atish Patra 2021-05-28 18:44 ` [RFC v2 3/7] RISC-V: Add a perf core library for pmu drivers Atish Patra 2021-05-28 18:44 ` Atish Patra 2021-05-28 18:44 ` [RFC v2 4/7] RISC-V: Add a simple platform driver for RISC-V legacy perf Atish Patra 2021-05-28 18:44 ` Atish Patra 2021-05-28 18:44 ` [RFC v2 5/7] RISC-V: Add RISC-V SBI PMU extension definitions Atish Patra 2021-05-28 18:44 ` Atish Patra 2021-05-28 18:44 ` [RFC v2 6/7] RISC-V: Add perf platform driver based on SBI PMU extension Atish Patra 2021-05-28 18:44 ` Atish Patra 2021-06-01 13:10 ` Stanislaw Kardach 2021-06-01 13:10 ` Stanislaw Kardach 2021-06-01 15:48 ` Anup Patel 2021-06-01 15:48 ` Anup Patel 2021-06-01 15:57 ` Anup Patel 2021-06-01 15:57 ` Anup Patel 2021-06-01 17:08 ` Stanislaw Kardach 2021-06-01 17:08 ` Stanislaw Kardach 2021-05-28 18:44 ` [RFC v2 7/7] Documentation: riscv: Remove the old documentation Atish Patra 2021-05-28 18:44 ` Atish Patra
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=20210528184405.1793783-1-atish.patra@wdc.com \ --to=atish.patra@wdc.com \ --cc=alankao@andestech.com \ --cc=anup.patel@wdc.com \ --cc=bpf@vger.kernel.org \ --cc=daniel.lezcano@linaro.org \ --cc=guoren@linux.alibaba.com \ --cc=linux-doc@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-perf-users@vger.kernel.org \ --cc=linux-riscv@lists.infradead.org \ --cc=mick@ics.forth.gr \ --cc=nickhu@andestech.com \ --cc=palmer@dabbelt.com \ --cc=paul.walmsley@sifive.com \ --cc=vincent.chen@sifive.com \ --cc=wangkefeng.wang@huawei.com \ --cc=xypron.glpk@gmx.de \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.