[lkml]   [2010]   [Dec]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [RFC][PATCH 05/17] x86: Optimize arch_spin_unlock_wait()
On Fri, Dec 24, 2010 at 4:23 AM, Peter Zijlstra <> wrote:
> Only wait for the current holder to release the lock.
> spin_unlock_wait() can only be about the current holder, since
> completion of this function is inherently racy with new contenders.
> Therefore, there is no reason to wait until the lock is completely
> unlocked.

Is there really any reason for this patch? I'd rather keep the simpler
and more straightforward code unless you have actual numbers.

> +static inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
> +{
> +       int tmp = ACCESS_ONCE(lock->slock);
> +
> +       if (!(((tmp >> TICKET_SHIFT) ^ tmp) & TICKET_MASK))
> +               return; /* not locked */
> +
> +       /* wait until the current lock holder goes away */
> +       while ((lock->slock & TICKET_MASK) == (tmp & TICKET_MASK))
> +               cpu_relax();
>  }

Also, the above is just ugly. You've lost the ACCESS_ONCE() on the
lock access, and it's using another model of masking than the regular
one. Both of which may be intentional (maybe you are _trying_ to get
the compiler to just load the low bytes and avoid the 'and'), but the
whole open-coding of the logic - twice, and with different looking
masking - just makes my skin itch.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2010-12-24 19:35    [W:0.206 / U:49.544 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site