alpha rwsem fix
PATCH 1/1 alpha rwsem fix
__down_read_trylock is utterly broken in a contention case, as Richard pointed out. Here's a replacement.
Ivan.
include/asm-alpha/rwsem.h +6 -4
@@ -93,14 +93,16 @@ static inline void __down_read(struct rw*/ static inline int __down_read_trylock (struct rw_semaphore *sem) { -long res, tmp; +long old, new, res; res = sem->count;do { - tmp = res +RWSEM_ACTIVE_READ_BIAS ; -if (tmp <=0 ) + new = res +RWSEM_ACTIVE_READ_BIAS ; +if (new <=0 )break ; - }while (cmpxchg (&sem->count, res, tmp) != res); + old = res; + res =cmpxchg (&sem->count, old, new); + }while (res != old);return res >=0 ?1 :0 ; }