|
@@ -2010,8 +2010,12 @@ static int unqueue_me(struct futex_q *q)
|
|
|
|
|
|
/* In the common case we don't take the spinlock, which is nice. */
|
|
/* In the common case we don't take the spinlock, which is nice. */
|
|
retry:
|
|
retry:
|
|
- lock_ptr = q->lock_ptr;
|
|
|
|
- barrier();
|
|
|
|
|
|
+ /*
|
|
|
|
+ * q->lock_ptr can change between this read and the following spin_lock.
|
|
|
|
+ * Use READ_ONCE to forbid the compiler from reloading q->lock_ptr and
|
|
|
|
+ * optimizing lock_ptr out of the logic below.
|
|
|
|
+ */
|
|
|
|
+ lock_ptr = READ_ONCE(q->lock_ptr);
|
|
if (lock_ptr != NULL) {
|
|
if (lock_ptr != NULL) {
|
|
spin_lock(lock_ptr);
|
|
spin_lock(lock_ptr);
|
|
/*
|
|
/*
|