[PATCH] ARM: implement optimized percpu variable access
Nicolas Pitre
nico at fluxnic.net
Tue Nov 27 12:29:39 EST 2012
On Mon, 12 Nov 2012, Rob Herring wrote:
> On 11/12/2012 04:23 AM, Will Deacon wrote:
> > On Sun, Nov 11, 2012 at 03:20:40AM +0000, Rob Herring wrote:
> >> +static inline void set_my_cpu_offset(unsigned long off)
> >> +{
> >> + asm volatile("mcr p15, 0, %0, c13, c0, 4 @ set TPIDRPRW" : : "r" (off) : "cc" );
> >> +}
> >
> > You don't need the "cc" here.
>
> You would think so, but the compiler drops this instruction if you
> don't. set_cr does the same thing.
If set_cr does it, that's because of historical reasons. A long long
time ago, you could use predicates inside inline assembly statements.
The %? was needed to conditionally execute the included instructions in
case gcc had decided not to branch over your code. So you had to write:
asm volatile("mcr%? p15, 0, %0, c13, c0, 4" : : "r" (off));
Or, if you didn't want to bother with %?, you had to clobber the
condition code to force gcc to emit a branch over the inline assembly
block when it shouldn't have been executed.
This subtlety was the source of many bugs as most people didn't use %?
properly, so CC is always assumed to be clobbered by inline assembly
now.
Nicolas
More information about the linux-arm-kernel
mailing list