Re: [PATCH bpf-next 2/3] tools, perf: use smp_{rmb,mb} barriers instead of {rmb,mb}

2018-10-19 Thread Paul E. McKenney
On Fri, Oct 19, 2018 at 12:02:43PM +0100, Will Deacon wrote: > On Thu, Oct 18, 2018 at 08:53:42PM -0700, Alexei Starovoitov wrote: > > On Thu, Oct 18, 2018 at 09:00:46PM +0200, Daniel Borkmann wrote: > > > On 10/18/2018 05:33 PM, Alexei Starovoitov wrote: > > > > On Thu, Oct 18, 2018 at 05:04:34PM

Re: [PATCH bpf-next 2/3] tools, perf: use smp_{rmb,mb} barriers instead of {rmb,mb}

2018-10-19 Thread Will Deacon
On Thu, Oct 18, 2018 at 08:53:42PM -0700, Alexei Starovoitov wrote: > On Thu, Oct 18, 2018 at 09:00:46PM +0200, Daniel Borkmann wrote: > > On 10/18/2018 05:33 PM, Alexei Starovoitov wrote: > > > On Thu, Oct 18, 2018 at 05:04:34PM +0200, Daniel Borkmann wrote: > > >> #endif /* _TOOLS_LINUX_ASM_IA64

Re: [PATCH bpf-next 2/3] tools, perf: use smp_{rmb,mb} barriers instead of {rmb,mb}

2018-10-19 Thread Daniel Borkmann
On 10/19/2018 11:44 AM, Peter Zijlstra wrote: > On Thu, Oct 18, 2018 at 05:04:34PM +0200, Daniel Borkmann wrote: >> diff --git a/tools/include/linux/ring_buffer.h >> b/tools/include/linux/ring_buffer.h >> new file mode 100644 >> index 000..48200e0 >> --- /dev/null >> +++ b/tools/include/linux/

Re: [PATCH bpf-next 2/3] tools, perf: use smp_{rmb,mb} barriers instead of {rmb,mb}

2018-10-19 Thread Peter Zijlstra
On Thu, Oct 18, 2018 at 05:04:34PM +0200, Daniel Borkmann wrote: > diff --git a/tools/include/linux/ring_buffer.h > b/tools/include/linux/ring_buffer.h > new file mode 100644 > index 000..48200e0 > --- /dev/null > +++ b/tools/include/linux/ring_buffer.h > @@ -0,0 +1,69 @@ > +#ifndef _TOOLS_LIN

Re: [PATCH bpf-next 2/3] tools, perf: use smp_{rmb,mb} barriers instead of {rmb,mb}

2018-10-19 Thread Peter Zijlstra
On Thu, Oct 18, 2018 at 08:33:09AM -0700, Alexei Starovoitov wrote: > On Thu, Oct 18, 2018 at 05:04:34PM +0200, Daniel Borkmann wrote: > > #endif /* _TOOLS_LINUX_ASM_IA64_BARRIER_H */ > > diff --git a/tools/arch/powerpc/include/asm/barrier.h > > b/tools/arch/powerpc/include/asm/barrier.h > > inde

Re: [PATCH bpf-next 2/3] tools, perf: use smp_{rmb,mb} barriers instead of {rmb,mb}

2018-10-18 Thread Alexei Starovoitov
On Thu, Oct 18, 2018 at 09:00:46PM +0200, Daniel Borkmann wrote: > On 10/18/2018 05:33 PM, Alexei Starovoitov wrote: > > On Thu, Oct 18, 2018 at 05:04:34PM +0200, Daniel Borkmann wrote: > >> #endif /* _TOOLS_LINUX_ASM_IA64_BARRIER_H */ > >> diff --git a/tools/arch/powerpc/include/asm/barrier.h >

Re: [PATCH bpf-next 2/3] tools, perf: use smp_{rmb,mb} barriers instead of {rmb,mb}

2018-10-18 Thread Daniel Borkmann
On 10/18/2018 05:33 PM, Alexei Starovoitov wrote: > On Thu, Oct 18, 2018 at 05:04:34PM +0200, Daniel Borkmann wrote: >> #endif /* _TOOLS_LINUX_ASM_IA64_BARRIER_H */ >> diff --git a/tools/arch/powerpc/include/asm/barrier.h >> b/tools/arch/powerpc/include/asm/barrier.h >> index a634da0..905a2c6 100

Re: [PATCH bpf-next 2/3] tools, perf: use smp_{rmb,mb} barriers instead of {rmb,mb}

2018-10-18 Thread Alexei Starovoitov
On Thu, Oct 18, 2018 at 05:04:34PM +0200, Daniel Borkmann wrote: > #endif /* _TOOLS_LINUX_ASM_IA64_BARRIER_H */ > diff --git a/tools/arch/powerpc/include/asm/barrier.h > b/tools/arch/powerpc/include/asm/barrier.h > index a634da0..905a2c6 100644 > --- a/tools/arch/powerpc/include/asm/barrier.h > +

Re: [PATCH bpf-next 2/3] tools, perf: use smp_{rmb,mb} barriers instead of {rmb,mb}

2018-10-18 Thread Daniel Borkmann
On 10/18/2018 10:14 AM, Peter Zijlstra wrote: > On Thu, Oct 18, 2018 at 01:10:15AM +0200, Daniel Borkmann wrote: > >> Wouldn't this then also allow the kernel side to use smp_store_release() >> when it updates the head? We'd be pretty much at the model as described >> in Documentation/core-api/cir

Re: [PATCH bpf-next 2/3] tools, perf: use smp_{rmb,mb} barriers instead of {rmb,mb}

2018-10-18 Thread Peter Zijlstra
On Thu, Oct 18, 2018 at 01:10:15AM +0200, Daniel Borkmann wrote: > Wouldn't this then also allow the kernel side to use smp_store_release() > when it updates the head? We'd be pretty much at the model as described > in Documentation/core-api/circular-buffers.rst. > > Meaning, rough pseudo-code di

Re: [PATCH bpf-next 2/3] tools, perf: use smp_{rmb,mb} barriers instead of {rmb,mb}

2018-10-17 Thread Daniel Borkmann
On 10/17/2018 05:50 PM, Peter Zijlstra wrote: > On Wed, Oct 17, 2018 at 04:41:55PM +0200, Daniel Borkmann wrote: >> @@ -73,7 +73,8 @@ static inline u64 perf_mmap__read_head(struct perf_mmap >> *mm) >> { >> struct perf_event_mmap_page *pc = mm->base; >> u64 head = READ_ONCE(pc->data_head

Re: [PATCH bpf-next 2/3] tools, perf: use smp_{rmb,mb} barriers instead of {rmb,mb}

2018-10-17 Thread Peter Zijlstra
On Wed, Oct 17, 2018 at 04:41:55PM +0200, Daniel Borkmann wrote: > @@ -73,7 +73,8 @@ static inline u64 perf_mmap__read_head(struct perf_mmap *mm) > { > struct perf_event_mmap_page *pc = mm->base; > u64 head = READ_ONCE(pc->data_head); > - rmb(); > + > + smp_rmb(); > retur

[PATCH bpf-next 2/3] tools, perf: use smp_{rmb,mb} barriers instead of {rmb,mb}

2018-10-17 Thread Daniel Borkmann
Switch both rmb()/mb() barriers to more lightweight smp_rmb()/smp_mb() ones. When walking the perf ring buffer they pair the following way, quoting kernel/events/ring_buffer.c: Since the mmap() consumer (userspace) can run on a different CPU: kernel user i