summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-03-06 07:57:51 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-03-13 11:34:53 -0400
commitbf45f4affd1f1ac98bdb5a9508db06c7d24fb0c7 (patch)
tree6d77be2e99a53ba09d50c5219f0785da7e6b9d05
parent244278db71980cd06f546b0e8dc4d1e6903abaf6 (diff)
six locks: be more careful about lost wakeups
This is a workaround for a lost wakeup bug we've been seeing - we still need to discover the actual bug. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--kernel/locking/six.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/kernel/locking/six.c b/kernel/locking/six.c
index 5a6eadc0e840..3d366a843eb5 100644
--- a/kernel/locking/six.c
+++ b/kernel/locking/six.c
@@ -143,8 +143,17 @@ static int __do_six_trylock_type(struct six_lock *lock,
* lock, issue a wakeup because we might have caused a
* spurious trylock failure:
*/
+#if 0
+ /*
+ * This code should be sufficient, but we're seeing unexplained
+ * lost wakeups:
+ */
if (old.write_locking)
ret = -1 - SIX_LOCK_write;
+#else
+ if (!ret)
+ ret = -1 - SIX_LOCK_write;
+#endif
} else if (type == SIX_LOCK_write && lock->readers) {
if (try) {
atomic64_add(__SIX_VAL(write_locking, 1),
@@ -320,11 +329,10 @@ static bool __six_relock_type(struct six_lock *lock, enum six_lock_type type,
* Similar to the lock path, we may have caused a spurious write
* lock fail and need to issue a wakeup:
*/
- if (old.write_locking)
- six_lock_wakeup(lock, old, SIX_LOCK_write);
-
if (ret)
six_acquire(&lock->dep_map, 1, type == SIX_LOCK_read, ip);
+ else
+ six_lock_wakeup(lock, old, SIX_LOCK_write);
return ret;
}