Skip to content

Commit 99143f8

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
lcoking/rwsem: Add missing ACQUIRE to read_slowpath sleep loop
While reviewing another read_slowpath patch, both Will and I noticed another missing ACQUIRE, namely: X = 0; CPU0 CPU1 rwsem_down_read() for (;;) { set_current_state(TASK_UNINTERRUPTIBLE); X = 1; rwsem_up_write(); rwsem_mark_wake() atomic_long_add(adjustment, &sem->count); smp_store_release(&waiter->task, NULL); if (!waiter.task) break; ... } r = X; Allows 'r == 0'. Reported-by: Peter Zijlstra (Intel) <[email protected]> Reported-by: Will Deacon <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Will Deacon <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Ingo Molnar <[email protected]>
1 parent e1b98fa commit 99143f8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

kernel/locking/rwsem.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1073,8 +1073,10 @@ rwsem_down_read_slowpath(struct rw_semaphore *sem, int state)
10731073
/* wait to be given the lock */
10741074
while (true) {
10751075
set_current_state(state);
1076-
if (!waiter.task)
1076+
if (!smp_load_acquire(&waiter.task)) {
1077+
/* Orders against rwsem_mark_wake()'s smp_store_release() */
10771078
break;
1079+
}
10781080
if (signal_pending_state(state, current)) {
10791081
raw_spin_lock_irq(&sem->wait_lock);
10801082
if (waiter.task)

0 commit comments

Comments
 (0)