Commit 99143f82 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

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: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reported-by: default avatarWill Deacon <will@kernel.org>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: default avatarWill Deacon <will@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: 1da177e4 ("Linux-2.6.12-rc2")
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent e1b98fa3
......@@ -1073,8 +1073,10 @@ rwsem_down_read_slowpath(struct rw_semaphore *sem, int state)
/* wait to be given the lock */
while (true) {
set_current_state(state);
if (!waiter.task)
if (!smp_load_acquire(&waiter.task)) {
/* Orders against rwsem_mark_wake()'s smp_store_release() */
break;
}
if (signal_pending_state(state, current)) {
raw_spin_lock_irq(&sem->wait_lock);
if (waiter.task)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment