Re: [PATCH 1/5] x86/percpu: Differentiate this_cpu_{}() and __this_cpu_{}()
From: Peter Zijlstra
Date: Wed Feb 27 2019 - 11:48:20 EST
On Wed, Feb 27, 2019 at 08:14:09AM -0800, Linus Torvalds wrote:
> On Wed, Feb 27, 2019 at 2:16 AM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> >
> > Nadav Amit reported that commit:
> >
> > b59167ac7baf ("x86/percpu: Fix this_cpu_read()")
> >
> > added a bunch of constraints to all sorts of code; and while some of
> > that was correct and desired, some of that seems superfluous.
>
> Hmm.
>
> I have the strong feeling that we should instead relax this_cpu_read()
> again a bit.
>
> In particular, making it "asm volatile" really is a big hammer
> approach. It's worth noting that the *other* this_cpu_xyz ops don't
> even do that.
Right, this patch 'fixes' that :-)
> I would suggest that instead of making "this_cpu_read()" be asm
> volatile, we mark it as potentially changing the memory location it is
> touching - the same way the modify/write ops do.
>
> That still means that the read will be forced (like READ_ONCE()), but
> allows gcc a bit more flexibility in instruction scheduling, I think.
Ah, fair enough, I'll spin a version of this patch with "+m" for
this_cpu and "m" for raw_cpu.
> That said, I didn't actually check how it affects code generation.
> Nadav, would you check the code sequences you originally noticed?
Much of it was the ONCE behaviour defeating CSE I think, but yes, it
would be good to have another look.