[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <52B1EE96.9000708@hp.com>
Date: Wed, 18 Dec 2013 13:51:02 -0500
From: Waiman Long <waiman.long@...com>
To: Linus Torvalds <torvalds@...ux-foundation.org>
CC: Paul McKenney <paulmck@...ux.vnet.ibm.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>, Arnd Bergmann <arnd@...db.de>,
"linux-arch@...r.kernel.org" <linux-arch@...r.kernel.org>,
the arch/x86 maintainers <x86@...nel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Peter Zijlstra <peterz@...radead.org>,
Steven Rostedt <rostedt@...dmis.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Michel Lespinasse <walken@...gle.com>,
Andi Kleen <andi@...stfloor.org>,
Rik van Riel <riel@...hat.com>,
Raghavendra K T <raghavendra.kt@...ux.vnet.ibm.com>,
George Spelvin <linux@...izon.com>,
Tim Chen <tim.c.chen@...ux.intel.com>,
Aswin Chandramouleeswaran <aswin@...com>,
Scott J Norton <scott.norton@...com>
Subject: Re: [PATCH v7 1/4] qrwlock: A queue read/write lock implementation
On 12/17/2013 02:27 PM, Linus Torvalds wrote:
> On Tue, Dec 17, 2013 at 11:21 AM, Paul E. McKenney
> <paulmck@...ux.vnet.ibm.com> wrote:
>> Looks like xadd() is x86-specific, but this is common code. One
>> approach would be to do xadd() for other arches, another approach
>> would be to make .rw be an atomic_t rather than a u32. Making it
>> be atomic_t is probably easiest. (The cmpxchg()s would then need
>> to be atomic_cmpxchg().)
> Note that "xadd()" has different semantics from "atomic_add_return()".
>
> xadd() returns the original value, while atomic_add_return() returns
> the result of the addition.
>
> In this case, we seem to want the xadd() semantics. I guess we can use
> "atomic_add_return(val,&atomic)-val" and just assume that the compiler
> gets it right (with the addition and the subtraction cancelling out).
> Or maybe we should have a "atomic_add_return_original()" with xadd
> semantics?
>
> Linus
I will use the atomic_add_return() for the combined count. Actually what
the code is looking for in the returned value is the state of the writer
byte. So it doesn't really matter if _QR_BIAS has or hasn't been added
to the count.
-Longman
--
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