Skip to content

Commit 2a0e2a0

Browse files
Julien Thierrywilldeacon
authored andcommitted
arm64: perf: Remove PMU locking
The PMU is disabled and enabled, and the counters are programmed from contexts where interrupts or preemption is disabled. The functions to toggle the PMU and to program the PMU counters access the registers directly and don't access data modified by the interrupt handler. That, and the fact that they're always called from non-preemptible contexts, means that we don't need to disable interrupts or use a spinlock. [Alexandru E.: Explained why locking is not needed, removed WARN_ONs] Signed-off-by: Julien Thierry <julien.thierry@arm.com> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Tested-by: Sumit Garg <sumit.garg@linaro.org> (Developerbox) Cc: Will Deacon <will.deacon@arm.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Link: https://lore.kernel.org/r/20200924110706.254996-4-alexandru.elisei@arm.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent 0fdf1bb commit 2a0e2a0

1 file changed

Lines changed: 0 additions & 28 deletions

File tree

arch/arm64/kernel/perf_event.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -691,15 +691,10 @@ static inline u32 armv8pmu_getreset_flags(void)
691691

692692
static void armv8pmu_enable_event(struct perf_event *event)
693693
{
694-
unsigned long flags;
695-
struct arm_pmu *cpu_pmu = to_arm_pmu(event->pmu);
696-
struct pmu_hw_events *events = this_cpu_ptr(cpu_pmu->hw_events);
697-
698694
/*
699695
* Enable counter and interrupt, and set the counter to count
700696
* the event that we're interested in.
701697
*/
702-
raw_spin_lock_irqsave(&events->pmu_lock, flags);
703698

704699
/*
705700
* Disable counter
@@ -720,21 +715,10 @@ static void armv8pmu_enable_event(struct perf_event *event)
720715
* Enable counter
721716
*/
722717
armv8pmu_enable_event_counter(event);
723-
724-
raw_spin_unlock_irqrestore(&events->pmu_lock, flags);
725718
}
726719

727720
static void armv8pmu_disable_event(struct perf_event *event)
728721
{
729-
unsigned long flags;
730-
struct arm_pmu *cpu_pmu = to_arm_pmu(event->pmu);
731-
struct pmu_hw_events *events = this_cpu_ptr(cpu_pmu->hw_events);
732-
733-
/*
734-
* Disable counter and interrupt
735-
*/
736-
raw_spin_lock_irqsave(&events->pmu_lock, flags);
737-
738722
/*
739723
* Disable counter
740724
*/
@@ -744,30 +728,18 @@ static void armv8pmu_disable_event(struct perf_event *event)
744728
* Disable interrupt for this counter
745729
*/
746730
armv8pmu_disable_event_irq(event);
747-
748-
raw_spin_unlock_irqrestore(&events->pmu_lock, flags);
749731
}
750732

751733
static void armv8pmu_start(struct arm_pmu *cpu_pmu)
752734
{
753-
unsigned long flags;
754-
struct pmu_hw_events *events = this_cpu_ptr(cpu_pmu->hw_events);
755-
756-
raw_spin_lock_irqsave(&events->pmu_lock, flags);
757735
/* Enable all counters */
758736
armv8pmu_pmcr_write(armv8pmu_pmcr_read() | ARMV8_PMU_PMCR_E);
759-
raw_spin_unlock_irqrestore(&events->pmu_lock, flags);
760737
}
761738

762739
static void armv8pmu_stop(struct arm_pmu *cpu_pmu)
763740
{
764-
unsigned long flags;
765-
struct pmu_hw_events *events = this_cpu_ptr(cpu_pmu->hw_events);
766-
767-
raw_spin_lock_irqsave(&events->pmu_lock, flags);
768741
/* Disable all counters */
769742
armv8pmu_pmcr_write(armv8pmu_pmcr_read() & ~ARMV8_PMU_PMCR_E);
770-
raw_spin_unlock_irqrestore(&events->pmu_lock, flags);
771743
}
772744

773745
static irqreturn_t armv8pmu_handle_irq(struct arm_pmu *cpu_pmu)

0 commit comments

Comments
 (0)