lkml.org 
[lkml]   [2002]   [Sep]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
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/
\
 
 \ /
  Last update: 2005-03-22 13:28    [W:1.253 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site