Skip to content

Commit 058244c

Browse files
Sebastian Andrzej SiewiorPeter Zijlstra
authored andcommitted
perf: Move irq_work_queue() where the event is prepared.
Only if perf_event::pending_sigtrap is zero, the irq_work accounted by increminging perf_event::nr_pending. The member perf_event::pending_addr might be overwritten by a subsequent event if the signal was not yet delivered and is expected. The irq_work will not be enqeueued again because it has a check to be only enqueued once. Move irq_work_queue() to where the counter is incremented and perf_event::pending_sigtrap is set to make it more obvious that the irq_work is scheduled once. Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Tested-by: Marco Elver <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 3a54654 commit 058244c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

kernel/events/core.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9727,6 +9727,11 @@ static int __perf_event_overflow(struct perf_event *event,
97279727
if (!event->pending_sigtrap) {
97289728
event->pending_sigtrap = pending_id;
97299729
local_inc(&event->ctx->nr_pending);
9730+
9731+
event->pending_addr = 0;
9732+
if (valid_sample && (data->sample_flags & PERF_SAMPLE_ADDR))
9733+
event->pending_addr = data->addr;
9734+
irq_work_queue(&event->pending_irq);
97309735
} else if (event->attr.exclude_kernel && valid_sample) {
97319736
/*
97329737
* Should not be able to return to user space without
@@ -9742,11 +9747,6 @@ static int __perf_event_overflow(struct perf_event *event,
97429747
*/
97439748
WARN_ON_ONCE(event->pending_sigtrap != pending_id);
97449749
}
9745-
9746-
event->pending_addr = 0;
9747-
if (valid_sample && (data->sample_flags & PERF_SAMPLE_ADDR))
9748-
event->pending_addr = data->addr;
9749-
irq_work_queue(&event->pending_irq);
97509750
}
97519751

97529752
READ_ONCE(event->overflow_handler)(event, data, regs);

0 commit comments

Comments
 (0)