six locks: Centralize setting of waiting bit
Originally, the waiting bit was always set by trylock() on failure: however, it's now set by __six_lock_type_slowpath(), with wait_lock held - which is the more correct place to do it. That made setting the waiting bit in trylock redundant, so this patch deletes that. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
@ -151,14 +151,6 @@ static int __do_six_trylock_type(struct six_lock *lock,
|
|||||||
atomic64_add(__SIX_VAL(write_locking, 1),
|
atomic64_add(__SIX_VAL(write_locking, 1),
|
||||||
&lock->state.counter);
|
&lock->state.counter);
|
||||||
smp_mb__after_atomic();
|
smp_mb__after_atomic();
|
||||||
} else if (!(lock->state.waiters & (1 << SIX_LOCK_write))) {
|
|
||||||
atomic64_add(__SIX_VAL(waiters, 1 << SIX_LOCK_write),
|
|
||||||
&lock->state.counter);
|
|
||||||
/*
|
|
||||||
* pairs with barrier after unlock and before checking
|
|
||||||
* for readers in unlock path
|
|
||||||
*/
|
|
||||||
smp_mb__after_atomic();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = !pcpu_read_count(lock);
|
ret = !pcpu_read_count(lock);
|
||||||
@ -190,10 +182,9 @@ static int __do_six_trylock_type(struct six_lock *lock,
|
|||||||
|
|
||||||
if (type == SIX_LOCK_write)
|
if (type == SIX_LOCK_write)
|
||||||
new.write_locking = 0;
|
new.write_locking = 0;
|
||||||
} else if (!try && !(new.waiters & (1 << type)))
|
} else {
|
||||||
new.waiters |= 1 << type;
|
break;
|
||||||
else
|
}
|
||||||
break; /* waiting bit already set */
|
|
||||||
} while ((v = atomic64_cmpxchg_acquire(&lock->state.counter,
|
} while ((v = atomic64_cmpxchg_acquire(&lock->state.counter,
|
||||||
old.v, new.v)) != old.v);
|
old.v, new.v)) != old.v);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user