Skip to content

Commit 05ab728

Browse files
Julien Thierrywilldeacon
authored andcommitted
arm64: perf: Defer irq_work to IPI_IRQ_WORK
When handling events, armv8pmu_handle_irq() calls perf_event_overflow(), and subsequently calls irq_work_run() to handle any work queued by perf_event_overflow(). As perf_event_overflow() raises IPI_IRQ_WORK when queuing the work, this isn't strictly necessary and the work could be handled as part of the IPI_IRQ_WORK handler. In the common case the IPI handler will run immediately after the PMU IRQ handler, and where the PE is heavily loaded with interrupts other handlers may run first, widening the window where some counters are disabled. In practice this window is unlikely to be a significant issue, and removing the call to irq_work_run() would make the PMU IRQ handler NMI safe in addition to making it simpler, so let's do that. [Alexandru E.: Reworded commit message] Signed-off-by: Julien Thierry <julien.thierry@arm.com> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Cc: Julien Thierry <julien.thierry.kdev@gmail.com> 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-5-alexandru.elisei@arm.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent 2a0e2a0 commit 05ab728

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

arch/arm64/kernel/perf_event.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -792,20 +792,16 @@ static irqreturn_t armv8pmu_handle_irq(struct arm_pmu *cpu_pmu)
792792
if (!armpmu_event_set_period(event))
793793
continue;
794794

795+
/*
796+
* Perf event overflow will queue the processing of the event as
797+
* an irq_work which will be taken care of in the handling of
798+
* IPI_IRQ_WORK.
799+
*/
795800
if (perf_event_overflow(event, &data, regs))
796801
cpu_pmu->disable(event);
797802
}
798803
armv8pmu_start(cpu_pmu);
799804

800-
/*
801-
* Handle the pending perf events.
802-
*
803-
* Note: this call *must* be run with interrupts disabled. For
804-
* platforms that can have the PMU interrupts raised as an NMI, this
805-
* will not work.
806-
*/
807-
irq_work_run();
808-
809805
return IRQ_HANDLED;
810806
}
811807

0 commit comments

Comments
 (0)