Re: [PATCH bpf-next 3/3] bpf, libbpf: use proper barriers in perf ring buffer walk

2018-10-17 Thread Peter Zijlstra
On Wed, Oct 17, 2018 at 04:41:56PM +0200, Daniel Borkmann wrote: > +static __u64 bpf_perf_read_head(struct perf_event_mmap_page *header) > +{ > + __u64 data_head = READ_ONCE(header->data_head); > + > + smp_rmb(); > + return data_head; > +} > + > +static void bpf_perf_write_tail(struct

[PATCH bpf-next 3/3] bpf, libbpf: use proper barriers in perf ring buffer walk

2018-10-17 Thread Daniel Borkmann
Add bpf_perf_read_head() and bpf_perf_write_tail() helpers to make it more clear in what context barriers are used here, and use smp_rmb() as well as smp_mb() barriers. Given libbpf is not restricted to x86-64 only, the compiler barrier needs to be replaced with smp_rmb(). Also the