powerpc/perf: Account for interrupts during PMC overflow for an invalid SIAR check
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
@@ -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
Quoted 12 lines · Athira Rajeev
Performance monitor interrupt handler checks if any counter has overflown and calls
record_and_restartin core-book3s which invokesperf_event_overflowto record the sample information.
Apart from creating sample,perf_event_overflowalso does the interrupt and period checks viaperf_event_account_interrupt.Currently we record information only if the SIAR valid bit is set ( using
siar_validcheck ) 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 thanmax_samples_per_tick. This leads to soft lockup.
Quoted 6 lines
Fix this by adding
perf_event_account_interruptin 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.Signed-off-by Athira Rajeev <[email protected]>Reported-by Alexey Kardashevskiy <[email protected]>
Quoted 20 lines
--- arch/powerpc/perf/core-book3s.c | 4 ++++ 1 file changed, 4 insertions(+)arch/powerpc/perf/core-book3s.c +4
-0@@ -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
Michael Ellerman
AppliedQuoted 6 lines · Athira Rajeev
Performance monitor interrupt handler checks if any counter has overflown and calls
record_and_restartin core-book3s which invokesperf_event_overflowto record the sample information.
Apart from creating sample,perf_event_overflowalso does the interrupt and period checks viaperf_event_account_interrupt.
Quoted 7 lines
Currently we record information only if the SIAR valid bit is set ( using
siar_validcheck ) 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 thanmax_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