lkml.org 
[lkml]   [2014]   [Feb]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [RFC][PATCH v2 5/5] mutex: Give spinners a chance to spin_on_owner if need_resched() triggered while queued
From
Date
On Sun, 2014-02-02 at 22:12 +0100, Peter Zijlstra wrote:
> The way I wrote that same loop in step-B, is:
>
>
> for (;;) {
> if (*lock == node && cmpxchg(lock, node, prev) == node)
> return
>
> next = xchg(&node->next, NULL); /* B -> A */
> if (next)
> break;
>
> arch_mutex_cpu_relax();
> }
>
> I suppose we can make that something like:
>
>
> if (node->next) {
> next = xchg(&node->next, NULL);
> if (next)
> break
> }
>
> To avoid the xchg on every loop.

Ah yes, we want to use xchg() on &node->next.

Since the cmpxchg() is now in a loop in the unlock function, an
additional (*lock == node) check before the cmpxchg() would also be nice
to avoid spinning on cmpxchg() there too.



\
 
 \ /
  Last update: 2014-02-03 20:21    [W:0.079 / U:0.920 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site