[patch] spin-nicer-2.6.11-rc1-A0

Paul Mackerras paulus at samba.org
Sun Jan 16 14:04:27 EST 2005

Ingo Molnar writes:

> * Paul Mackerras <paulus at samba.org> wrote:
> > Secondly we have lost the __spin_yield call that we had on ppc64,
> > which is an important optimization when we are running under the
> > hypervisor.  I can't just put that in cpu_relax because I need to know
> > which (virtual) cpu is holding the lock, so that I can tell the
> > hypervisor which virtual cpu to give my time slice to.  That
> > information is stored in the lock variable, which is why __spin_yield
> > needs the address of the lock.
> hm, how about calling __spin_yield() from _raw_spin_trylock(), if the
> locking attempt was unsuccessful? This might be slightly incorrect if
> the locking attempt is not connected to an actual spin-loop, but we do
> have other spin-loops with open-coded trylocks that would benefit from
> this optimization too.

That would help, but we also need to yield while we are polling the
lock until it becomes available.  Otherwise we will only yield once;
if we get another timeslice and the other cpu still hasn't finished
with the lock (or another cpu has got it now), we will spin uselessly
for the whole of our timeslice.  Thus I think we need to yield in the
polling loop, whether or not we also yield in _raw_spin_trylock.


More information about the Linuxppc64-dev mailing list