Commit a64af0e
bpf, libbpf: use correct barriers in perf ring buffer walk
Given libbpf is a generic library and not restricted to x86-64 only,
the compiler barrier in bpf_perf_event_read_simple() after fetching
the head needs to be replaced with smp_rmb() at minimum. Also, writing
out the tail we should use WRITE_ONCE() to avoid store tearing.
Now that we have the logic in place in ring_buffer_read_head() and
ring_buffer_write_tail() helper also used by perf tool which would
select the correct and best variant for a given architecture (e.g.
x86-64 can avoid CPU barriers entirely), make use of these in order
to fix bpf_perf_event_read_simple().
Fixes: d0cabbb ("tools: bpf: move the event reading loop to libbpf")
Fixes: 3911169 ("samples: bpf: add bpf_perf_event_output example")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>1 parent 09d6215 commit a64af0e
1 file changed
+4
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
2418 | 2419 | | |
2419 | 2420 | | |
2420 | 2421 | | |
2421 | | - | |
| 2422 | + | |
| 2423 | + | |
2422 | 2424 | | |
2423 | | - | |
2424 | 2425 | | |
2425 | 2426 | | |
2426 | 2427 | | |
2427 | | - | |
2428 | 2428 | | |
2429 | 2429 | | |
2430 | 2430 | | |
| |||
2467 | 2467 | | |
2468 | 2468 | | |
2469 | 2469 | | |
2470 | | - | |
2471 | | - | |
2472 | | - | |
| 2470 | + | |
2473 | 2471 | | |
2474 | 2472 | | |
0 commit comments