tty/ldsem, locking/rwsem: Add missing ACQUIRE to read_failed sleep loop
authorPeter Zijlstra <peterz@infradead.org>
Thu, 18 Jul 2019 13:03:15 +0000 (15:03 +0200)
committerIngo Molnar <mingo@kernel.org>
Thu, 25 Jul 2019 13:39:24 +0000 (15:39 +0200)
commit952041a8639a7a3a73a2b6573cb8aa8518bc39f8
treef2fe74978be7b45287b9f7275dbca20a3e2fcb56
parent99143f82a255e7f054bead8443462fae76dd829e
tty/ldsem, locking/rwsem: Add missing ACQUIRE to read_failed sleep loop

While reviewing rwsem down_slowpath, Will noticed ldsem had a copy of
a bug we just found for rwsem.

  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: Will Deacon <will@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Will Deacon <will@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Hurley <peter@hurleysoftware.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: 4898e640caf0 ("tty: Add timed, writer-prioritized rw semaphore")
Signed-off-by: Ingo Molnar <mingo@kernel.org>
drivers/tty/tty_ldsem.c