提交 94232a43 编写于 作者: M Martin Schwidefsky

s390/rwlock: improve writer fairness

Set the write-lock bit in the out-of-line rwlock code to indicate that
a writer is waiting. Additional readers will no be able to get the lock
until at least one writer got the lock. Additional writers have to wait
for the first writer to release the lock again.
Signed-off-by: NMartin Schwidefsky <schwidefsky@de.ibm.com>
上级 2684e73a
...@@ -149,9 +149,10 @@ EXPORT_SYMBOL(_raw_read_trylock_retry); ...@@ -149,9 +149,10 @@ EXPORT_SYMBOL(_raw_read_trylock_retry);
void _raw_write_lock_wait(arch_rwlock_t *rw) void _raw_write_lock_wait(arch_rwlock_t *rw)
{ {
unsigned int owner, old; unsigned int owner, old, prev;
int count = spin_retry; int count = spin_retry;
prev = 0x80000000;
owner = 0; owner = 0;
while (1) { while (1) {
if (count-- <= 0) { if (count-- <= 0) {
...@@ -161,10 +162,13 @@ void _raw_write_lock_wait(arch_rwlock_t *rw) ...@@ -161,10 +162,13 @@ void _raw_write_lock_wait(arch_rwlock_t *rw)
} }
old = ACCESS_ONCE(rw->lock); old = ACCESS_ONCE(rw->lock);
owner = ACCESS_ONCE(rw->owner); owner = ACCESS_ONCE(rw->owner);
if (old) if ((int) old >= 0 &&
continue; _raw_compare_and_swap(&rw->lock, old, old | 0x80000000))
if (_raw_compare_and_swap(&rw->lock, 0, 0x80000000)) prev = old;
return; else
smp_rmb();
if ((old & 0x7fffffff) == 0 && (int) prev >= 0)
break;
} }
} }
EXPORT_SYMBOL(_raw_write_lock_wait); EXPORT_SYMBOL(_raw_write_lock_wait);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册