Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 373753
b: refs/heads/master
c: 9b0fc9c
h: refs/heads/master
i:
  373751: 933598b
v: v3
  • Loading branch information
Michel Lespinasse authored and Linus Torvalds committed May 7, 2013
1 parent 7724925 commit 514a0b3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a7d2c573ae7fad1b2c877d1a1342fa5bb0d6478c
refs/heads/master: 9b0fc9c09f1b262b7fe697eba6b05095d78850e5
17 changes: 9 additions & 8 deletions trunk/lib/rwsem.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,22 +216,23 @@ struct rw_semaphore __sched *rwsem_down_write_failed(struct rw_semaphore *sem)
/* wait until we successfully acquire the lock */
set_task_state(tsk, TASK_UNINTERRUPTIBLE);
while (true) {

/* Try acquiring the write lock. */
count = RWSEM_ACTIVE_WRITE_BIAS;
if (!list_is_singular(&sem->wait_list))
count += RWSEM_WAITING_BIAS;
if (cmpxchg(&sem->count, RWSEM_WAITING_BIAS, count) ==
if (!(count & RWSEM_ACTIVE_MASK)) {
/* Try acquiring the write lock. */
count = RWSEM_ACTIVE_WRITE_BIAS;
if (!list_is_singular(&sem->wait_list))
count += RWSEM_WAITING_BIAS;
if (cmpxchg(&sem->count, RWSEM_WAITING_BIAS, count) ==
RWSEM_WAITING_BIAS)
break;
break;
}

raw_spin_unlock_irq(&sem->wait_lock);

/* Block until there are no active lockers. */
do {
schedule();
set_task_state(tsk, TASK_UNINTERRUPTIBLE);
} while (sem->count & RWSEM_ACTIVE_MASK);
} while ((count = sem->count) & RWSEM_ACTIVE_MASK);

raw_spin_lock_irq(&sem->wait_lock);
}
Expand Down

0 comments on commit 514a0b3

Please sign in to comment.