[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1391452760.7498.26.camel@j-VirtualBox>
Date: Mon, 03 Feb 2014 10:39:20 -0800
From: Jason Low <jason.low2@...com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Ingo Molnar <mingo@...hat.com>,
Paul McKenney <paulmck@...ux.vnet.ibm.com>,
Waiman Long <Waiman.Long@...com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Thomas Gleixner <tglx@...utronix.de>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Rik van Riel <riel@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Davidlohr Bueso <davidlohr@...com>,
"H. Peter Anvin" <hpa@...or.com>, Andi Kleen <andi@...stfloor.org>,
"Chandramouleeswaran, Aswin" <aswin@...com>,
"Norton, Scott J" <scott.norton@...com>, chegu_vinod@...com
Subject: Re: [RFC][PATCH v2 5/5] mutex: Give spinners a chance to
spin_on_owner if need_resched() triggered while queued
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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists