Re: [patch] spinlocks: remove 'volatile'

Ralf Baechle
2006-07-08T22:50:14Z

On Thu, Jul 06, 2006 at 01:34:14PM -0700, Linus Torvalds wrote:

> On Thu, 6 Jul 2006, Linus Torvalds wrote:
> >
> > So I _think_ that we should change the "=m" to the much more correct "+m"
> > at the same time (or before - it's really a bug-fix regardless) as
> > removing the "volatile".
>
> Here's a first cut (UNTESTED!) for x86. I didn't check any other
> architectures, I bet they have similar problems.

I tried the same on MIPS, for lazyness sake at first only in atomic.h. With
gcc 3.3 the code size is exactly the same with both "=m" and "+m", so I
didn't look into details of the generated code. With gcc 4.1 "+m" results
in a size increase of about 1K for the ip27_defconfig kernel. For example:

<unlock_kernel>:
df830000 ld v1,0(gp)
8c620028 lw v0,40(v1)
04400014 bltz v0,a80000000029944c <unlock_kernel+0x5c>
00000000 nop
2442ffff subiu v0,v0,1
ac620028 sw v0,40(v1) # current->lock_depth
8c630028 lw v1,40(v1) # current->lock_depth
0461000b bgez v1,a80000000029943c <unlock_kernel+0x4c>

The poinless load isn't generated with "=m". The interesting thing is
that in all the instances of bloat I looked at it was actually happening
not as part of the asm statement itself, so maybe gcc's reload is getting
a little confused.

Ralf