[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140207154346.GC3104@twins.programming.kicks-ass.net>
Date: Fri, 7 Feb 2014 16:43:46 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Torsten Duwe <duwe@....de>
Cc: Scott Wood <scottwood@...escale.com>, linux-kernel@...r.kernel.org,
Paul Mackerras <paulus@...ba.org>,
Anton Blanchard <anton@...ba.org>,
Tom Musta <tommusta@...il.com>,
"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
linuxppc-dev@...ts.ozlabs.org, Ingo Molnar <mingo@...nel.org>
Subject: Re: [PATCH] Convert powerpc simple spinlocks into ticket locks
On Fri, Feb 07, 2014 at 04:18:47PM +0100, Peter Zijlstra wrote:
> void ticket_lock(tickets_t *lock)
> {
> tickets_t t;
>
> /*
> * Because @head is MSB, the direct increment wrap doesn't disturb
> * @tail.
> */
> t.pair = xadd(&lock->pair, 1<<16);
>
> if (likely(t.head == t.tail)) {
> __lwsync(); /* acquire */
> return;
> }
>
> while (smp_load_acquire(&lock->tail) != t.tail)
> cpu_relax();
That should be "!= t.head", for that contains our ticket.
I'm hopelessly scatter brained today it seems :/
> }
>
> void ticket_unlock(tickets_t *lock)
> {
> ticket_t tail = lock->tail + 1;
>
> /*
> * The store is save against the xadd for it will make the ll/sc fail
> * and try again. Aside from that PowerISA guarantees single-copy
> * atomicy for half-word writes.
> *
> * And since only the lock owner will ever write the tail, we're good.
> */
> smp_store_release(&lock->tail, tail);
> }
--
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