This is a note to let you know that I've just added the patch titled sparc32: unbreak arch_write_unlock()
to the 2.6.33-longterm tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/longterm/longterm-queue-2.6.33.git;a=summary The filename of the patch is: sparc32-unbreak-arch_write_unlock.patch and it can be found in the queue-2.6.33 subdirectory. If you, or anyone else, feels it should not be added to the 2.6.33 longterm tree, please let <sta...@kernel.org> know about it. >From 3f6aa0b113846a8628baa649af422cfc6fb1d786 Mon Sep 17 00:00:00 2001 From: Mikael Pettersson <mi...@it.uu.se> Date: Mon, 15 Aug 2011 10:11:50 +0000 Subject: sparc32: unbreak arch_write_unlock() From: Mikael Pettersson <mi...@it.uu.se> commit 3f6aa0b113846a8628baa649af422cfc6fb1d786 upstream. The sparc32 version of arch_write_unlock() is just a plain assignment. Unfortunately this allows the compiler to schedule side-effects in a protected region to occur after the HW-level unlock, which is broken. E.g., the following trivial test case gets miscompiled: #include <linux/spinlock.h> rwlock_t lock; int counter; void foo(void) { write_lock(&lock); ++counter; write_unlock(&lock); } Fixed by adding a compiler memory barrier to arch_write_unlock(). The sparc64 version combines the barrier and assignment into a single asm(), and implements the operation as a static inline, so that's what I did too. Compile-tested with sparc32_defconfig + CONFIG_SMP=y. Signed-off-by: Mikael Pettersson <mi...@it.uu.se> Signed-off-by: David S. Miller <da...@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gre...@suse.de> --- arch/sparc/include/asm/spinlock_32.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) --- a/arch/sparc/include/asm/spinlock_32.h +++ b/arch/sparc/include/asm/spinlock_32.h @@ -130,6 +130,15 @@ static inline void arch_write_lock(arch_ *(volatile __u32 *)&lp->lock = ~0U; } +static void inline arch_write_unlock(arch_rwlock_t *lock) +{ + __asm__ __volatile__( +" st %%g0, [%0]" + : /* no outputs */ + : "r" (lock) + : "memory"); +} + static inline int arch_write_trylock(arch_rwlock_t *rw) { unsigned int val; @@ -174,8 +183,6 @@ static inline int __arch_read_trylock(ar res; \ }) -#define arch_write_unlock(rw) do { (rw)->lock = 0; } while(0) - #define arch_spin_lock_flags(lock, flags) arch_spin_lock(lock) #define arch_read_lock_flags(rw, flags) arch_read_lock(rw) #define arch_write_lock_flags(rw, flags) arch_write_lock(rw) Patches currently in longterm-queue-2.6.33 which might be from mi...@it.uu.se are /home/gregkh/linux/longterm/longterm-queue-2.6.33/queue-2.6.33/sparc64-remove-unnecessary-macros-from-spinlock_64.h.patch /home/gregkh/linux/longterm/longterm-queue-2.6.33/queue-2.6.33/sparc32-unbreak-arch_write_unlock.patch _______________________________________________ stable mailing list stable@linux.kernel.org http://linux.kernel.org/mailman/listinfo/stable