Skip to contentSkip to conversation

drivers/perf: riscv_pmu: Add riscv pmu pm notifier

PATCH Applied Eric Lin 2 participants 2 messages Jul 5, 2022 – Jul 6, 2022

Subsystems (3)
lore
Share & tools
lore

Eric Lin

author
#0 lore raw

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
index b2b8d2074ed0..2c961839903d 100644
@@ -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
index 46f9b6fe306e..bf66fe011fa8 100644
@@ -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
maintainer Applied
#1 lore raw
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_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.

[...]

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