[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <BLU0-SMTP387BD0AE22A4EAD432D65F97210@phx.gbl>
Date: Sun, 1 Jun 2014 16:46:26 -0400
From: John David Anglin <dave.anglin@...l.net>
To: Peter Zijlstra <peterz@...radead.org>
CC: Mikulas Patocka <mpatocka@...hat.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
jejb@...isc-linux.org, deller@....de, linux-parisc@...r.kernel.org,
linux-kernel@...r.kernel.org, chegu_vinod@...com,
paulmck@...ux.vnet.ibm.com, Waiman.Long@...com, tglx@...utronix.de,
riel@...hat.com, akpm@...ux-foundation.org, davidlohr@...com,
hpa@...or.com, andi@...stfloor.org, aswin@...com,
scott.norton@...com, Jason Low <jason.low2@...com>
Subject: Re: [PATCH] fix a race condition in cancelable mcs spinlocks
On 1-Jun-14, at 3:20 PM, Peter Zijlstra wrote:
>> If you write to some variable with ACCESS_ONCE and use cmpxchg or
>> xchg at
>> the same time, you break it. ACCESS_ONCE doesn't take the hashed
>> spinlock,
>> so, in this case, cmpxchg or xchg isn't really atomic at all.
>
> And this is really the first place in the kernel that breaks like
> this?
> I've been using xchg() and cmpxchg() without such consideration for
> quite a while.
I believe Mikulas is correct. Even in a controlled situation where a
cmpxchg operation
is used to implement pthread_spin_lock() in userspace, we found
recently that the lock
must be released with a cmpxchg operation and not a simple write on
SMP systems.
There is a race in the cache operations or instruction ordering that's
not present with
the ldcw instruction.
Dave
--
John David Anglin dave.anglin@...l.net
--
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