Skip to content

Commit c4fcc7d

Browse files
khueyIngo Molnar
authored andcommitted
perf/bpf: Allow a BPF program to suppress all sample side effects
Returning zero from a BPF program attached to a perf event already suppresses any data output. Return early from __perf_event_overflow() in this case so it will also suppress event_limit accounting, SIGTRAP generation, and F_ASYNC signalling. Signed-off-by: Kyle Huey <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Acked-by: Song Liu <[email protected]> Acked-by: Jiri Olsa <[email protected]> Acked-by: Namhyung Kim <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 76f6d58 commit c4fcc7d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

kernel/events/core.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9677,6 +9677,9 @@ static int __perf_event_overflow(struct perf_event *event,
96779677

96789678
ret = __perf_event_account_interrupt(event, throttle);
96799679

9680+
if (event->prog && !bpf_overflow_handler(event, data, regs))
9681+
return ret;
9682+
96809683
/*
96819684
* XXX event_limit might not quite work as expected on inherited
96829685
* events
@@ -9726,8 +9729,7 @@ static int __perf_event_overflow(struct perf_event *event,
97269729
irq_work_queue(&event->pending_irq);
97279730
}
97289731

9729-
if (!(event->prog && !bpf_overflow_handler(event, data, regs)))
9730-
READ_ONCE(event->overflow_handler)(event, data, regs);
9732+
READ_ONCE(event->overflow_handler)(event, data, regs);
97319733

97329734
if (*perf_event_fasync(event) && event->pending_kill) {
97339735
event->pending_wakeup = 1;

0 commit comments

Comments
 (0)