[PATCH v3 44/57] perf: Simplify bpf_overflow_handler()
Peter Zijlstra
peterz at infradead.org
Mon Jun 12 09:07:57 UTC 2023
Signed-off-by: Peter Zijlstra (Intel) <peterz at infradead.org>
---
kernel/events/core.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -10288,16 +10288,14 @@ static void bpf_overflow_handler(struct
int ret = 0;
ctx.regs = perf_arch_bpf_user_pt_regs(regs);
- if (unlikely(__this_cpu_inc_return(bpf_prog_active) != 1))
- goto out;
- rcu_read_lock();
- prog = READ_ONCE(event->prog);
- if (prog) {
- perf_prepare_sample(data, event, regs);
- ret = bpf_prog_run(prog, &ctx);
+ if (likely(__this_cpu_inc_return(bpf_prog_active) == 1)) {
+ guard(rcu)();
+ prog = READ_ONCE(event->prog);
+ if (prog) {
+ perf_prepare_sample(data, event, regs);
+ ret = bpf_prog_run(prog, &ctx);
+ }
}
- rcu_read_unlock();
-out:
__this_cpu_dec(bpf_prog_active);
if (!ret)
return;
More information about the Linux-security-module-archive
mailing list