Messages in this thread | | | Subject | Re: [RFC][PATCH v2 5/5] mutex: Give spinners a chance to spin_on_owner if need_resched() triggered while queued | From | Jason Low <> | Date | Mon, 03 Feb 2014 10:39:20 -0800 |
| |
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.
| |