Skip to contentSkip to conversation

powerpc/perf: Account for interrupts during PMC overflow for an invalid SIAR check

PATCH Applied Athira Rajeev 3 participants 3 messages Aug 6, 2020 – Aug 20, 2020 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/perf: Account for interrupts during PMC overflow for an invalid SIAR check

Performance monitor interrupt handler checks if any counter has overflown and calls record_and_restart in core-book3s which invokes perf_event_overflow to record the sample information.
Apart from creating sample, perf_event_overflow also does the interrupt and period checks via perf_event_account_interrupt.

Currently we record information only if the SIAR valid bit is set ( using siar_valid check ) and hence the interrupt check.
But it is possible that we do sampling for some events that are not generating valid SIAR and hence there is no chance to disable the event if interrupts is more than max_samples_per_tick. This leads to soft lockup.

Fix this by adding perf_event_account_interrupt in the invalid siar code path for a sampling event. ie if siar is invalid, just do interrupt check and don't record the sample information.

---
 arch/powerpc/perf/core-book3s.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/powerpc/perf/core-book3s.c +4 -0
index 01d7028..626e587 100644
@@ -2101,6 +2101,10 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
 
 		if (perf_event_overflow(event, &data, regs))
 			power_pmu_stop(event, 0);
+	} else if (period) {
+		/* Account for interrupt incase of invalid siar */
+		if (perf_event_account_interrupt(event))
+			power_pmu_stop(event, 0);
 	}
 }
 
Signature · 1 line
1.8.3.1
Tested-by on v1 1/1
#1 lore raw
Quoted 12 lines · Athira Rajeev

Performance monitor interrupt handler checks if any counter has overflown and calls record_and_restart in core-book3s which invokes perf_event_overflow to record the sample information.
Apart from creating sample, perf_event_overflow also does the interrupt and period checks via perf_event_account_interrupt.

Currently we record information only if the SIAR valid bit is set ( using siar_valid check ) and hence the interrupt check.
But it is possible that we do sampling for some events that are not generating valid SIAR and hence there is no chance to disable the event if interrupts is more than max_samples_per_tick. This leads to soft lockup.

Quoted 6 lines

Fix this by adding perf_event_account_interrupt in the invalid siar code path for a sampling event. ie if siar is invalid, just do interrupt check and don't record the sample information.

Quoted 20 lines
---
 arch/powerpc/perf/core-book3s.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/powerpc/perf/core-book3s.c +4 -0
index 01d7028..626e587 100644
@@ -2101,6 +2101,10 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
 
 		if (perf_event_overflow(event, &data, regs))
 			power_pmu_stop(event, 0);
+	} else if (period) {
+		/* Account for interrupt incase of invalid siar */
+		if (perf_event_account_interrupt(event))
+			power_pmu_stop(event, 0);
 	}
 }
 
Signature · 1 line
Alexey
#2 lore raw
In reply to Athira Rajeev
Quoted 6 lines · Athira Rajeev

Performance monitor interrupt handler checks if any counter has overflown and calls record_and_restart in core-book3s which invokes perf_event_overflow to record the sample information.
Apart from creating sample, perf_event_overflow also does the interrupt and period checks via perf_event_account_interrupt.

Quoted 7 lines

Currently we record information only if the SIAR valid bit is set ( using siar_valid check ) and hence the interrupt check.
But it is possible that we do sampling for some events that are not generating valid SIAR and hence there is no chance to disable the event if interrupts is more than max_samples_per_tick. This leads to soft lockup.

[...]

Applied to powerpc/fixes.

[1/1] powerpc/perf: Fix soft lockups due to missed interrupt accounting

      https://git.kernel.org/powerpc/c/17899eaf88d689529b866371344c8f269ba79b5f

cheers