drivers/perf: riscv_pmu: Add riscv pmu pm notifier
Subsystems (3)
PATCH 1/1 drivers/perf: riscv_pmu: Add riscv pmu pm notifier
Currently, when the CPU is doing suspend to ram, we don't save pmu counter register and its content will be lost.
To ensure perf profiling is not affected by suspend to ram, this patch is based on arm_pmu CPU_PM notifier and implements riscv pmu pm notifier. In the pm notifier, we stop the counter and update the counter value before suspend and start the counter after resume.
--- drivers/perf/riscv_pmu.c | 4 +- drivers/perf/riscv_pmu_sbi.c | 81 ++++++++++++++++++++++++++++++++-- include/linux/perf/riscv_pmu.h | 4 ++ 3 files changed, 83 insertions(+), 6 deletions(-)
drivers/perf/riscv_pmu.c +2 -2
@@ -121,7 +121,7 @@ u64 riscv_pmu_event_update(struct perf_event *event)return delta; } -static void riscv_pmu_stop (struct perf_event *event,int flags) +void riscv_pmu_stop (struct perf_event *event,int flags) {struct hw_perf_event *hwc = &event->hw;struct riscv_pmu *rvpmu =to_riscv_pmu (event->pmu);
@@ -175,7 +175,7 @@ int riscv_pmu_event_set_period(struct perf_event *event)return overflow; } -static void riscv_pmu_start (struct perf_event *event,int flags) +void riscv_pmu_start (struct perf_event *event,int flags) {struct hw_perf_event *hwc = &event->hw;struct riscv_pmu *rvpmu =to_riscv_pmu (event->pmu);
drivers/perf/riscv_pmu_sbi.c +77 -4
103 lines not on this page · raw message
include/linux/perf/riscv_pmu.h +4 -0
@@ -56,9 +56,13 @@ struct riscv_pmu {struct cpu_hw_events __percpu *hw_events;struct hlist_node node; +struct notifier_block riscv_pm_nb; };#define to_riscv_pmu (p) (container_of(p, struct riscv_pmu, pmu)) + +void riscv_pmu_start (struct perf_event *event,int flags); +void riscv_pmu_stop (struct perf_event *event,int flags);unsigned long riscv_pmu_ctr_read_csr (unsigned long csr);int riscv_pmu_event_set_period (struct perf_event *event);uint64_t riscv_pmu_ctr_get_width_mask (struct perf_event *event);
Signature · 1 line
2.36.1
Quoted 9 lines · Eric Lin
Currently, when the CPU is doing suspend to ram, we don't save pmu counter register and its content will be lost.
To ensure perf profiling is not affected by suspend to ram, this patch is based on
arm_pmuCPU_PMnotifier and implements riscv pmu pm notifier. In the pm notifier, we stop the counter and update the counter value before suspend and start the counter after resume.[...]
Applied to will (for-next/perf), thanks!
[1/1] drivers/perf: riscv_pmu: Add riscv pmu pm notifier
https://git.kernel.org/will/c/e9a023f2b73a
Cheers,
Signature · 5 lines
Will https://fixes.arm64.dev https://next.arm64.dev https://will.arm64.dev