Thread (10 messages) flat view 10 messages, 5 authors, 2021-08-18

Re: [PATCH v1 2/4] powerpc/64s/perf: add power_pmu_running to query whether perf is being used

From: Madhavan Srinivasan <maddy@linux.ibm.com>
Date: 2021-08-17 13:07:06

On 8/16/21 12:59 PM, Nicholas Piggin wrote:
quoted hunk ↗ jump to hunk
Interrupt handling code would like to know whether perf is enabled, to
know whether it should enable MSR[EE] to improve PMI coverage.

Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Athira Rajeev <redacted>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
  arch/powerpc/include/asm/hw_irq.h |  2 ++
  arch/powerpc/perf/core-book3s.c   | 13 +++++++++++++
  2 files changed, 15 insertions(+)
diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h
index 21cc571ea9c2..2d5c0d3ccbb6 100644
--- a/arch/powerpc/include/asm/hw_irq.h
+++ b/arch/powerpc/include/asm/hw_irq.h
@@ -306,6 +306,8 @@ static inline bool lazy_irq_pending_nocheck(void)
  	return __lazy_irq_pending(local_paca->irq_happened);
  }
  
+bool power_pmu_running(void);
+
  /*
   * This is called by asynchronous interrupts to conditionally
   * re-enable hard interrupts after having cleared the source
diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index bb0ee716de91..76114a9afb2b 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -2380,6 +2380,19 @@ static void perf_event_interrupt(struct pt_regs *regs)
  	perf_sample_event_took(sched_clock() - start_clock);
  }
  
+bool power_pmu_running(void)
+{
+	struct cpu_hw_events *cpuhw;
+
+	/* Could this simply test local_paca->pmcregs_in_use? */
+
+	if (!ppmu)
+		return false;

This covers only when perf platform driver is not registered,
but we should also check for MMCR0[32], since pmu sprs can be
accessed via sysfs.

Maddy

+
+	cpuhw = this_cpu_ptr(&cpu_hw_events);
+	return cpuhw->n_events;
+}
+
  static int power_pmu_prepare_cpu(unsigned int cpu)
  {
  	struct cpu_hw_events *cpuhw = &per_cpu(cpu_hw_events, cpu);
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help