Re: [PATCH 1/2] perf bench futex: cache align the worer struct

From: Sebastian Andrzej Siewior
Date: Wed Oct 19 2016 - 10:34:32 EST


On 2016-10-17 18:09:49 [-0700], Davidlohr Bueso wrote:
> On Sun, 16 Oct 2016, Sebastian Andrzej Siewior wrote:
>
> > It popped up in perf testing that the worker consumes some amount of
> > CPU. It boils down to the increment of `ops` which causes cache line
> > bouncing between the individual threads.
>
> Are you referring to this?
>
> ÃÂÂ for (i = 0; i < nfutexes; i++, w->ops++) {
> ÃÂÂ be: add $0x1,%ebx
> 65.87 ÃÂÂ addq $0x1,0x18(%r12)
>
> (which is like 65% of 13% on my box with a default futex-hash run).
correct.

> Even better, could we get rid entirely of the ops increments and just
> use a local variable, then update the worker at the end of the function.
> The following makes 'perf' pretty much disappear in the profile.

this should do it, too. So what remains is the read access for w->futex
but since it does not pop up in perf, it is probably not that important.

> Thanks,
> Davidlohr

Sebastian