2005-03-19 20:39:42

by Jeff Garzik

[permalink] [raw]
Subject: [PATCH] _raw_read_trylock for alpha


alpha SMP doesn't build, due to lack of _raw_read_trylock().

Patch below completely untested... needs review and testing.

One could also use the arch-neutral generic_raw_read_trylock(),
but that implementation is rather lame (it spins). I'm amazed at the
number of arches that use the generic implementation, since the generic
version isn't really a "trylock".

Don't send this patch upstream until its been verified to actually work.

Signed-off-by: Jeff Garzik <[email protected]>


diff -ur ../kernel-2.6.11.orig/linux-2.6.11/include/asm-alpha/spinlock.h linux-2.6.11/include/asm-alpha/spinlock.h
--- ../kernel-2.6.11.orig/linux-2.6.11/include/asm-alpha/spinlock.h 2005-03-02 02:38:12.000000000 -0500
+++ linux-2.6.11/include/asm-alpha/spinlock.h 2005-03-19 03:26:11.000000000 -0500
@@ -153,6 +153,29 @@
}
#endif /* CONFIG_DEBUG_RWLOCK */

+static inline int _raw_read_trylock(rwlock_t * lock)
+{
+ long regx;
+ int success;
+
+ __asm__ __volatile__(
+ "1: ldl_l %1,%0\n"
+ " lda %2,0\n"
+ " blbs %1,6f\n"
+ " subl %1,2,%1\n"
+ " stl_c %1,%0\n"
+ " beq %1,6f\n"
+ " lda %2,1\n"
+ "4: mb\n"
+ ".subsection 2\n"
+ "6: br 1b\n"
+ ".previous"
+ : "=m" (*lock), "=&r" (regx), "=&r" (success)
+ : "m" (*lock) : "memory");
+
+ return success;
+}
+
static inline int _raw_write_trylock(rwlock_t * lock)
{
long regx;


2005-03-20 02:40:15

by Richard Henderson

[permalink] [raw]
Subject: Re: [PATCH] _raw_read_trylock for alpha

On Sat, Mar 19, 2005 at 03:39:33PM -0500, Jeff Garzik wrote:
> Don't send this patch upstream until its been verified to actually work.

It certainly won't. I'll gen up something soon.


r~