Messages in this thread Patch in this message |  | | Date | Fri, 13 Sep 2002 18:39:24 +0400 | From | Ivan Kokshaysky <> | Subject | [patch 2.5.34] alpha rwsem fix |
| |
__down_read_trylock is utterly broken in a contention case, as Richard pointed out. Here's a replacement.
Ivan.
--- 2.5.34/include/asm-alpha/rwsem.h Tue Sep 3 01:12:00 2002 +++ linux/include/asm-alpha/rwsem.h Fri Sep 13 03:31:20 2002 @@ -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; } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|  |